public void AddUser([FromServices] AccountService service, [FromBody] AccountUserDto dto) { if (string.IsNullOrWhiteSpace(dto.Account)) { throw new LogicException("帐号为空"); } if (string.IsNullOrWhiteSpace(dto.Name)) { throw new LogicException("名稱为空"); } if (string.IsNullOrWhiteSpace(dto.PassWord)) { throw new LogicException("密碼为空"); } if (string.IsNullOrWhiteSpace(dto.ComfirmPassword)) { throw new LogicException("确认密碼为空"); } if (dto.PassWord != dto.ComfirmPassword) { throw new LogicException("两次密碼不一致"); } var entity = dto.ProjectedAs <AccountUser>(); service.AddUser(entity); }
public void EditUser([FromServices] AccountService service, [FromBody] AccountUserDto dto) { var entity = dto.ProjectedAs <AccountUser>(); service.EditUser(entity); }