Example #1
0
 public void CopyFrom(WarningViewModel itemViewModel, DBUnitOfWork db)
 {
     Message = itemViewModel.Message;
     if (itemViewModel.ItemEntityId != null)
     {
         ItemEntityId = itemViewModel.ItemEntityId.Value;
     }
     else
     {
         throw new Exception("This Warning doesn't have an associated Item!");
     }
 }
Example #2
0
 public HttpResponseMessage Get()
 {
     using (var db = new DBUnitOfWork())
     {
         try
         {
             var warningViewModels = new List<WarningViewModel>();
             var warningModels = db.Repository<Warning>().GetAll();
             foreach (var warning in warningModels)
             {
                 var warningViewModel = new WarningViewModel();
                 warningViewModel.CopyFrom(warning);
                 warningViewModels.Add(warningViewModel);
             }
             return Request.CreateResponse(HttpStatusCode.OK, warningViewModels); ;
         }
         catch (Exception)
         {
             return Request.CreateResponse(HttpStatusCode.InternalServerError);
         }
     }
 }