using System.Collections.Generic;
using System.Linq;
using Microsoft.EntityFrameworkCore;
using UtilsSharp;

namespace Models.Data
{
    public static class DbInitializer
    {
        /// <summary>
        /// 需要同步是数据表名
        /// </summary>
        public static List<string> list = new List<string>() { "TBL_HOTEL_GROUP_INFO","TBL_HOTEL_SEASON","TBL_HOTEL_BASIC_INFO", "TBL_ROOM_TYPE_LIST", "TBL_ROOM_BASIC_INFO", "TBL_SEASON" };


        public static void Initialize(HotelServiceContext context)
        {
            //初始化数据------------------------ 主要初始化同步表  
            foreach (var item in list)
            {
                if (context.NEW_TABLE_UPDATE_TIME_MARKS.FirstOrDefault(x => x.NEW_DB_TABLE_NAME == item) == null)
                    context.NEW_TABLE_UPDATE_TIME_MARKS.Add(new Models.NEW_TABLE_UPDATE_TIME_MARK
                    {
                        NEW_DB_TABLE_NAME = item
                    });
                context.SaveChanges();
            }
        }

    }
}
