public static DTO_CUS_SYS_Role toDTO(tbl_CUS_SYS_Role dbResult) { if (dbResult != null) { return(new DTO_CUS_SYS_Role() { IDPartner = dbResult.IDPartner, 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, }); } else { return(null); } }
public static DTO_CUS_SYS_Role post_CUS_SYS_Role(AppEntities db, int PartnerID, DTO_CUS_SYS_Role item, string Username) { tbl_CUS_SYS_Role dbitem = new tbl_CUS_SYS_Role(); if (item != null) { 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.CreatedBy = Username; dbitem.CreatedDate = DateTime.Now; dbitem.ModifiedBy = Username; dbitem.ModifiedDate = DateTime.Now; dbitem.IDPartner = PartnerID; try { db.tbl_CUS_SYS_Role.Add(dbitem); db.SaveChanges(); BS_CUS_Version.update_CUS_Version(db, dbitem.IDPartner, "DTO_CUS_SYS_Role", 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_SYS_Role", e); item = null; } } return(item); }