// GET api/<controller>/5
 public Sys_DynamicColumnModel Get(Guid id)
 {
     string status = string.Empty;
     var service = new Sys_DynamicColumnServices();
     var result = service.GetById<Sys_DynamicColumnEntity>(id, ref status);
     var Sys_DynamicColumn = new Sys_DynamicColumnModel
     {
         ID = result.ID,
         ColumnName = result.ColumnName,
         Code = result.Code,
         Status = result.Status,
         DataType = result.DataType,
         Length = result.Length,
         TableName = result.TableName,
         Comment = result.Comment
     };
     return Sys_DynamicColumn;
     
 }
   /// <summary>
   /// Tạo mới một Sys_DynamicColumn
   /// </summary>
   /// <param name="model"></param>
   /// <returns></returns>
 
   public ActionResult Create(Sys_DynamicColumnModel model)
   {
       
       var service = new RestServiceClient<Sys_DynamicColumnModel>(UserLogin);
       var sys_DynamicColumnModel = new Sys_DynamicColumnModel();
       sys_DynamicColumnModel = model;        
       if(model.Length != null)
       {
           if (model.DataType == "Decimal") sys_DynamicColumnModel.DataType = model.DataType + "(" + model.Length + ",0)";
           else {
               sys_DynamicColumnModel.DataType = model.DataType + "(" + model.Length + ")";
           }
       }
       else {
           sys_DynamicColumnModel.DataType = model.DataType;
       }
       service.SetCookies(this.Request.Cookies, _hrm_Sys_Service);
       var result = service.Put(_hrm_Sys_Service, "api/Sys_DynamicColumn/", sys_DynamicColumnModel);
       return Json(result, JsonRequestBehavior.AllowGet);
   }
   /// <summary>
   /// Tạo mới một Sys_DynamicColumn
   /// </summary>
   /// <param name="model"></param>
   /// <returns></returns>
 
   public ActionResult Create(Sys_DynamicColumnModel model)
   {
       var isAccess = CheckPermission(UserId, PrivilegeType.Create, ConstantPermission.Sys_DynamicColumn);
       if (!isAccess)
       {
           return PartialView("AccessDenied");
       }
       var service = new RestServiceClient<Sys_DynamicColumnModel>();
       var sys_DynamicColumnModel = new Sys_DynamicColumnModel();
       sys_DynamicColumnModel = model;        
       if(model.Length != null)
       {
           if (model.DataType == "Decimal") sys_DynamicColumnModel.DataType = model.DataType + "(" + model.Length + ",0)";
           else {
               sys_DynamicColumnModel.DataType = model.DataType + "(" + model.Length + ")";
           }
       }
       else {
           sys_DynamicColumnModel.DataType = model.DataType;
       }
       service.SetCookies(this.Request.Cookies, _hrm_Sys_Service);
       var result = service.Put(_hrm_Sys_Service, "api/Sys_DynamicColumn/", sys_DynamicColumnModel);
       return Json(result, JsonRequestBehavior.AllowGet);
   }
 public ActionResult Edit([DataSourceRequest] DataSourceRequest request, Sys_DynamicColumnModel DynamicColumn)
 {
     var isAccess = CheckPermission(UserId, PrivilegeType.Modify, ConstantPermission.Sys_DynamicColumn);
     if (!isAccess)
     {
         return PartialView("AccessDenied");
     }
     var service = new RestServiceClient<Sys_DynamicColumnModel>();
     service.SetCookies(this.Request.Cookies, _hrm_Sys_Service);
     var result = service.Put(_hrm_Sys_Service, "api/Sys_DynamicColumn/", DynamicColumn);
     return Json(result);
 }
 public Sys_DynamicColumnModel Put(Sys_DynamicColumnModel model)
 {
     var Sys_DynamicColumn = new Sys_DynamicColumnEntity
     {
         ID = model.ID,
         ColumnName = model.ColumnName,
         Code = model.Code,
         Status = model.Status,
         DataType = model.DataType,
         Length = model.Length,
         TableName = model.TableName,
         Comment = model.Comment
     };
     var service = new Sys_DynamicColumnServices();
     if (model.ID != Guid.Empty)
     {
         Sys_DynamicColumn.ID = model.ID;
         service.Edit<Sys_DynamicColumnEntity>(Sys_DynamicColumn);
     }
     else
     {
         service.Add(Sys_DynamicColumn);
         model.ID = Sys_DynamicColumn.ID;
     }
     return model;
 }
 // DELETE api/<controller>/5
 public Sys_DynamicColumnModel Delete(Guid id)
 {
     var service = new Sys_DynamicColumnServices();
     service.Remove<Sys_DynamicColumnEntity>(id);
     var result = new Sys_DynamicColumnModel();
     return result;
 }
 public ActionResult Edit([DataSourceRequest] DataSourceRequest request, Sys_DynamicColumnModel DynamicColumn)
 {
     
     var service = new RestServiceClient<Sys_DynamicColumnModel>(UserLogin);
     service.SetCookies(this.Request.Cookies, _hrm_Sys_Service);
     var result = service.Put(_hrm_Sys_Service, "api/Sys_DynamicColumn/", DynamicColumn);
     return Json(result);
 }