public HttpResponseMessage Patch(DateTime diaryid, int id, [FromBody] DiaryEntryModel model) { try { var entity = TheRepo.GetDiaryEntry(_identityService.CurrentUser, diaryid, id); if (entity == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } var parsedValue = TheModelFactory.Parse(model); if (parsedValue == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } if (entity.Quantity != parsedValue.Quantity) { entity.Quantity = parsedValue.Quantity; if (TheRepo.SaveAll()) { return(Request.CreateResponse(HttpStatusCode.OK)); } } return(Request.CreateResponse(HttpStatusCode.BadRequest)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public HttpResponseMessage Get(DateTime diaryid, int id) { var result = TheRepo.GetDiaryEntry(_identityService.CurrentUser, diaryid.Date, id); if (result == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } return(Request.CreateResponse(HttpStatusCode.OK, TheModelFactory.Create(result))); }