public IActionResult Add(ShoeViewModel model) { var cookie = Request.Cookies["customerCookie"]; this.cartService.PostToCart(model.Id, cookie); return(RedirectToAction("Index", "Shoe")); }
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)); }
public IActionResult ShoeView() { var data = new ShoeViewModel { Shoe = _context.Shoe.ToList(), Registrant = _context.Registrant.ToList() }; return(View(data)); }
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); }
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(); }
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)); }
public async Task <IActionResult> Edit(ShoeViewModel shoeViewModel) { this.shoeService.Edit(shoeViewModel.Id, shoeViewModel.AmountInStore, shoeViewModel.Price, shoeViewModel.Type, shoeViewModel.Size); return(this.RedirectToAction("List")); }
public IActionResult UpdateShoeById(int id, [FromBody] ShoeViewModel shoe) { var updatedShoe = _shoesService.UpdateShoeById(id, shoe); return(Ok(updatedShoe)); }
public IActionResult AddShoe([FromBody] ShoeViewModel shoe) { _shoesService.AddShoe(shoe); return(Ok()); }