Пример #1
0
        public IActionResult Create(PrizeCreateEditViewModel model)
        {
            IActionResult result;

            if (ModelState.IsValid)
            {
                Prize prize = model.ToPrize();

                _prizeDataAccessor.Insert(prize);

                result = RedirectToAction("Index");
            }
            else
            {
                result = RedirectToAction("Create");
            }

            return(result);
        }
Пример #2
0
        public IActionResult Edit([FromRoute] int?id, PrizeCreateEditViewModel prizeModel)
        {
            IActionResult result;

            if (ModelState.IsValid && id.HasValue)
            {
                Prize prize = prizeModel.ToPrize();

                _prizeDataAccessor.Update(id.Value, prize);

                result = RedirectToAction("Index");
            }
            else
            {
                result = RedirectToAction("Create");
            }

            return(result);
        }