/// <summary> /// Get proxy users. /// </summary> /// <param name="strUser">user name</param> /// <returns>Proxy VM></returns> public IMyProxyVM GetMyProxyVM(string strUser) { var proxyvmobject = _kernel.Get <IMyProxyVM>(); var myuserid = GetUserID(strUser).GetValueOrDefault(); proxyvmobject.MyDetails = GetUserInfo(myuserid); var proxy = this.dataContext.Poll_ProxyUser.FirstOrDefault(x => x.UserId == myuserid && x.IsEnabled == true); if ((proxy != null)) { proxyvmobject.isProxy = true; proxyvmobject.myProxy = GetUserInfo(proxy.ProxyUserId.GetValueOrDefault()); } else { proxyvmobject.isProxy = false; } var objUserDetails = (from UD in this.dataContext.UserDetails join U in this.dataContext.Users on UD.UserID equals U.UserID where UD.IsDeleted == false && U.IsEnabled == true && U.IsAllowedToVote == true && UD.isResigned == false select new { U.UserID, UD.LastName, UD.FirstName, U.Initial, UD.Title, UD.PartnerTypeID, UD.UserTypeID, UD.IsInternationalPartner, UD.OfficeLocation, UD.isResigned, UD.ResignationDate, UD.DateLeft, UD.EmailAddress }).OrderBy(x => x.FirstName).ToList(); if (objUserDetails != null) { foreach (var a in objUserDetails) { proxyDropDownListClass pdd = new proxyDropDownListClass() { usrid = a.UserID, usrname = a.FirstName + " " + a.LastName + " (" + a.Initial + ")" }; proxyvmobject.proxyDropDownlist.Add(pdd); } } return(proxyvmobject); }
/// <summary> /// Get assigned proxy /// </summary> /// <returns>Assign Proxy VM</returns> public IAssignProxyVM GetAssignProxyVM() { var objUserDetails = (from UD in this.dataContext.UserDetails join U in this.dataContext.Users on UD.UserID equals U.UserID where UD.IsDeleted == false && U.IsEnabled == true && U.IsAllowedToVote == true && UD.isResigned == false select new { U.UserID, UD.LastName, UD.FirstName, U.Initial, UD.Title, UD.PartnerTypeID, UD.UserTypeID, UD.IsInternationalPartner, UD.OfficeLocation, UD.isResigned, UD.ResignationDate, UD.DateLeft, UD.EmailAddress }).OrderBy(x => x.FirstName).ToList(); if (objUserDetails.Count > 0) { foreach (var a in objUserDetails) { IPersonnelForProxyVM po = new PersonnelForProxyVM(); po.UserID = a.UserID; po.Name = a.Title + ' ' + a.FirstName + ' ' + a.LastName; po.Initials = a.Initial; po.Office = a.OfficeLocation; po.Title = a.Title; int?proxyid = GetProxy(a.UserID); if (proxyid != null) { var proxydetails = (from UD in this.dataContext.UserDetails join U in this.dataContext.Users on UD.UserID equals U.UserID where UD.IsDeleted == false && U.UserID == proxyid && U.IsAllowedToVote == true select new { U.UserID, UD.LastName, UD.FirstName, U.Initial, UD.Title, UD.PartnerTypeID, UD.UserTypeID, UD.IsInternationalPartner, UD.OfficeLocation, UD.isResigned, UD.ResignationDate, UD.DateLeft, UD.EmailAddress }).OrderBy(x => x.FirstName).ToList(); if (proxydetails.Count > 0) { po.ProxyInitials = proxydetails[0].Initial; po.ProxyName = proxydetails[0].FirstName + " " + proxydetails[0].LastName + " (" + proxydetails[0].Initial + ")"; } } if (a.IsInternationalPartner == true) { po.International = "Y"; } else { po.International = "N"; } if (a.PartnerTypeID == 1) { po.Grade = "A"; } else if (a.PartnerTypeID == 2) { po.Grade = "B"; } else { po.Grade = "Admin"; } if (a.UserTypeID == 1) { po.AdminRights = "Y"; } else if (a.UserTypeID == 2) { po.AdminRights = "S"; } else { po.AdminRights = "N"; } proxyDropDownListClass pdd = new proxyDropDownListClass() { usrid = a.UserID, usrname = a.FirstName + " " + a.LastName + " (" + a.Initial + ")" }; this.assignProxyVM.proxyDropDownlist.Add(pdd); this.assignProxyVM.proxyPersonnelList.Add(po); } } return(this.assignProxyVM); }