public EditPurchaseViewModel GetEditPurchaseViewModel(int?id) { Purchase purchase = this.Context.Purchases.Find(id); if (purchase == null) { return(null); } EditPurchaseViewModel viewModel = Mapper.Map <Purchase, EditPurchaseViewModel>(purchase); return(viewModel); }
// GET: Admin/Purchases/Edit/5 public ActionResult Edit(int?id) { if (id == null) { throw new Exception("Invalid URL - promotion's id can not be null"); } EditPurchaseViewModel viewModel = this.purchaseService.GetEditPurchaseViewModel(id); if (viewModel == null) { throw new Exception($"Invalid URL - there is no promotion with id {id}"); } return(View(viewModel)); }