Exemplo n.º 1
0
        public DeletePurchaseViewModel GetDeletePurchaseViewModel(int?id)
        {
            Purchase purchase = this.Context.Purchases.Find(id);

            if (purchase == null)
            {
                return(null);
            }

            DeletePurchaseViewModel viewModel = Mapper.Map <Purchase, DeletePurchaseViewModel>(purchase);

            return(viewModel);
        }
        // GET: Admin/Purchases/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                throw new Exception("Invalid URL - promotion's id can not be null");
            }

            DeletePurchaseViewModel viewModel = this.purchaseService.GetDeletePurchaseViewModel(id);

            if (viewModel == null)
            {
                throw new Exception($"Invalid URL - there is no promotion with id {id}");
            }

            return(View(viewModel));
        }