Example #1
0
        public IActionResult Index(DiceIndexViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            Random rnd = new Random();

            model.Results = new List <int>();
            model.Total   = 0;

            for (int i = 0; i < model.DiceAmount; i++)
            {
                int roll = rnd.Next(1, model.DiceSize + 1);
                model.Results.Add(roll);
                model.Total += roll;
            }

            var addition = model.PlusMinusAmount;

            if (!model.Add)
            {
                addition *= -1;
            }

            model.Total += addition;
            return(View(model));
        }
Example #2
0
        public IActionResult Index()
        {
            var model = new DiceIndexViewModel()
            {
                DiceAmount      = 1,
                Add             = true,
                DiceSize        = 20,
                PlusMinusAmount = 0
            };

            return(View(model));
        }