protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity <Role>().HasData( new Role { Id = 1, Name = UserRoleNames.ADMIN }, new Role { Id = 2, Name = UserRoleNames.USER } ); modelBuilder.Entity <User>().HasData( new User { Id = 1, UserName = "******", Email = "admin", PasswordHash = "1WQsxoDVnpZqyS548nWhdA53TNno/tsuCg6X5Sw5POPN7MnQ", RoleId = 1, StatusId = (int)UserStatusEnum.Confirmed } ); modelBuilder.Entity <User>().HasData( new User { Id = 2, UserName = "******", Email = "oksana", PasswordHash = "B1QrZf+hIErc18k3AvgCW2mmVWQ+Py/Ojys/YqG9fxPu7rbt", RoleId = 2, StatusId = (int)UserStatusEnum.Confirmed } ); modelBuilder.Entity <Product>() .HasIndex(x => new { x.VkId }) .IsUnique(true); modelBuilder.Entity <VkImage>() .HasIndex(x => new { x.VkId }) .IsUnique(true); modelBuilder.Entity <UserStatus>().HasData( Enum.GetValues(typeof(UserStatusEnum)).Cast <UserStatusEnum>().Select(x => new UserStatus() { Id = (int)x, Name = UserStatusEnumHelper.ToString(x) }) ); modelBuilder.Entity <ProductType>().HasData( Enum.GetValues(typeof(ProductTypeEnum)).Cast <ProductTypeEnum>().Select(x => new ProductType() { Id = (int)x, Name = ProductTypeEnumHelper.ToString(x) }) ); modelBuilder.Entity <ProductCategory>().HasData( Enum.GetValues(typeof(ProductCategoryEnum)).Cast <ProductCategoryEnum>().Select(x => new ProductCategory() { Id = (int)x, Name = ProductCategoryEnumHelper.ToString(x), TypeId = ProductCategoryEnumHelper.GetTypeId(x) }) ); modelBuilder.Entity <ProductGoodsType>().HasData( Enum.GetValues(typeof(ProductGoodsTypeEnum)).Cast <ProductGoodsTypeEnum>().Select(x => new ProductGoodsType() { Id = (int)x, Name = ProductGoodsTypeEnumHelper.ToString(x), CategoryId = ProductGoodsTypeEnumHelper.GetCategoryId(x) }) ); modelBuilder.Entity <ProductApparel>().HasData( Enum.GetValues(typeof(ProductApparelEnum)).Cast <ProductApparelEnum>().Select(x => new ProductApparel() { Id = (int)x, Name = ProductApparelEnumHelper.ToString(x), GoodsTypeId = ProductApparelEnumHelper.GetGoodsTypeId(x) }) ); modelBuilder.Entity <ProductSize>().HasData( Enum.GetValues(typeof(ProductSizeEnum)).Cast <ProductSizeEnum>().Select(x => new ProductSize() { Id = (int)x, Name = ProductSizeEnumHelper.ToString(x), GoodsTypeId = ProductSizeEnumHelper.GetGoodsTypeId(x), ApparelId = ProductSizeEnumHelper.GetApparelId(x) }) ); modelBuilder.Entity <ProductAdType>().HasData( Enum.GetValues(typeof(ProductAdTypeEnum)).Cast <ProductAdTypeEnum>().Select(x => new ProductAdType() { Id = (int)x, Name = ProductAdTypeEnumHelper.ToString(x) }) ); modelBuilder.Entity <ProductCondition>().HasData( Enum.GetValues(typeof(ProductConditionEnum)).Cast <ProductConditionEnum>().Select(x => new ProductCondition() { Id = (int)x, Name = ProductConditionEnumHelper.ToString(x) }) ); }
public AuthProfile() { CreateMap <User, UserDTO>() .ForMember(dest => dest.StatusStr, opts => opts.MapFrom(src => UserStatusEnumHelper.ToString((UserStatusEnum)src.StatusId))); }