public HttpResponseMessage Put(string id, [FromBody] preg_country dataUpdate)
        {
            try
            {
                if (!dataUpdate.DeepEquals(new preg_country()))
                {
                    preg_country country = new preg_country();
                    country = dao.GetItemByID(Convert.ToInt32(id)).FirstOrDefault();
                    if (country == null)
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.NotFound, SysConst.DATA_NOT_FOUND));
                    }
                    if (dataUpdate.name != null)
                    {
                        country.name = dataUpdate.name;
                    }

                    dao.UpdateData(country);
                    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_country data)
 {
     try
     {
         IEnumerable <preg_country> result;
         if (!data.DeepEquals(new preg_country()))
         {
             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_country data)
 {
     try
     {
         if (!data.DeepEquals(new preg_country()))
         {
             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));
     }
 }