public async Task <ActionResult> Delete(string name) { if (ModelState.IsValid) { //TODO: Implement Command/Query - Remove direct Repository access using (var repo = new Repository(User)) { var domainReference = DomainReference.Parse(name, DomainType.Set); var result = await repo.DeleteSet(domainReference); if (result.Success) { if (Request.IsAjaxRequest()) { return(JsonResult(result)); } else { return(new RedirectToRouteResult("UserSets", new RouteValueDictionary() { { "pathPrefix", "user" }, { "userName", User.Identity.Name } })); } } else { ModelState.AddModelError("", result.Message); } } } return(await Index(name, "")); }
public async Task <JsonResult> ListChange(string name, string subverse, Domain.Models.SubscriptionAction subscribeAction) { var domainReference = DomainReference.Parse(name, DomainType.Set); //Only user sets can be changed, thus userName never needs to be checked here. var cmd = new SetSubverseCommand(domainReference, subverse, subscribeAction).SetUserContext(User); var result = await cmd.Execute(); return(JsonResult(result)); }
public async Task <ActionResult> Sidebar(string name) { //TODO: Implement Command/Query - Remove direct Repository access using (var repo = new Repository(User)) { var domainReference = DomainReference.Parse(name, DomainType.Set); var set = repo.GetSet(domainReference.Name, domainReference.OwnerName); if (set != null) { return(PartialView("~/Views/Shared/Sidebars/_SidebarSet.cshtml", set)); } else { return(new EmptyResult()); } } }
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)); }
public async Task <ActionResult> Details(string name) { //TODO: Implement Command/Query - Remove direct Repository access using (var repo = new Repository(User)) { var domainReference = DomainReference.Parse(name, DomainType.Set); var set = repo.GetSet(domainReference.Name, domainReference.OwnerName); if (set == null) { //Since system sets are not created until needed we show a slightly better error message for front/blocked. if (name.IsEqual(SetType.Front.ToString())) { ViewBag.NavigationViewModel = new Models.ViewModels.NavigationViewModel() { Description = "Discover Search", Name = "No Idea", MenuType = Models.ViewModels.MenuType.Discovery, BasePath = VoatUrlFormatter.BasePath(domainReference), Sort = null }; return(ErrorView(new ErrorViewModel() { Title = "No Subscriptions!", Description = "You don't have any subscriptions so we have to show you this instead", Footer = "Subscribe to a subverse you silly goat" })); } else if (name.IsEqual(SetType.Blocked.ToString())) { ViewBag.NavigationViewModel = new Models.ViewModels.NavigationViewModel() { Description = "Discover Search", Name = "No Idea", MenuType = Models.ViewModels.MenuType.Discovery, BasePath = VoatUrlFormatter.BasePath(domainReference), Sort = null }; return(ErrorView(new ErrorViewModel() { Title = "No Blocked Subs!", Description = "You don't have any blocked subs. Golf clap.", Footer = "Block some subs and this page will magically change!" })); } else { return(ErrorView(new ErrorViewModel() { Title = "Can't find this set", Description = "Maybe it's gone?", Footer = "Probably yeah" })); } } var perms = SetPermission.GetPermissions(set.Map(), User.Identity); if (!perms.View) { return(ErrorView(new ErrorViewModel() { Title = "Set is Private", Description = "This set doesn't allow the viewing of its properties", Footer = "It's ok, I can't see it either" })); } var options = new SearchOptions(Request.QueryString.Value); options.Count = 50; var setList = await repo.GetSetListDescription(set.ID, options.Page); var model = new SetViewModel(); model.Permissions = perms; model.Set = set.Map(); model.List = new PaginatedList <Domain.Models.SubverseSubscriptionDetail>(setList, options.Page, options.Count); model.List.RouteName = "SetDetails"; ViewBag.NavigationViewModel = new NavigationViewModel() { Name = domainReference.FullName, Description = set.Description, BasePath = VoatUrlFormatter.BasePath(domainReference), MenuType = (set.Type == (int)SetType.Front || set.Type == (int)SetType.Blocked ? MenuType.Discovery : MenuType.Set) }; return(View("Details", model)); } }