public ActionResult Create(CategoryMaster categoryMaster) { if (ModelState.IsValid) { //Save Category shopDB.AddToCategoryMasters(categoryMaster); shopDB.SaveChanges(); return RedirectToAction("Index"); } // Invalid – redisplay with errors var category = new CategoryMaster(); return View(category); }
/// <summary> /// Create a new CategoryMaster object. /// </summary> /// <param name="categoryId">Initial value of the CategoryId property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="description">Initial value of the Description property.</param> public static CategoryMaster CreateCategoryMaster(global::System.Int32 categoryId, global::System.String name, global::System.String description) { CategoryMaster categoryMaster = new CategoryMaster(); categoryMaster.CategoryId = categoryId; categoryMaster.Name = name; categoryMaster.Description = description; return categoryMaster; }
/// <summary> /// Deprecated Method for adding a new object to the CategoryMasters EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToCategoryMasters(CategoryMaster categoryMaster) { base.AddObject("CategoryMasters", categoryMaster); }
// // GET: /CategoryManager/Create public ActionResult Create() { var category =new CategoryMaster(); return View(category); }