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> SubverseIndex(string subverse, MessageTypeFlag type, MessageState?state = null, int?page = null)
        {
            if (!(type == MessageTypeFlag.Private || type == MessageTypeFlag.Sent))
            {
                return(RedirectToAction("Index", "Home"));
            }
            if (string.IsNullOrEmpty(subverse))
            {
                return(RedirectToAction("Index", "Home"));
            }
            if (!ModeratorPermission.HasPermission(User, subverse, ModeratorAction.ReadMail))
            {
                return(RedirectToAction("Index", "Home"));
            }

            ViewBag.Context = new MessageContextViewModel()
            {
                ViewerContext = new UserDefinition()
                {
                    Name = subverse, Type = IdentityType.Subverse
                }
            };

            var qSub = new QuerySubverse(subverse);
            var sub  = await qSub.ExecuteAsync();

            if (sub == null)
            {
                return(ErrorView(ErrorViewModel.GetErrorViewModel(ErrorType.SubverseNotFound)));
            }
            //ViewBag.PmView = "mod";
            //ViewBag.Title = string.Format("v/{0} {1}", sub.Name, (type == MessageTypeFlag.Sent ? "Sent" : "Inbox"));

            var q = new QueryMessages(sub.Name, IdentityType.Subverse, type, MessageState.All, false).SetUserContext(User);

            q.PageNumber = SetPage(page);
            var result = await q.ExecuteAsync();

            var pagedList = new PaginatedList <Message>(result, q.PageNumber, q.PageCount);

            //TODO: This needs to be the Smail Menu, right now it shows user menu
            var name = type == MessageTypeFlag.Sent ? "Sent" : "Inbox";

            ViewBag.Title = name;
            SetMenuNavigationModel(name, MenuType.Smail, subverse);

            return(View("Index", pagedList));
        }
Esempio n. 3
0
        public async Task <ActionResult> Submit(string selectedsubverse)
        {
            ViewBag.selectedSubverse = selectedsubverse;
            //CORE_PORT: Ported correctly?
            //string linkPost = Request.Params["linkpost"];
            //string title = Request.Params["title"];
            string linkPost = Request.Query["linkpost"];
            string title    = Request.Query["title"];
            string url      = Request.Query["url"];

            CreateSubmissionViewModel model = new CreateSubmissionViewModel();

            model.Title = title;

            if (linkPost != null && linkPost == "true")
            {
                model.Type = Domain.Models.SubmissionType.Link;
                model.Url  = url;
            }
            else
            {
                model.Type = Domain.Models.SubmissionType.Text;
                model.Url  = "https://voat.co"; //dummy for validation (Do not look at me like that)
            }

            if (!String.IsNullOrWhiteSpace(selectedsubverse))
            {
                var q        = new QuerySubverse(selectedsubverse);
                var subverse = await q.ExecuteAsync();

                if (subverse != null)
                {
                    model.Subverse        = subverse.Name;
                    model.IsAdult         = subverse.IsAdult;
                    model.IsAnonymized    = subverse.IsAnonymized.HasValue ? subverse.IsAnonymized.Value : false;
                    model.AllowAnonymized = subverse.IsAnonymized == null || subverse.IsAnonymized.Value;
                }
            }

            var userData = UserData;

            model.RequireCaptcha = userData.Information.CommentPoints.Sum < VoatSettings.Instance.MinimumCommentPointsForCaptchaSubmission && VoatSettings.Instance.CaptchaEnabled;

            return(View(model));
        }
        public async Task <ActionResult> Create(string subverse)
        {
            if (!VotesEnabled)
            {
                return(ErrorView(ErrorViewModel.GetErrorViewModel(ErrorType.Unauthorized)));
            }

            var q   = new QuerySubverse(subverse);
            var sub = await q.ExecuteAsync();

            if (sub == null)
            {
                return(ErrorController.ErrorView(ErrorType.SubverseNotFound));
            }

            var model = new Vote();

            model.Subverse = sub.Name;

            return(View("Edit", model));
        }
Esempio n. 5
0
        public async Task <ActionResult> SubverseIndex(string subverse, MessageTypeFlag type, MessageState?state = null, int?page = null)
        {
            if (!(type == MessageTypeFlag.Private || type == MessageTypeFlag.Sent))
            {
                return(RedirectToAction("Index", "Home"));
            }
            if (string.IsNullOrEmpty(subverse))
            {
                return(RedirectToAction("Index", "Home"));
            }
            if (!ModeratorPermission.HasPermission(User.Identity.Name, subverse, ModeratorAction.ReadMail))
            {
                return(RedirectToAction("Index", "Home"));
            }

            ViewBag.Context = new MessageContextViewModel()
            {
                ViewerContext = new UserDefinition()
                {
                    Name = subverse, Type = IdentityType.Subverse
                }
            };

            var qSub = new QuerySubverse(subverse);
            var sub  = await qSub.ExecuteAsync();

            ViewBag.PmView = "mod";
            ViewBag.Title  = string.Format("v/{0} {1}", sub.Name, (type == MessageTypeFlag.Sent ? "Sent" : "Inbox"));

            var q = new QueryMessages(sub.Name, IdentityType.Subverse, type, MessageState.All, false);

            q.PageNumber = SetPage(page);
            var result = await q.ExecuteAsync();

            var pagedList = FakePaging(result, q.PageNumber, q.PageCount);

            return(View("Index", pagedList));
        }