public static DTO_CUS_DOC_File_Permission toDTO(tbl_CUS_DOC_File_Permission dbResult)
 {
     if (dbResult != null)
     {
         return(new DTO_CUS_DOC_File_Permission()
         {
             IDPartner = dbResult.IDPartner,
             IDFile = dbResult.IDFile,
             IDRole = dbResult.IDRole,
             ID = dbResult.ID,
             ModifiedDate = dbResult.ModifiedDate,
             IsDisabled = dbResult.IsDisabled,
             IsDeleted = dbResult.IsDeleted,
             CreatedBy = dbResult.CreatedBy,
             ModifiedBy = dbResult.ModifiedBy,
             CreatedDate = dbResult.CreatedDate,
             IsCanView = dbResult.IsCanView,
             IsCanChange = dbResult.IsCanChange,
             IsCanApprove = dbResult.IsCanApprove,
         });
     }
     else
     {
         return(null);
     }
 }
        public static DTO_CUS_DOC_File_Permission post_CUS_DOC_File_Permission(AppEntities db, int PartnerID, DTO_CUS_DOC_File_Permission item, string Username)
        {
            tbl_CUS_DOC_File_Permission dbitem = new tbl_CUS_DOC_File_Permission();

            if (item != null)
            {
                dbitem.IDFile       = item.IDFile;
                dbitem.IDRole       = item.IDRole;
                dbitem.IsDisabled   = item.IsDisabled;
                dbitem.IsDeleted    = item.IsDeleted;
                dbitem.IsCanView    = item.IsCanView;
                dbitem.IsCanChange  = item.IsCanChange;
                dbitem.IsCanApprove = item.IsCanApprove;

                dbitem.CreatedBy   = Username;
                dbitem.CreatedDate = DateTime.Now;

                dbitem.ModifiedBy   = Username;
                dbitem.ModifiedDate = DateTime.Now;

                dbitem.IDPartner = PartnerID;


                try
                {
                    db.tbl_CUS_DOC_File_Permission.Add(dbitem);
                    db.SaveChanges();

                    BS_CUS_Version.update_CUS_Version(db, dbitem.IDPartner, "DTO_CUS_DOC_File_Permission", dbitem.ModifiedDate, Username);



                    item.ID = dbitem.ID;

                    item.CreatedBy   = dbitem.CreatedBy;
                    item.CreatedDate = dbitem.CreatedDate;

                    item.ModifiedBy   = dbitem.ModifiedBy;
                    item.ModifiedDate = dbitem.ModifiedDate;

                    item.IDPartner = dbitem.IDPartner;
                }
                catch (DbEntityValidationException e)
                {
                    errorLog.logMessage("post_CUS_DOC_File_Permission", e);
                    item = null;
                }
            }
            return(item);
        }