Exemplo n.º 1
0
        public IEnumerable <DiaryEntryModel> Get(DateTime diaryid)
        {
            var results = TheRepo.GetDiaryEntries(_identityService.CurrentUser, diaryid.Date)
                          .ToList()
                          .Select(e => TheModelFactory.Create(e));

            return(results);
        }
Exemplo n.º 2
0
 public HttpResponseMessage Delete(DateTime diaryid, int id)
 {
     try
     {
         if (TheRepo.GetDiaryEntries(_identityService.CurrentUser, diaryid).Any(e => e.Id == id) == false)
         {
             return(Request.CreateResponse(HttpStatusCode.NotFound));
         }
         if (TheRepo.DeleteDiaryEntry(id) && TheRepo.SaveAll())
         {
             return(Request.CreateResponse(HttpStatusCode.OK));
         }
         else
         {
             return(Request.CreateResponse(HttpStatusCode.BadRequest));
         }
     }
     catch (Exception ex) {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Could not save in the database"));
     }
 }