コード例 #1
0
        public async Task <ActionResult <Therapy> > PostTherapy(Therapy therapy)
        {
            try
            {
                await _service.AddTherapy(therapy);
            }
            catch (TherapyAdlAlreadyExistException e)
            {
                return(Conflict(e));
            }
            catch (TherapyAbbreviationAlreadyExistException e)
            {
                return(Conflict(e));
            }
            catch (TherapyMainDoesNotExistException e)
            {
                return(BadRequest(e));
            }
            catch (DbUpdateException)
            {
                throw;
            }

            return(CreatedAtAction("GetTherapy", new { id = therapy.Adl }, therapy));
        }
コード例 #2
0
 public IHttpActionResult AddTherapy([FromBody] Therapy therapy)
 {
     therapy.Date = therapy.Date.ToLocalTime();
     _therapyService.AddTherapy(therapy);
     return(Ok());
 }