Exemple #1
0
        public ActionResult Index(GameParameters parameters)
        {
            var model = new IndexViewModel {
                Parameters = parameters
            };

            if (model.IsValid())
            {
                var game = new GameGenerator();
                var gameGeneratorParameters = MapGameParametersToGameGeneratorParameters(parameters);
                var cards = game.GetGameCards(gameGeneratorParameters);

                switch (parameters.SortBy)
                {
                case "Cost":
                    model.Cards = cards.OrderBy(x => x.Cost).ToList();
                    break;

                case "Name":
                    model.Cards = cards.OrderBy(x => x.Name).ToList();
                    break;

                case "Set":
                    model.Cards = cards.OrderBy(x => x.Set).ToList();
                    break;

                default:
                    model.Cards = cards.ToList();
                    break;
                }
            }
            return(View(model));
        }