public bool CreateReviewer(ReviewerCreateDto reviewerToCreateDto) { var reviewerToCreate = MapConfig.Mapper.Map <Reviewer>(reviewerToCreateDto); _reviewerContext.Add(reviewerToCreate); return(Save()); }
public IActionResult CreateReviewer([FromBody] ReviewerCreateDto newReviewer) { if (newReviewer == null) { return(BadRequest(ModelState)); } if (_unitOfWork.ReviewerRepository.ReviewerExists(newReviewer.Id)) { ModelState.AddModelError("", "Such reviewer Exists!"); return(StatusCode(404, ModelState)); } if (!_unitOfWork.ReviewerRepository.CreateReviewer(newReviewer)) { ModelState.AddModelError("", $"Something went wrong saving the reviewer " + $"{newReviewer.ReviewerFirstName}{newReviewer.ReviewerLastName}"); return(StatusCode(500, ModelState)); } _unitOfWork.Commit(); return(CreatedAtRoute("GetReviewerById", new { reviewerId = newReviewer.Id }, newReviewer)); }