public ActionResult Create(SubCategoryMaster SubCategory) { if (ModelState.IsValid) { //Save Sub Category shopDB.AddToSubCategoryMasters(SubCategory); shopDB.SaveChanges(); return RedirectToAction("Index"); } // Invalid – redisplay with errors var viewModel = new SubCategoryManagerViewModel { SubCategory = new SubCategoryMaster(), Categories = shopDB.CategoryMasters.ToList() }; return View(viewModel); }
/// <summary> /// Deprecated Method for adding a new object to the SubCategoryMasters EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToSubCategoryMasters(SubCategoryMaster subCategoryMaster) { base.AddObject("SubCategoryMasters", subCategoryMaster); }
/// <summary> /// Create a new SubCategoryMaster object. /// </summary> /// <param name="subCategoryId">Initial value of the SubCategoryId property.</param> /// <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 SubCategoryMaster CreateSubCategoryMaster(global::System.Int32 subCategoryId, global::System.Int32 categoryId, global::System.String name, global::System.String description) { SubCategoryMaster subCategoryMaster = new SubCategoryMaster(); subCategoryMaster.SubCategoryId = subCategoryId; subCategoryMaster.CategoryId = categoryId; subCategoryMaster.Name = name; subCategoryMaster.Description = description; return subCategoryMaster; }