public ActionResult Create(CreateOrEditProductViewModel model) { try { if (ModelState.IsValid) { Product product = new Product { Name = model.Name, Price = model.Price }; //_db.Products.Add(product); //_db.SaveChanges(); //return RedirectToAction("Index"); return Content(Boolean.TrueString); } //return View(category); //return PartialView("_Add", category); return Content("Please review your form."); } catch (Exception ex) { return Content("Error Occured!"); } }
public ActionResult Create() { //var categories = _db.Categories.ToList<Category>().PopulateDropdownList("CategoryId", "Name").ToList(); var categories = SelectListItemExtension.PopulateDropdownList(_db.Categories.ToList<Category>(), "CategoryId", "Name").ToList(); //ViewBag.CategoryId = new SelectList(_db.Categories, "CategoryId", "Name"); var model = new CreateOrEditProductViewModel() { ddlCategories = categories }; //return View(); //return PartialView("_Create"); //return View("_Create"); return View("_Create", model); }
public ActionResult NumberUI() { var categories = SelectListItemExtension.PopulateDropdownList(_db.Categories.ToList<Category>(), "CategoryId", "Name").ToList(); var model = new CreateOrEditProductViewModel() { ddlCategories = categories }; return View(model); }