Exemplo n.º 1
0
        public static async Task <VoteAggregate> Load(int voteID)
        {
            var v    = new QueryVote(voteID);
            var vote = await v.ExecuteAsync();

            return(await Load(vote));
        }
        protected override async Task <CommandResponse <VoteTracker> > ExecuteStage(CommandStage stage, CommandResponse <VoteTracker> previous)
        {
            switch (stage)
            {
            case CommandStage.OnExecuting:

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

                var notPassed = vote.Restrictions.FirstOrDefault(x => {
                    var e = x.Evaluate(User);
                    return(!e.Success);
                });

                _restrictionsPassed = notPassed == null;

                break;

            case CommandStage.OnExecuted:

                if (previous.Success)
                {
                    CacheHandler.Instance.Remove(CachingKey.VoteStatistics(_voteID));
                }

                break;
            }
            return(await base.ExecuteStage(stage, previous));
        }
Exemplo n.º 3
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));
        }