public ActionResult <ReviewProcessApiO> Patch([FromBody] ReviewProcessApiO model) { if (this.AppConfigurationService.IsDevelopment == true) { System.Threading.Thread.Sleep(7000); // sleep for 7 seconds just to see the animations working. } try { if (ModelState.IsValid == false) { ModelState.TryAddModelError(string.Empty, "The data is not valid"); return(BadRequest(ModelState)); } else { using (Transposition transposition = new Transposition()) { ReviewProcessViewModel result = transposition.Transpose <ReviewProcessApiO, ReviewProcessViewModel>(model, new ReviewProcessViewModel()); this.ReviewService.SaveReview(result, User.Identity.Name); return(model); // return the same object as was sent with status code 200 ok. } } } catch (Exception e) { // return internal server error. return(StatusCode(500, e)); } }
public ActionResult <ReviewProcessApiO> Post([FromBody] ReviewStartApiO model) { if (this.AppConfigurationService.IsDevelopment == true) { System.Threading.Thread.Sleep(2000); // sleep for 2 seconds just to see the animations working. This should show a cursor only. } try { if (ModelState.IsValid == false) { ModelState.TryAddModelError(string.Empty, "The data is not valid"); return(BadRequest(ModelState)); } else { ReviewProcessViewModel businessResult = this.ReviewService.AssembleReviewProcessViewModel(model.FoodParcelId, model.SelectedFoodItemId, model.TestId, User.Identity.Name); if (businessResult != null) { using (Transposition transposition = new Transposition()) { ReviewProcessApiO result = transposition.Transpose <ReviewProcessViewModel, ReviewProcessApiO>(businessResult, new ReviewProcessApiO()); return(result); } } else { return(NotFound()); } } } catch (Exception e) { // return internal server error. return(StatusCode(500, e)); } }