public ActionResult Index()
        {
            var isRestricted = CurrentUser.IsRestricted(PortalRoleValues.AdvisorView);

            var groups = isRestricted ? GetAccessibleGroups() :  _groupService.GetGroups(new GroupRequest()).Groups.OrderBy(g => g.Name).ToList();

            ViewBag.IsRestricted   = isRestricted;
            ViewBag.DefaultGroupID = string.Empty;

            if (isRestricted)
            {
                groups.Insert(0, new Group()
                {
                    Name = "", GroupID = NoSelectedGroupId
                });
                ViewBag.DefaultGroupID = NoSelectedGroupId;
            }

            var viewModel = new AdvisorViewModel
            {
                Groups     = groups,
                Affiliates = _affiliateService.GetAffiliates(new AffiliateRequest())
            };

            return(View(viewModel));
        }
示例#2
0
        public IEnumerable <dynamic> GetAffiliates([FromUri] AffiliateRequest request)
        {
            request = request ?? new AffiliateRequest();

            return(_affiliateService.GetAffiliates(request).OrderBy(a => a.Name).Select(a => new
            {
                a.AffiliateID,
                a.Name,
                a.ExternalID,
                Phone = a.Phone.FormatAsPhoneNo(),
                a.WebsiteUrl,
                Address = a.Address.Replace(Environment.NewLine, "<br/>"),
                a.UserCount,
                a.ModifyDateUtc
            }));
        }
示例#3
0
        private List <Affiliate> GetAffiliates(bool includeAll = false)
        {
            var affiliates = _affiliateService.GetAffiliates(new AffiliateRequest {
                IncludeSamlConfiguration = true, UseCache = false, IncludeLogos = true
            });

            if (!includeAll)
            {
                affiliates = affiliates.Where(a => a.HasFeature(Features.LoginPage));
            }

            return(affiliates.ToList());
        }
示例#4
0
        private ReportViewModel ToReportViewModel(View view)
        {
            var viewModel = new ReportViewModel()
            {
                ReportID   = view.ViewID,
                FullName   = view.FullName,
                IsPageable = view.IsPageable,
                IsSortable = view.IsSortable,
                PageSize   = view.PageSize ?? 50,
                Columns    = view.ViewColumns.OrderBy(vc => vc.Ordinal).ToList()
            };

            foreach (var filter in view.Filters)
            {
                switch ((Model.Report.Filters)filter.FilterID)
                {
                case Model.Report.Filters.BrokerDealer:
                {
                    filter.Options = _affiliateService.GetAffiliates(new AffiliateRequest()).OrderBy(a => a.Name).Select(a => new FilterOption()
                        {
                            Name = a.Name, Value = a.AffiliateID.ToString()
                        }).ToList();
                    filter.Options.Insert(0, new FilterOption()
                        {
                            Value = string.Empty, Name = filter.Label
                        });
                    filter.DefaultValue = filter.Value = string.Empty;
                }
                break;

                case Model.Report.Filters.Year:
                {
                    const int startYear = 2014;

                    for (var year = startYear; year < DateTime.Now.Year + 5; year++)
                    {
                        filter.Options.Add(new FilterOption()
                            {
                                Name = year.ToString(), Value = year.ToString()
                            });
                    }

                    filter.DefaultValue = filter.Value = DateTime.Now.Year.ToString();
                    filter.Options.Insert(0, new FilterOption()
                        {
                            Value = string.Empty, Name = filter.Label
                        });
                }
                break;

                case Model.Report.Filters.Group:
                {
                    var isRestricted = CurrentUser.IsRestricted(PortalRoleValues.Reporting);
                    var groups       = isRestricted
                                            ? _groupService.GetAccessibleGroups(CurrentUser.UserID)
                                            : _groupService.GetGroups(new GroupRequest()).Groups;

                    filter.Options = groups.OrderBy(g => g.Name).Select(g => new FilterOption()
                        {
                            Name = g.Name, Value = g.GroupID.ToString()
                        }).ToList();

                    if (!isRestricted)
                    {
                        // Unrestricted Access so give them a blank option which in turn makes the group selection optional
                        filter.Options.Insert(0, new FilterOption()
                            {
                                Value = string.Empty, Name = filter.Label
                            });
                        filter.DefaultValue = filter.Value = string.Empty;
                    }
                    else
                    {
                        if (filter.Options.Any())
                        {
                            // Restricted access, default to all accessible group ids
                            var allGroupIdsList = filter.Options.ToCsv(o => o.Value);
                            filter.Options.Insert(0, new FilterOption()
                                {
                                    Value = allGroupIdsList, Name = filter.Label
                                });
                            filter.DefaultValue = filter.Value = allGroupIdsList;
                        }
                        else
                        {
                            // Restricted access and no groups, give them a default bogus option so no results will come back.
                            filter.Options.Insert(0, new FilterOption()
                                {
                                    Value = "-1", Name = filter.Label
                                });
                            filter.DefaultValue = filter.Value = filter.Options[0].Value;
                        }
                    }
                }
                break;

                case Model.Report.Filters.StartDate:
                {
                    filter.DefaultValue = filter.Value = DateTime.Today.AddYears(-1).ToString("MM/dd/yyyy");
                }
                break;

                case Model.Report.Filters.EndDate:
                {
                    filter.DefaultValue = filter.Value = DateTime.Today.ToString("MM/dd/yyyy");
                }
                break;

                case Model.Report.Filters.ExcludeAdvisorsWithNoData:
                {
                    filter.DefaultValue = filter.Value = true;
                }
                break;
                }

                viewModel.Filters.Add(filter);
            }

            return(viewModel);
        }