public static DTO_CUS_HRM_LIST_ChucDanh toDTO(tbl_CUS_HRM_LIST_ChucDanh dbResult) { if (dbResult != null) { return(new DTO_CUS_HRM_LIST_ChucDanh() { IDPartner = dbResult.IDPartner, IDBoPhan = dbResult.IDBoPhan, ID = dbResult.ID, Code = dbResult.Code, Name = dbResult.Name, Remark = dbResult.Remark, IsDisabled = dbResult.IsDisabled, Sort = dbResult.Sort, IsDeleted = dbResult.IsDeleted, CreatedDate = dbResult.CreatedDate, ModifiedDate = dbResult.ModifiedDate, CreatedBy = dbResult.CreatedBy, ModifiedBy = dbResult.ModifiedBy, }); } else { return(null); } }
public static DTO_CUS_HRM_LIST_ChucDanh post_CUS_HRM_LIST_ChucDanh(AppEntities db, int PartnerID, DTO_CUS_HRM_LIST_ChucDanh item, string Username) { tbl_CUS_HRM_LIST_ChucDanh dbitem = new tbl_CUS_HRM_LIST_ChucDanh(); if (item != null) { dbitem.IDBoPhan = item.IDBoPhan; dbitem.Code = item.Code; dbitem.Name = item.Name; dbitem.Remark = item.Remark; dbitem.IsDisabled = item.IsDisabled; dbitem.Sort = item.Sort; dbitem.IsDeleted = item.IsDeleted; dbitem.CreatedBy = Username; dbitem.CreatedDate = DateTime.Now; dbitem.ModifiedBy = Username; dbitem.ModifiedDate = DateTime.Now; dbitem.IDPartner = PartnerID; try { db.tbl_CUS_HRM_LIST_ChucDanh.Add(dbitem); db.SaveChanges(); BS_CUS_Version.update_CUS_Version(db, dbitem.IDPartner, "DTO_CUS_HRM_LIST_ChucDanh", 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_LIST_ChucDanh", e); item = null; } } return(item); }