public ODSerListResult GetListWithPaging(WCFAuthInfoVM entity_WCFAuthInfoVM, LUserOrgDetailsVM entity_SearchCriteria, int int_CurrentPage, int int_PageSize, string str_SortColumn, string str_SortDir, List <string> str_CustomFilter) { ODSerListResult ret = null; ret = _client.GetListWithPaging(entity_WCFAuthInfoVM, entity_SearchCriteria, int_CurrentPage, int_PageSize, str_SortColumn, str_SortDir, str_CustomFilter); return(ret); }
// GET: AccessControl/LUOrgDetailsManage public ActionResult Index(int page = 1, string sort = "", string sortDir = "") { //Message Box Title -- When Error occured, Message Box would be showed. string str_MsgBoxTitle = MultilingualHelper.GetStringFromResource(languageKey, "LUOrgDetailsManage"); //Define output variable(recordCount && entityList_Result) int recordCount = 0; LUserOrgDetailsVM selectionCriteria = new LUserOrgDetailsVM(); GetSelectionCriteriaFromViewData(ref selectionCriteria); List <LUserOrgDetailsVM> entityList_Result = new List <LUserOrgDetailsVM>(); //Define wcf output object; ODSerListResult entity_ODSerListResult = null; WebCommonHelper webCommonHelper = new WebCommonHelper(); webCommonHelper.CallWCFHelper(this, (entity_WCFAuthInfoVM) => { entity_ODSerListResult = orgDetailMgtHelper.Value.GetListWithPaging(entity_WCFAuthInfoVM, selectionCriteria, 1, PageSize, null, null, CustomFilter(selectionCriteria)); }); //Assign data to local variable if (entity_ODSerListResult != null) { recordCount = entity_ODSerListResult.Int_TotalRecordCount; entityList_Result = entity_ODSerListResult.EntityList_LUserOrgDetailsVM; } StorePageInfo(recordCount, page); StoreSelectionCriteria <LUserOrganizationVM>(null); //Pass Error To UI string strError = ""; if (entity_ODSerListResult != null && entity_ODSerListResult.StrList_Error.Count() > 0) { strError = string.Join("<br/>", entity_ODSerListResult.StrList_Error.ToArray()); } if (!string.IsNullOrWhiteSpace(strError)) { MsgInfo errorMsgInfo = new MsgInfo(); errorMsgInfo.MsgTitle = str_MsgBoxTitle; errorMsgInfo.MsgDesc = strError; errorMsgInfo.MsgType = MessageType.ValidationError; ViewBag.ActionMessage = errorMsgInfo; } return(View(entityList_Result)); }
public ODSerListResult GetListWithPaging(WCFAuthInfoVM entity_WCFAuthInfoVM, LUserOrgDetailsVM entity_SearchCriteria, int int_CurrentPage, int int_PageSize, string str_SortColumn, string str_SortDir, List <string> str_CustomFilter) { try { //Restore Server Session RetrieveServerSideSession(entity_WCFAuthInfoVM); bool ret_CheckPrivilege = false; List <string> strList_Error = new List <string>(); ODSerListResult returnResult = new ODSerListResult(); CoolPrivilegeControlContext dbContext = CoolPrivilegeControlContext.CreateContext(); OrgDRespository entityRepos_OrgD = new OrgDRespository(dbContext, entity_BaseSession.ID); #region [ Check Privilege ] ret_CheckPrivilege = CheckAccPrivilege(entity_BaseSession.ID, entity_WCFAuthInfoVM.RequestFunKey, entity_WCFAuthInfoVM.RequestFunTypeKey, ref strList_Error); #endregion bool allowEdit = entity_BaseSession.CheckAccessRight(entity_WCFAuthInfoVM.RequestFunKey, "Edit", "", null); bool allowDel = entity_BaseSession.CheckAccessRight(entity_WCFAuthInfoVM.RequestFunKey, "Delete", "", null); bool allowEdit_Role = entity_BaseSession.CheckAccessRight("LURoleManage", "Edit", "", null); bool allowDel_Role = entity_BaseSession.CheckAccessRight("LURoleManage", "Delete", "", null); returnResult.StrList_Error = strList_Error; returnResult.Int_TotalRecordCount = 0; returnResult.EntityList_LUserOrgDetailsVM = new List <LUserOrgDetailsVM>(); if (ret_CheckPrivilege) { int recordCount = 0; if (entity_SearchCriteria == null) { entity_SearchCriteria = new LUserOrgDetailsVM(); } if (!string.IsNullOrWhiteSpace(entity_SearchCriteria.OrgDetailsKey) && str_CustomFilter.Count == 0) { str_CustomFilter.Add(String.Format("{0}.StartsWith(\"{1}\")", "OD_Key", entity_SearchCriteria.OrgDetailsKey)); } LUOrgDetailsAccessPolicy lUOrgDetailsAccessPolicy = new LUOrgDetailsAccessPolicy(); Func <List <LUserOrgDetails>, List <LUserOrgDetails> > func_OtherFilter = (entityList_OrgDetails) => { List <LUserOrgDetails> ret = entityList_OrgDetails; if (entity_SearchCriteria.OrgDetailsType.HasValue) { if (entity_SearchCriteria.OrgDetailsType.Value == 1) { ret = ret.Where(current => current.OD_Type.HasValue && current.OD_Type.Value == 1).ToList(); } else if (entity_SearchCriteria.OrgDetailsType.Value == 2) { ret = ret.Where(current => current.OD_Type.HasValue && current.OD_Type.Value == 2).ToList(); if (!string.IsNullOrWhiteSpace(entity_SearchCriteria.SC_RoleName)) { List <LUserOrgDetailsVM> entityList_LoginUservm = lUOrgDetailsAccessPolicy.Get_OrgDetailsSettings_RoleName(dbContext, entity_SearchCriteria.SC_RoleName.ToString()); var IDList_LoginUserVM = entityList_LoginUservm.Select(current => current.ID).ToList(); ret = ret.Where(current => IDList_LoginUserVM.Contains(current.ID)).ToList(); } } } if (!string.IsNullOrWhiteSpace(entity_SearchCriteria.OrgDetailsKey)) { string str_OrganizationKey = entity_SearchCriteria.OrgDetailsKey.ToString(); ret = ret.Except(ret.Where(current => current.OD_Key.IndexOf(str_OrganizationKey) != 0)).ToList(); } return(ret); }; List <LUserOrgDetailsVM> vmList = entityRepos_OrgD.GetEntityListByPage(entity_SearchCriteria, int_CurrentPage, int_PageSize, str_SortColumn, str_SortDir, out recordCount, str_CustomFilter, func_OtherFilter, null, (entityList_VM) => { foreach (var item in entityList_VM) { if (item.OrgDetailsType == 2) { List <LUserRoleVM> entityList_RoleVM = lUOrgDetailsAccessPolicy.Get_RoleSettings_OrgDID(item.ID); foreach (var item_Role in entityList_RoleVM) { item_Role.AllowDel = allowDel_Role; item_Role.AllowEdit = allowEdit_Role; } item.EntityList_Role = entityList_RoleVM; item.OrgDetailsTypeName = MultilingualHelper.GetStringFromResource(languageKey, "AsRoleSetting"); } else if (item.OrgDetailsType == 1) { item.OrgDetailsTypeName = MultilingualHelper.GetStringFromResource(languageKey, "SpecificFunctions"); } item.AllowDel = allowDel; item.AllowEdit = allowEdit; } return(entityList_VM); }); returnResult.EntityList_LUserOrgDetailsVM = vmList; returnResult.Int_TotalRecordCount = recordCount; } return(returnResult); } catch (Exception ex) { throw new WebFaultException <WCFErrorContract>(new WCFErrorContract(ex), System.Net.HttpStatusCode.ExpectationFailed); } }