Example #1
0
 public HttpResponseMessage Post(HttpRequestMessage request, FooterViewModel footerVm)
 {
     return(CreateHttpResponse(request, () =>
     {
         HttpResponseMessage response = null;
         if (!ModelState.IsValid)
         {
             request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
         }
         else
         {
             Footer newFooter = new Footer();
             newFooter.UpdateFooter(footerVm);
             var category = _footerService.Add(newFooter);
             _footerService.SaveChanges();
             response = request.CreateResponse(HttpStatusCode.Created, category);
         }
         return response;
     }));
 }
Example #2
0
        public HttpResponseMessage Create(HttpRequestMessage request, FooterViewModel FooterCategoryVm)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                if (!ModelState.IsValid)
                {
                    response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState);
                }
                else
                {
                    var newFooter = new Footer();
                    newFooter.UpdateFooter(FooterCategoryVm);
                    _FooterService.Add(newFooter);
                    _FooterService.SaveChanges();

                    var responseData = Mapper.Map <Footer, FooterViewModel>(newFooter);
                    response = request.CreateResponse(HttpStatusCode.Created, responseData);
                }

                return response;
            }));
        }