Exemplo n.º 1
0
        public async Task <ActionResult> View(string subverse, int id)
        {
            var agg = await VoteAggregate.Load(id);

            //var q = new QueryVote(id);
            //var vote = await q.ExecuteAsync();

            if (agg.Vote == null)
            {
                return(ErrorController.ErrorView(ErrorType.NotFound));
            }
            if (!agg.Vote.Subverse.IsEqual(subverse))
            {
                return(ErrorController.ErrorView(ErrorType.NotFound));
            }
            return(View("Index", agg));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Edit(string subverse, int id)
        {
            var q    = new QueryVote(id);
            var vote = await q.ExecuteAsync();

            if (vote == null)
            {
                return(ErrorController.ErrorView(ErrorType.NotFound));
            }

            if (!vote.CreatedBy.IsEqual(User.Identity.Name))
            {
                return(ErrorController.ErrorView(ErrorType.Unauthorized));
            }

            return(View(vote));
        }
Exemplo n.º 3
0
        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));
        }