public async Task <IViewComponentResult> InvokeAsync(DomainReference domainReference, ContentReference contentReference = null) { IViewComponentResult result = View("Default", domainReference); if (domainReference != null) { switch (domainReference.Type) { case DomainType.Subverse: Subverse subverse = null; if (!String.IsNullOrEmpty(domainReference.Name)) { var q = new QuerySubverse(domainReference.Name); subverse = await q.ExecuteAsync(); } if (subverse != null) { var qa = new QueryActiveSessionCount(domainReference); ViewBag.OnlineUsers = await qa.ExecuteAsync(); var view = "Subverse"; // contentReference != null && contentReference.Type == ContentType.Submission ? "Submission" : "Subverse"; if (contentReference != null) { switch (contentReference.Type) { case ContentType.Vote: view = "VoteSubmission"; break; } } result = View(view, subverse); } else { result = View("Default"); } break; case DomainType.User: result = View("User", domainReference); break; case DomainType.Set: var qSet = new QuerySet(domainReference.Name, domainReference.OwnerName); var set = await qSet.ExecuteAsync(); result = View("Set", set); break; } } return(result); return(View("Chat", domainReference)); }
public async Task <ActionResult> Index(string name, string sort) { var domainReference = DomainReference.Parse(name, DomainType.Set); //var domainReference = new DomainReference(DomainType.Set, name, userName); var qSet = new QuerySet(domainReference.Name, domainReference.OwnerName); var set = await qSet.ExecuteAsync(); if (set == null) { return(ErrorView(new ErrorViewModel() { Title = "Can't find this set", Description = "Maybe it's gone?", Footer = "Probably yeah" })); } var perms = SetPermission.GetPermissions(set, User.Identity); if (!perms.View) { return(ErrorView(new ErrorViewModel() { Title = "Set is Private", Description = "This set doesn't allow viewing. It is private.", Footer = "Sometimes sets are shy around others." })); } var options = new SearchOptions(Request.QueryString.Value); //Set sort because it is part of path if (!String.IsNullOrEmpty(sort)) { options.Sort = (SortAlgorithm)Enum.Parse(typeof(SortAlgorithm), sort, true); } else { //Set Default Set to Relative if no sort is provided if (set.Name.IsEqual("Default") && String.IsNullOrEmpty(set.UserName)) { options.Sort = SortAlgorithm.Relative; } } //set span to day if not specified explicitly if (options.Sort == SortAlgorithm.Top && !Request.Query.ContainsKey("span")) { options.Span = SortSpan.Day; } var q = new QuerySubmissions(domainReference, options).SetUserContext(User); var result = await q.ExecuteAsync(); var model = new ListViewModel <Domain.Models.Submission>(); model.Items = new Utilities.PaginatedList <Domain.Models.Submission>(result, options.Page, options.Count); model.Items.RouteName = "SetIndex"; model.Context = domainReference; model.Sort = options.Sort;// == SortAlgorithm.RelativeRank ? SortAlgorithm.Hot :options.Sort; //UI doesn't want relative rank model.Span = options.Span; ViewBag.NavigationViewModel = new NavigationViewModel() { Description = "Set Description Here", Name = name, MenuType = MenuType.Set, BasePath = model.Context.BasePath(), Sort = model.Sort }; return(View(ViewPath(model.Context), model)); }