public HttpResponseMessage UpdateData(string id, preg_time_line dataUpdate)
        {
            try
            {
                if (!dataUpdate.DeepEquals(new preg_time_line()))
                {
                    preg_time_line time_line = new preg_time_line();
                    time_line = dao.GetItemByID(Convert.ToInt32(id)).FirstOrDefault();
                    if (time_line == null)
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.NotFound, SysConst.DATA_NOT_FOUND));
                    }
                    if (dataUpdate.week_id != null)
                    {
                        time_line.week_id = dataUpdate.week_id;
                    }
                    if (dataUpdate.title != null)
                    {
                        time_line.title = dataUpdate.title;
                    }
                    if (dataUpdate.image != null)
                    {
                        time_line.image = dataUpdate.image;
                    }
                    if (dataUpdate.position != null)
                    {
                        time_line.position = dataUpdate.position;
                    }
                    if (dataUpdate.time_frame_id != null)
                    {
                        time_line.time_frame_id = dataUpdate.time_frame_id;
                    }

                    dao.UpdateData(time_line);
                    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 Post([FromBody] preg_time_line data)
 {
     try
     {
         if (!data.DeepEquals(new preg_time_line()))
         {
             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));
     }
 }
 public HttpResponseMessage Get([FromUri] preg_time_line data)
 {
     try
     {
         if (!data.DeepEquals(new preg_time_line()))
         {
             IEnumerable <preg_time_line> result = dao.GetItemsByParams(data);
             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));
             }
         }
         else
         {
             IEnumerable <preg_time_line> 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));
     }
 }