public static Approvers getApprovers(AP_Staff_Rmb rmb, DotNetNuke.Entities.Users.UserInfo authUser, DotNetNuke.Entities.Users.UserInfo authAuthUser) { StaffBroker.StaffBrokerDataContext dStaff = new StaffBroker.StaffBrokerDataContext(); Approvers rtn = new Approvers(); var st = StaffBrokerFunctions.GetStaffMember(rmb.UserId); rtn.Name = st.DisplayName; int SpouseId = StaffBrokerFunctions.GetSpouseId(rmb.UserId); rtn.AmountSpecial = (from c in rmb.AP_Staff_RmbLines where c.LargeTransaction == true select c).Count() > 0; rtn.isDept = (rmb.CostCenter != st.CostCenter); rtn.SpouseSpecial = false; rtn.UserIds = new List<DotNetNuke.Entities.Users.UserInfo>(); if (rtn.isDept) { var cc = from c in dStaff.AP_StaffBroker_Departments where (c.CostCentre == rmb.CostCenter) && c.PortalId == rmb.PortalId select c; rtn.CCMSpecial = (from c in cc where ((c.CostCentreManager == null && c.CostCentreDelegate == null) == false) && ( ((c.CostCentreManager != rmb.UserId) && (c.CostCentreManager != SpouseId)) || ((c.CostCentreDelegate != rmb.UserId) && (c.CostCentreDelegate != SpouseId)) ) select c.CostCenterId).Count() == 0; if(rtn.CCMSpecial && !(cc.First().CostCentreManager==null && cc.First().CostCentreDelegate==null)) { //Try to add the CCM's own Team Leader instead of auth User var app2 = StaffBrokerFunctions.GetLeaders(rmb.UserId, true); foreach (int i in (from c in app2 where c != rmb.UserId && c != SpouseId select c)) rtn.UserIds.Add(DotNetNuke.Entities.Users.UserController.GetUserById(rmb.PortalId, i)); } if ((rtn.CCMSpecial && rtn.UserIds.Count()==0 )|| rtn.AmountSpecial || rtn.SpouseSpecial) { rtn.UserIds.Clear(); rtn.UserIds.Add(authUser.UserID == rmb.UserId ? authAuthUser : authUser); if (cc.First().CostCentreManager == rtn.UserIds.First().UserID || cc.First().CostCentreDelegate == rtn.UserIds.First().UserID) { rtn.AmountSpecial = false; rtn.CCMSpecial = false; } } else { if (cc.First().CostCentreManager != rmb.UserId && cc.First().CostCentreManager != SpouseId && cc.First().CostCentreManager != null) rtn.UserIds.Add(DotNetNuke.Entities.Users.UserController.GetUserById(rmb.PortalId, (int)cc.First().CostCentreManager)); if (cc.First().CostCentreDelegate != rmb.UserId && cc.First().CostCentreDelegate != SpouseId && cc.First().CostCentreDelegate != null) rtn.UserIds.Add(DotNetNuke.Entities.Users.UserController.GetUserById(rmb.PortalId, (int)cc.First().CostCentreDelegate)); } if (cc.Count() > 0) rtn.Name = cc.First().Name; } else { rtn.CCMSpecial = false; var app2 = StaffBrokerFunctions.GetLeaders(rmb.UserId, true); rtn.SpouseSpecial = (app2.Count() == 1 && ((app2.First() == SpouseId) || (app2.First() == rmb.UserId))); if (rtn.AmountSpecial || rtn.SpouseSpecial || app2.Count() == 0) { rtn.UserIds.Add(authUser.UserID == rmb.UserId ? authAuthUser : authUser); if (app2.Contains(rtn.UserIds.First().UserID)) { rtn.AmountSpecial = false; } } else { foreach (int i in (from c in app2 where c != rmb.UserId && c != SpouseId select c)) rtn.UserIds.Add(DotNetNuke.Entities.Users.UserController.GetUserById(rmb.PortalId, i)); } } if(rtn.UserIds.Count()==0) rtn.UserIds.Add(authUser.UserID == rmb.UserId ? authAuthUser : authUser); return rtn; }
partial void UpdateAP_Staff_Rmb(AP_Staff_Rmb instance);
partial void DeleteAP_Staff_Rmb(AP_Staff_Rmb instance);
partial void InsertAP_Staff_Rmb(AP_Staff_Rmb instance);