public IActionResult Create(TreatmentViewModel TreatmentViewModel) { try { //Get user name var userName = User.FindFirstValue(ClaimTypes.Name); TreatmentViewModel.Treatment.DoneBy = userName; // Find proper stay on Animal ID bias TreatmentViewModel.Treatment.Stay = _stayService.FindRelatedStay(TreatmentViewModel.Animal.ID); _treatmentService.Add(TreatmentViewModel.Treatment); return(RedirectToAction(nameof(Index))); } catch (InvalidOperationException e) { // throw e; return(View(TreatmentViewModel)); } }
public ContentResult CreateTreatment(Treatment treatment) { treatmentService.Add(treatment); treatmentService.Save(); return(Content("<p>The patient was created successfully!</p>")); }