コード例 #1
0
        public ActionResult Post([FromBody] MedicineScheduleTreatmentViewModel medicineScheduleVM)
        {
            var schedule = _mapper.Map <MedicineScheduleTreatment>(medicineScheduleVM);

            try
            {
                _medicineScheduleService.Create(schedule);
                return(Ok());
            }
            catch (AppException ex)
            {
                return(BadRequest(new { message = ex.Message }));
            }
        }
コード例 #2
0
        public ActionResult Put(int idScheduleTreatment, [FromBody] MedicineScheduleTreatmentViewModel scheduleVM)
        {
            // map dto to entity and set id
            var schedule = _mapper.Map <MedicineScheduleTreatment>(scheduleVM);

            schedule.ScheduleTreatmentID = idScheduleTreatment;

            try
            {
                // save
                _medicineScheduleService.Update(schedule);
                return(Ok());
            }
            catch (AppException ex)
            {
                // return error message if there was an exception
                return(BadRequest(new { message = ex.Message }));
            }
        }