public HttpResponseMessage Delete(int id) { try { SuccessResponse response = new SuccessResponse(); SavedService svc = new SavedService(); svc.Delete(id); return(Request.CreateResponse(HttpStatusCode.OK, response)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } }
public HttpResponseMessage SelectById(int id) { try { ItemResponse <SavedPost> resp = new ItemResponse <SavedPost>(); SavedService svc = new SavedService(); resp.Item = svc.SelectById(id); return(Request.CreateResponse(HttpStatusCode.OK, resp)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } }
public HttpResponseMessage Update(UpdatePostRequest model) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } try { SuccessResponse resp = new SuccessResponse(); SavedService svc = new SavedService(); svc.Update(model); return(Request.CreateResponse(HttpStatusCode.OK, resp)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } }