Exemplo n.º 1
0
        public HttpResponseMessage Delete(HttpRequestMessage request, int id)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                if (!ModelState.IsValid)
                {
                    response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState);
                }
                else
                {
                    var oldFooter = _footerService.Delete(id);
                    _footerService.Save();

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

                return response;
            }));
        }
Exemplo n.º 2
0
        public HttpResponseMessage Delete(HttpRequestMessage request, string id)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                if (!ModelState.IsValid)
                {
                    //trả về lỗi để bên ngoài bắt được sự kiện lỗi này
                    response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState);
                }
                else
                {
                    var oldProduct = _footerService.Delete(id); //xoá dữ liệu cũ

                    _footerService.Save();

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

                return response;
            }));
        }
Exemplo n.º 3
0
 public async Task <HttpResponseMessage> Delete(HttpRequestMessage request, int id)
 {
     return(await CreateHttpResponse(request, () =>
     {
         HttpResponseMessage response = null;
         if (ModelState.IsValid)
         {
             request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
         }
         else
         {
             _footerService.Delete(id);
             _footerService.SaveAsync();
             response = request.CreateResponse(HttpStatusCode.OK);
         }
         return response;
     }));
 }
Exemplo n.º 4
0
        public HttpResponseMessage Delete(HttpRequestMessage request, int id)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;
                if (!ModelState.IsValid)
                {
                    request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
                }
                else
                {
                    _footerService.Delete(id);
                    _footerService.SaveChanges();

                    response = request.CreateResponse(HttpStatusCode.OK);
                }
                return response;
            }));
        }
Exemplo n.º 5
0
 public void Delete(int id)
 {
     _footerRepository.Delete(id);
 }