public bool UpdateLibraryManagingDirector(LibraryManagingDirectorUpdateDto libraryManagingDirectorToUpdateDto) { var libraryManagingDirectorToUpdate = MapConfig.Mapper.Map <LibraryManagingDirector>(libraryManagingDirectorToUpdateDto); _libraryManagingDirectorContext.Update(libraryManagingDirectorToUpdate); return(Save()); }
public IActionResult UpdateLibraryManagingDirector(int libraryManagingDirectorId, [FromBody] LibraryManagingDirectorUpdateDto updatedLibraryManagingDirector) { if (updatedLibraryManagingDirector == null) { return(BadRequest(ModelState)); } if (libraryManagingDirectorId != updatedLibraryManagingDirector.Id) { return(BadRequest(ModelState)); } if (!_unitOfWork.LibraryManagingDirectorRepository.LibraryManagingDirectorExists(libraryManagingDirectorId)) { ModelState.AddModelError("", "Library managing director doesn't exist!"); } if (!ModelState.IsValid) { return(StatusCode(404, ModelState)); } if (!_unitOfWork.LibraryManagingDirectorRepository.UpdateLibraryManagingDirector(updatedLibraryManagingDirector)) { ModelState.AddModelError("", $"Something went wrong updating the library managing director " + $"{updatedLibraryManagingDirector.LibraryManagingDirectorFirstName}{updatedLibraryManagingDirector.LibraryManagingDirectorLastName}"); } _unitOfWork.Commit(); return(NoContent()); }