public IActionResult AddBrand(Brand brand) { try { _brandServices.AddBrand(brand); return(CreatedAtAction("AddBrand", brand)); } catch (Exception) { return(BadRequest()); } }
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)); }
public IActionResult AddBrand([FromBody] BrandVm brand) { _brandService.AddBrand(brand); return(Ok()); }