//convert HtmlRole kepada ASPNETROLESHTML //Update/Edit dalam Oracle DB public static int EditList(List <HtmlRole> output) { try { List <ASPNETROLESHTML> roles = new List <ASPNETROLESHTML>(); foreach (HtmlRole single in output) { ASPNETROLESHTML role = new ASPNETROLESHTML(); role.ROLEID = single.RoleId; role.MODULEID = single.ModuleId; role.HTMLNAME = single.HtmlName; role.CSSCLASS = single.CSSClass; role.ISVIEW = single.IsView ? 1 : 0; role.ISADD = single.IsAdd ? 1 : 0; role.ISEDIT = single.IsEdit ? 1 : 0; role.ISDELETE = single.IsDelete ? 1 : 0; role.TABID = single.TabId; roles.Add(role); } ASPNETROLESHTML.EditList(roles); return(0); } catch (Exception ex) { Debug.WriteLine(ex.ToString()); return(1); } }
//convert ASPNETROLESHTML kepada List<HtmlRole> //css-class kalau null, kita defaultkan valuenya ke "noclass" //display kat View public static List <HtmlRole> GetHtmlRoles(string roleId, int moduleId, int tabId = 0) { List <ASPNETROLESHTML> roles = new List <ASPNETROLESHTML>(); if (tabId == 0) { roles = ASPNETROLESHTML.GetByRoleId(roleId); } else { roles = ASPNETROLESHTML.GetByRoleId(roleId, moduleId, tabId); } List <HtmlRole> output = new List <HtmlRole>(); foreach (ASPNETROLESHTML role in roles) { HtmlRole single = new HtmlRole(); single.RoleId = role.ROLEID; single.ModuleId = role.MODULEID.Equals(DBNull.Value) ? 0 : moduleId; single.TabId = role.TABID.Equals(DBNull.Value) ? 0 : tabId; single.HtmlName = role.HTMLNAME; single.CSSClass = role.CSSCLASS == null ? "noclass": role.CSSCLASS; if (!role.ISVIEW.Equals(DBNull.Value)) { if (role.ISVIEW > 0) { single.IsView = true; } } if (!role.ISADD.Equals(DBNull.Value)) { if (role.ISADD > 0) { single.IsAdd = true; } } if (!role.ISEDIT.Equals(DBNull.Value)) { if (role.ISEDIT > 0) { single.IsEdit = true; } } if (!role.ISDELETE.Equals(DBNull.Value)) { if (role.ISDELETE > 0) { single.IsDelete = true; } } output.Add(single); } return(output); }
//convert HtmlRole kepada ASPNETROLESHTML //Update/Edit dalam Oracle DB public static int EditList(List <HtmlRoleWithTab> output, int tabId) { try { //sepatutnya output ni dapat 1 je sebab tabId ada 1 je utk setiap output output = output .Where(s => s.TabHeader.TabId == tabId).ToList(); //sebenarnya edit 1 je. 1 tab daripada semua tab yang tersenarai foreach (HtmlRoleWithTab single in output) { List <ASPNETROLESHTML> roles = new List <ASPNETROLESHTML>(); ASPNETROLESHTML tabHeader = new ASPNETROLESHTML(); tabHeader.ROLEID = single.TabHeader.RoleId; tabHeader.MODULEID = single.TabHeader.ModuleId; tabHeader.HTMLNAME = single.TabHeader.HtmlName; tabHeader.CSSCLASS = single.TabHeader.CSSClass; tabHeader.ISVIEW = single.TabHeader.IsView ? 1 : 0; tabHeader.ISADD = single.TabHeader.IsAdd ? 1 : 0; tabHeader.ISEDIT = single.TabHeader.IsEdit ? 1 : 0; tabHeader.ISDELETE = single.TabHeader.IsDelete ? 1 : 0; tabHeader.TABID = single.TabHeader.TabId; //add header to TOEDIT list; roles.Add(tabHeader); foreach (HtmlRole inSingle in single.HtmlRoles) { ASPNETROLESHTML role = new ASPNETROLESHTML(); role.ROLEID = inSingle.RoleId; role.MODULEID = inSingle.ModuleId; role.HTMLNAME = inSingle.HtmlName; role.CSSCLASS = inSingle.CSSClass; role.ISVIEW = inSingle.IsView ? 1 : 0; role.ISADD = inSingle.IsAdd ? 1 : 0; role.ISEDIT = inSingle.IsEdit ? 1 : 0; role.ISDELETE = inSingle.IsDelete ? 1 : 0; role.TABID = inSingle.TabId; //add others to roles roles.Add(role); } //Edit all the htmlRoles ASPNETROLESHTML.EditList(roles); } return(0); } catch (Exception ex) { Debug.WriteLine(ex.ToString()); return(1); } }