コード例 #1
0
 public static string DebugMessage(this Domain.Command.CommandResponse response)
 {
     if (VoatSettings.Instance.IsDevelopment)
     {
         if (response.Exception != null)
         {
             return(response.Exception.ToString());
         }
     }
     return(response.Message);
 }
コード例 #2
0
 protected override async Task <CommandResponse <Submission> > ExecuteStage(CommandStage stage, CommandResponse <Submission> previous)
 {
     switch (stage)
     {
     case CommandStage.OnValidation:
         if (_userSubmission.Content.Length > 10000)
         {
             return(CommandResponse.FromStatus <Submission>(null, Status.Invalid, "Content can not exceed 10,000 characters"));
         }
         break;
     }
     return(await base.ExecuteStage(stage, previous));
 }
コード例 #3
0
 protected override async Task <CommandResponse <Vote> > ExecuteStage(CommandStage stage, CommandResponse <Vote> previous)
 {
     switch (stage)
     {
     case CommandStage.OnExecuting:
         //perform validationn return non-success if not success
         break;
     }
     return(await base.ExecuteStage(stage, previous));
 }
コード例 #4
0
ファイル: Command.cs プロジェクト: asynchronizations/artifact
        //So any command can invoke the rules engine
        //protected RulesEngine.RulesEngine<VoatRuleContext> rulesEngine = VoatRulesEngine.Instance;

        protected CommandResponse Map(RulesEngine.RuleOutcome outcome)
        {
            return(CommandResponse.FromStatus(outcome.Message, Status.Denied, outcome.ToString()));
        }
コード例 #5
0
 public override Task <T> Execute()
 {
     _commands.Add(this);
     return(Task.FromResult((T)CommandResponse.FromStatus(Status.Queued)));
 }
コード例 #6
0
ファイル: Command.cs プロジェクト: asynchronizations/artifact
 protected CommandResponse <T> Map <T>(RulesEngine.RuleOutcome outcome)
 {
     return(CommandResponse.FromStatus(default(T), Status.Denied, outcome.Message));
 }
コード例 #7
0
 public static CommandResponse <M> Map <T, M>(CommandResponse <T> response, M mapped)
 {
     return(new CommandResponse <M>(mapped, response.Status, response.Message));
 }
コード例 #8
0
 protected override async Task <CommandResponse <Models.Comment> > ExecuteStage(CommandStage stage, CommandResponse <Models.Comment> previous)
 {
     switch (stage)
     {
     case CommandStage.OnValidation:
         if (Content.Length > 10000)
         {
             return(CommandResponse.FromStatus <Models.Comment>(null, Status.Denied, "Comment can not exceed 10,000 characters"));
         }
         break;
     }
     return(CommandResponse.FromStatus <Models.Comment>(null, Status.Success));
 }
コード例 #9
0
        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));
        }
コード例 #10
0
 protected override async Task <CommandResponse <Submission> > ExecuteStage(CommandStage stage, CommandResponse <Submission> previous)
 {
     switch (stage)
     {
     case CommandStage.OnValidation:
         var results = ValidationHandler.Validate(_userSubmission);
         if (!results.IsNullOrEmpty())
         {
             return(CommandResponse.Invalid <Submission>(results));
         }
         break;
     }
     return(await base.ExecuteStage(stage, previous));
 }