DefaultAppGuidsCreator.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using ShwasherSys.BaseSysInfo;
  7. using ShwasherSys.EntityFramework;
  8. namespace ShwasherSys.Migrations.SeedData
  9. {
  10. public class DefaultAppGuidsCreator
  11. {
  12. private readonly ShwasherDbContext _context;
  13. public DefaultAppGuidsCreator(ShwasherDbContext context)
  14. {
  15. _context = context;
  16. }
  17. public void Create()
  18. {
  19. _context.DeleteTable("[dbo].[Sys_AppGuids]");
  20. AddAppGuidIfNotExists((short)AppGuidType.PackageEnterBill,20000);
  21. }
  22. private void AddAppGuidIfNotExists(short type, int start = 100000, short step = 1)
  23. {
  24. if (_context.AppGuids.Any(s => s.IdType == type))
  25. return;
  26. _context.AppGuids.Add(new SysAppGuid()
  27. {
  28. IdType = type,
  29. LastId = start,
  30. Step = step
  31. });
  32. _context.SaveChanges();
  33. }
  34. }
  35. }