Esempio n. 1
0
        public IActionResult Add(ShoeViewModel model)
        {
            var cookie = Request.Cookies["customerCookie"];

            this.cartService.PostToCart(model.Id, cookie);
            return(RedirectToAction("Index", "Shoe"));
        }
Esempio n. 2
0
        public async Task <ActionResult> Edit(int id)
        {
            var shoe = this.shoeService.GetById(id);

            var editShoeViewModel = new ShoeViewModel(shoe.Id, shoe.AmountInStore, shoe.IsOnSale, shoe.Price, shoe.IsNewRelease, shoe.ShoeType, shoe.Size);

            return(this.View(editShoeViewModel));
        }
Esempio n. 3
0
        public IActionResult ShoeView()
        {
            var data = new ShoeViewModel
            {
                Shoe       = _context.Shoe.ToList(),
                Registrant = _context.Registrant.ToList()
            };

            return(View(data));
        }
Esempio n. 4
0
        public Shoe UpdateShoeById(int shoeId, ShoeViewModel shoe)
        {
            var _shoe = _context.Shoes.FirstOrDefault(n => n.Id == shoeId);

            if (_shoe is null)
            {
                return(_shoe);
            }
            _shoe.Name      = shoe.Name;
            _shoe.Price     = shoe.Price;
            _shoe.IsOnSale  = false;
            _shoe.SalePrice = null;
            _shoe.BrandId   = shoe.BrandId;

            _context.SaveChanges();

            return(_shoe);
        }
Esempio n. 5
0
        public void AddShoe(ShoeViewModel shoe)
        {
            var _shoe = new Shoe
            {
                Name        = shoe.Name,
                Price       = shoe.Price,
                BrandId     = shoe.BrandId,
                IsOnSale    = false,
                SalePrice   = null,
                Description = shoe.Description,
                PictureUrl  = shoe.PictureUrl,

                Brand = _context.Brands.Where(n => n.Id == shoe.BrandId).Select(n => n.Name).FirstOrDefault()
            };

            _context.Shoes.Add(_shoe);
            _context.SaveChanges();
        }
Esempio n. 6
0
        public ActionResult Index(string name, int price, int brandId, string picture, string description)
        {
            var allShoesVm = new ShoeListViewModel
            {
                Shoes = _shoesService.GetAllShoes()
            };
            var allBrandsVM = _brandServices.GetAllBrands();

            dynamic myModel = new ExpandoObject();

            myModel.AllShoes = allShoesVm.Shoes;
            myModel.Brand    = allBrandsVM;

            try
            {
                if (ModelState.IsValid)
                {
                    var shoe = new ShoeViewModel()
                    {
                        Name        = name,
                        Price       = price,
                        BrandId     = brandId,
                        PictureUrl  = picture,
                        Description = description
                    };

                    if (!string.IsNullOrWhiteSpace(shoe.Description))
                    {
                        _shoesService.AddShoe(shoe);
                    }
                }
            }
            catch (Exception)
            {
                ViewBag.Error = "Some Error";
            }

            return(View("Index", myModel));
        }
Esempio n. 7
0
 public async Task <IActionResult> Edit(ShoeViewModel shoeViewModel)
 {
     this.shoeService.Edit(shoeViewModel.Id, shoeViewModel.AmountInStore, shoeViewModel.Price, shoeViewModel.Type, shoeViewModel.Size);
     return(this.RedirectToAction("List"));
 }
Esempio n. 8
0
        public IActionResult UpdateShoeById(int id, [FromBody] ShoeViewModel shoe)
        {
            var updatedShoe = _shoesService.UpdateShoeById(id, shoe);

            return(Ok(updatedShoe));
        }
Esempio n. 9
0
 public IActionResult AddShoe([FromBody] ShoeViewModel shoe)
 {
     _shoesService.AddShoe(shoe);
     return(Ok());
 }