Beispiel #1
0
 public HttpResponseMessage Creatte(HttpRequestMessage request, FooterViewModel footerVm)
 {
     return(CreateHttpResponse(request, () =>
     {
         if (ModelState.IsValid)
         {
             if (_footerService.GetAll() == null)
             {
                 Footer footerDb = new Footer();
                 footerDb.UpdateFooter(footerVm);
                 _footerService.Add(footerDb);
                 _footerService.SaveChange();
                 return request.CreateResponse(HttpStatusCode.Created, footerVm);
             }
             else
             {
                 return request.CreateErrorResponse(HttpStatusCode.BadRequest, "Đã tồn tại");
             }
         }
         else
         {
             return request.CreateResponse(HttpStatusCode.BadRequest, ModelState);
         }
     }));
 }