예제 #1
0
        public IActionResult Delete(int?id)
        {
            if (id != null && this.bagService.BagExists(id))
            {
                EditBagModel editBagModel = this.bagService.GetBagCompleteEditInformation(id.Value);

                return(View(editBagModel));
            }

            return(BadRequest());
        }
예제 #2
0
        public IActionResult Edit(EditBagModel editBagModel)
        {
            if (this.ModelState.IsValid && this.bagService.BagExists(editBagModel.BagId))
            {
                this.bagService.EditBag(editBagModel);

                return(RedirectToAction("Index", "Home"));
            }

            return(View(editBagModel));
        }
예제 #3
0
        public void EditBag(EditBagModel editBagModel)
        {
            var bag = this.db.Bags.First(c => c.Id == editBagModel.BagId);

            bag.ImageUrl    = editBagModel.ImageUrl;
            bag.Color       = editBagModel.Color;
            bag.Description = editBagModel.Description;
            bag.Price       = editBagModel.Price;
            bag.Quantity    = editBagModel.Quantity;
            bag.Title       = editBagModel.Title;


            this.db.SaveChanges();
        }
예제 #4
0
        public EditBagModel GetBagCompleteEditInformation(int bagId)
        {
            var bag = this.db.Bags.First(c => c.Id == bagId);

            EditBagModel editBagModel = new EditBagModel()
            {
                BagId       = bag.Id,
                Description = bag.Description,
                Color       = bag.Color,
                ImageUrl    = bag.ImageUrl,
                Price       = bag.Price,
                Quantity    = bag.Quantity,
                Title       = bag.Title
            };

            return(editBagModel);
        }