/// <summary> /// 测试初始化 /// </summary> public DCUsersServiceTest() { _scope = Ioc.BeginScope(); _dCUsersRepository = _scope.Create <IDCUsersRepository>(); _dCUsersService = _scope.Create <IDCUsersService>(); _dCUsersDto = DCUsersDtoTest.Create(); }
/// <summary> /// 转换为用户名实体 /// </summary> /// <param name="dto">用户名数据传输对象</param> public static DCUsers ToEntity(this DCUsersDto dto) { if (dto == null) { return(new DCUsers()); } return(dto.MapTo(new DCUsers(dto.Id.ToLong()))); }
public async Task <IActionResult> Register(RegisterModel model) { if (ModelState.IsValid) { var DCUsersService = Ioc.Create <IDCUsersService>(); var modelUser = new DCUsersDto(); modelUser.Name = model.Username; modelUser.NickName = model.Username; modelUser.Email = model.Email; modelUser.PasswordVersion = 1; modelUser.Salt = Randoms.MakeRandomString(SiteSetting.Current.WebConfig.RandomLibrary, 6); modelUser.Password = await DCUsersService.CreateUserPassword(model.Password, modelUser.Salt); modelUser.Description = ""; modelUser.IsSystemAdministrator = false; modelUser.CreationTime = DateTime.Now; await DCUsersService.CreateAsync(modelUser); } return(View()); }
/// <summary> /// 转换为用户名实体 /// </summary> /// <param name="dto">用户名数据传输对象</param> public static DCUsers ToEntity2(this DCUsersDto dto) { if (dto == null) { return(new DCUsers()); } return(new DCUsers(dto.Id.ToLong()) { Name = dto.Name, NickName = dto.NickName, Email = dto.Email, PasswordVersion = dto.PasswordVersion, Password = dto.Password, Salt = dto.Salt, Description = dto.Description, IsSystemAdministrator = dto.IsSystemAdministrator.SafeValue(), CreationTime = dto.CreationTime, CreatId = dto.CreatId, LastModifiTime = dto.LastModifiTime, LastModifiId = dto.LastModifiId, IsDeleted = dto.IsDeleted.SafeValue(), Version = dto.Version, }); }