public async Task UpdateAsync(UserUpdateCommand command) { await ValidatorFactory.GetValidator <UserUpdateCommand>().ValidateAndThrowAsync(command); var user = await _readRepository.GetSingleAsync(_userFiltersProvider.ById(command.Id)); user.FirstName = command.FirstName; user.LastName = command.LastName; user.Phone = command.Phone; user.Birthday = DateTime.SpecifyKind(command.Birthday.Date, DateTimeKind.Utc); user.Salary = command.Salary; await WriteRepository.UpdateAsync(user); await UnitOfWork.CommitAsync(); }
public async Task <UserModel> GetByIdAsync(int id) { var user = await ReadRepository.GetSingleAsync(_filtersProvider.ById(id), _relationsProvider.JoinRole); if (user == null) { throw new NotFoundException("Item was not found!"); } return(Mapper.Map <UserModel>(user)); }
private async Task <bool> UserExists(int id, CancellationToken cancellationToken) { return(await Task.Run(() => ReadRepository.ValidateExists(_userFiltersProvider.ById(id)), cancellationToken)); }