public HttpResponseMessage Put(string id, [FromBody] preg_guides_type dataUpdate) { try { if (!dataUpdate.DeepEquals(new preg_guides())) { preg_guides_type guides_type = new preg_guides_type(); guides_type = dao.GetItemByID(Convert.ToInt32(id)).FirstOrDefault(); if (guides_type == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, SysConst.DATA_NOT_FOUND)); } if (dataUpdate.type != null) { guides_type.type = dataUpdate.type; } dao.UpdateData(guides_type); return(Request.CreateResponse(HttpStatusCode.Accepted, SysConst.DATA_UPDATE_SUCCESS)); } else { HttpError err = new HttpError(SysConst.DATA_NOT_EMPTY); return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, err)); } } catch (Exception ex) { HttpError err = new HttpError(ex.Message); return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, err)); } }
public HttpResponseMessage Get([FromUri] preg_guides_type data) { try { IEnumerable <preg_guides_type> result; if (!data.DeepEquals(new preg_guides())) { result = dao.GetItemsByParams(data); } else { result = dao.GetListItem(); } if (result.Count() > 0) { return(Request.CreateResponse(HttpStatusCode.OK, result)); } else { HttpError err = new HttpError(SysConst.DATA_NOT_FOUND); return(Request.CreateErrorResponse(HttpStatusCode.NotFound, err)); } } catch (Exception ex) { HttpError err = new HttpError(ex.Message); return(Request.CreateErrorResponse(HttpStatusCode.NotFound, err)); } }
public HttpResponseMessage Post([FromBody] preg_guides_type data) { try { if (!data.DeepEquals(new preg_guides())) { dao.InsertData(data); return(Request.CreateResponse(HttpStatusCode.Created, SysConst.DATA_INSERT_SUCCESS)); } else { HttpError err = new HttpError(SysConst.DATA_NOT_EMPTY); return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, err)); } } catch (Exception ex) { HttpError err = new HttpError(ex.Message); return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, err)); } }