public void ReturnBook(int bookOfficeId, UserAndOrganizationDTO userAndOrg) { var log = _bookLogsDbSet .FirstOrDefault(l => l.BookOfficeId == bookOfficeId && l.ApplicationUserId == userAndOrg.UserId && l.OrganizationId == userAndOrg.OrganizationId && l.Returned == null); _bookServiceValidator.ThrowIfBookCannotBeReturned(log != null); log.Returned = DateTime.UtcNow; log.Modified = DateTime.UtcNow; log.ModifiedBy = userAndOrg.UserId; _uow.SaveChanges(false); }
public async Task ReturnBookAsync(int bookOfficeId, UserAndOrganizationDto userAndOrg) { var log = await _bookLogsDbSet .FirstOrDefaultAsync(l => l.BookOfficeId == bookOfficeId && l.ApplicationUserId == userAndOrg.UserId && l.OrganizationId == userAndOrg.OrganizationId && l.Returned == null); _bookServiceValidator.ThrowIfBookCannotBeReturned(log != null); // ReSharper disable once PossibleNullReferenceException log.Returned = DateTime.UtcNow; log.Modified = DateTime.UtcNow; log.ModifiedBy = userAndOrg.UserId; await _uow.SaveChangesAsync(false); }