public async Task UpdateAsync(Guid id, CuratorDto curator) { if (id == Guid.Empty) { throw new ArgumentNullException(nameof(id)); } if (curator == null) { throw new ArgumentNullException(nameof(curator)); } var entity = await UnitOfWork.GetRepository <Curator>().FindByIdAsync(id); if (entity == null || entity.IsArchive) { throw new NotFoundException($"Curator with id = {id} not found."); } entity.FirstName = curator.FirstName; entity.Surname = curator.Surname; entity.Patronymic = curator.Patronymic; UnitOfWork.GetRepository <Curator>().Update(entity); await UnitOfWork.CommitAsync(); }
public async Task AddAsync(CuratorDto curator) { if (curator == null) { throw new ArgumentNullException(nameof(curator)); } UnitOfWork.GetRepository <Curator>().Add(Mapper.Map <Curator>(curator)); await UnitOfWork.CommitAsync(); }