예제 #1
0
        public ActionResult Finish()
        {
            ScenarioModel  scenario = this.TempData["Scenario"] != null ? (ScenarioModel)this.TempData["Scenario"] : null;
            List <Witness> witness  = this.TempData["Witness"] != null ? (List <Witness>) this.TempData["Witness"] : null;
            TheEndModel    theEnd   = new TheEndModel();

            try
            {
                theEnd = ChallengeSolverBusiness.GetInstance().FindWhoIsTheKiller(scenario, witness);
            }
            catch (Exception e)
            {
                Error("Assassino não encontrado!");
                return(View(theEnd));
            }

            if (theEnd == null || theEnd.Killers == null || theEnd.Killers.Count == 0)
            {
                Error("Assassino não encontrado!");
            }
            else
            {
                Success("Assassino(s) encontrado(s)!");
            }


            return(View(theEnd));
        }
예제 #2
0
        public ActionResult Init(HttpPostedFileBase fileData, HttpPostedFileBase fileWitness)
        {
            ScenarioModel  scenario = new ScenarioModel();
            List <Witness> witness  = new List <Witness>();

            if (fileData != null && fileData.ContentLength > 0)
            {
                scenario = ChallengeSolverBusiness.GetInstance().DeserializeJsonFileScenario(fileData.InputStream);
                this.TempData["Scenario"] = scenario;
            }
            else
            {
                Error("Arquivo de cenário inválido!");
                return(View(scenario));
            }

            if (fileWitness != null && fileWitness.ContentLength > 0)
            {
                witness = ChallengeSolverBusiness.GetInstance().DeserializeJsonFileWitness(fileWitness.InputStream, scenario);
                if (witness == null || witness.Count == 0)
                {
                    Error("Arquivo de vitímas inválido!");
                    return(View(scenario));
                }
                else
                {
                    scenario.Witness         = witness;
                    this.TempData["Witness"] = witness;
                }
            }
            else
            {
                Error("Arquivo de vitímas inválido!");
                return(View(scenario));
            }

            Success("Arquivo carregado com sucesso!");
            return(View(scenario));
        }