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 ActionResult AddBrandView(string name) { 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 brand = new BrandVm() { Name = name, }; if (!string.IsNullOrWhiteSpace(brand.Name)) { _brandServices.AddBrand(brand); } } } catch (Exception) { ViewBag.Error = "Some Error"; } return(View("Index", myModel)); }