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; })); }
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; })); }
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; })); }
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; })); }
public void Delete(int id) { _footerRepository.Delete(id); }