public UserMappingProfile()
        {
            CreateMap <RegisterViewModel, RegisterServiceModel>();
            CreateMap <RegisterServiceModel, User>()
            .ForMember(dest => dest.Password, act => act.MapFrom(src => HashPasswordService.GetHshedPassword(src.Password)))
            .ForMember(dest => dest.UserRoles, act => act.MapFrom(src => new List <UserRole> {
                new UserRole {
                    RoleId = (int)RolesOfUser.User
                }
            }));

            CreateMap <LoginViewModel, LoginServiceModel>();
            CreateMap <RegisterViewModel, AccountServiceModel>();
            CreateMap <RoleServiceModel, RoleViewModel>().ReverseMap();
        }
Beispiel #2
0
 public void Configure(EntityTypeBuilder <User> builder)
 {
     builder.ToTable("Users");
     builder.HasKey(k => k.Id);
     builder.Property(p => p.Email).IsRequired().HasColumnType("NVARCHAR(50)");
     builder.Property(p => p.Password).IsRequired().HasColumnType("NVARCHAR(50)");
     builder.HasData(
         new User[]
     {
         new User
         {
             Id = 1, Email = "*****@*****.**", Password = HashPasswordService.GetHshedPassword("superadmin")
         }
     });
 }