Exemplo n.º 1
0
 public async Task <HttpResponseMessage> Post(HttpRequestMessage request, FooterViewModel footerVm)
 {
     return(await CreateHttpResponse(request, () =>
     {
         HttpResponseMessage response = null;
         if (ModelState.IsValid)
         {
             request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
         }
         else
         {
             //Khoi tao
             Footer newFooter = new Footer();
             newFooter.UpdateFooter(footerVm); //Gan ViewModel sang Model de Insert DB, this
             //Goi Insert
             var footer = _footerService.Add(newFooter);
             _footerService.SaveAsync();
             response = request.CreateResponse(HttpStatusCode.Created, footer);
         }
         return response;
     }));
 }