using System.Linq; using WePlatform.BaseInfo; using WePlatform.EF; using IwbZero.Authorization.Base.SystemInfo; namespace WePlatform.SeedData { public class DefaultAppGuidsCreator { private readonly WePlatformDbContext _context; public DefaultAppGuidsCreator(WePlatformDbContext context) { _context = context; } public void Create() { _context.TruncateTable("[dbo].[Sys_AppGuids]"); AddAppGuidIfNotExists((short)AppGuidType.UserNo); AddAppGuidIfNotExists((short)AppGuidType.Guest); AddAppGuidIfNotExists((short)AppGuidType.DataLib,1000); } private void AddAppGuidIfNotExists(short type, int start = 100000, short step = 1) { if (_context.SysAppGuids.Any(s => s.IdType == type)) return; _context.SysAppGuids.Add(new SysAppGuid() { IdType = type, LastId = start, Step = step, }); _context.SaveChanges(); } } }