public static DTO_CUS_HRM_STAFF_NhanSu toDTO(tbl_CUS_HRM_STAFF_NhanSu dbResult)
 {
     if (dbResult != null)
     {
         return(new DTO_CUS_HRM_STAFF_NhanSu()
         {
             IDPartner = dbResult.IDPartner,
             IDChucDanh = dbResult.IDChucDanh,
             IDBoPhan = dbResult.IDBoPhan,
             IDRole = dbResult.IDRole,
             ID = dbResult.ID,
             Code = dbResult.Code,
             Name = dbResult.Name,
             Remark = dbResult.Remark,
             Sort = dbResult.Sort,
             IsDisabled = dbResult.IsDisabled,
             IsDeleted = dbResult.IsDeleted,
             CreatedBy = dbResult.CreatedBy,
             ModifiedBy = dbResult.ModifiedBy,
             CreatedDate = dbResult.CreatedDate,
             ModifiedDate = dbResult.ModifiedDate,
             Ten = dbResult.Ten,
             Ho = dbResult.Ho,
             Email = dbResult.Email,
             SoDienThoai = dbResult.SoDienThoai,
             DiaChi = dbResult.DiaChi,
             IsHRCO = dbResult.IsHRCO,
             IsCNDT = dbResult.IsCNDT,
         });
     }
     else
     {
         return(null);
     }
 }
        public static DTO_CUS_HRM_STAFF_NhanSu post_CUS_HRM_STAFF_NhanSu(AppEntities db, int PartnerID, DTO_CUS_HRM_STAFF_NhanSu item, string Username)
        {
            tbl_CUS_HRM_STAFF_NhanSu dbitem = new tbl_CUS_HRM_STAFF_NhanSu();

            if (item != null)
            {
                dbitem.IDChucDanh  = item.IDChucDanh;
                dbitem.IDBoPhan    = item.IDBoPhan;
                dbitem.IDRole      = item.IDRole;
                dbitem.Code        = item.Code;
                dbitem.Name        = item.Name;
                dbitem.Remark      = item.Remark;
                dbitem.Sort        = item.Sort;
                dbitem.IsDisabled  = item.IsDisabled;
                dbitem.IsDeleted   = item.IsDeleted;
                dbitem.Ten         = item.Ten;
                dbitem.Ho          = item.Ho;
                dbitem.Email       = item.Email;
                dbitem.SoDienThoai = item.SoDienThoai;
                dbitem.DiaChi      = item.DiaChi;
                dbitem.IsHRCO      = item.IsHRCO;
                dbitem.IsCNDT      = item.IsCNDT;

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

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

                dbitem.IDPartner = PartnerID;


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

                    BS_CUS_Version.update_CUS_Version(db, dbitem.IDPartner, "DTO_CUS_HRM_STAFF_NhanSu", 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_HRM_STAFF_NhanSu", e);
                    item = null;
                }
            }
            return(item);
        }