//GET: public IActionResult Edit(int id) { PrizeCreateEditViewModel viewModel = new PrizeCreateEditViewModel(_prizeDataAccessor.Get(id), _vendorDataAccessor.Get()); return(View("CreateEdit", viewModel)); }
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); }
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); }
public IActionResult Create() { PrizeCreateEditViewModel viewModel = new PrizeCreateEditViewModel(_vendorDataAccessor.Get()); return(View("CreateEdit", viewModel)); }