Пример #1
0
        //GET:
        public IActionResult Edit(int id)
        {
            PrizeCreateEditViewModel viewModel = new PrizeCreateEditViewModel(_prizeDataAccessor.Get(id),
                                                                              _vendorDataAccessor.Get());

            return(View("CreateEdit", viewModel));
        }
Пример #2
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);
        }
Пример #3
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);
        }
Пример #4
0
        public IActionResult Create()
        {
            PrizeCreateEditViewModel viewModel = new PrizeCreateEditViewModel(_vendorDataAccessor.Get());

            return(View("CreateEdit", viewModel));
        }