public ActionResult Post([FromBody] ScheduleTreatmentViewModel scheduleVM) { var schedule = _mapper.Map <ScheduleTreatment>(scheduleVM); var treatment = schedule.Treatment; schedule.Treatment = null; try { _scheduleService.Create(schedule, treatment); return(Ok()); } catch (AppException ex) { return(BadRequest(new { message = ex.Message })); } }
public ActionResult Put(int idTreatment, [FromBody] ScheduleTreatmentViewModel scheduleVM) { // map dto to entity and set id var schedule = _mapper.Map <ScheduleTreatment>(scheduleVM); schedule.TreatmentID = idTreatment; try { // save _scheduleService.Update(schedule); return(Ok()); } catch (AppException ex) { // return error message if there was an exception return(BadRequest(new { message = ex.Message })); } }