public ActionResult Create([Bind(Include = "CourseID,Title,Credits")] Course course) { if (ModelState.IsValid) { db.Courses.Add(course); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(course)); }
public ActionResult Create([Bind(Include = "id,name")] Catalog catalog) { if (ModelState.IsValid) { db.Catalogs.Add(catalog); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(catalog)); }
public ActionResult Create([Bind(Include = "ID,LastName,FirstMidName,EnrollmentDate")] Student student) { if (ModelState.IsValid) { db.Students.Add(student); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(student)); }
public ActionResult Create([Bind(Include = "EnrollmentID,CourseID,StudentID,Grade")] Enrollment enrollment) { if (ModelState.IsValid) { db.Enrollments.Add(enrollment); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CourseID = new SelectList(db.Courses, "CourseID", "Title", enrollment.CourseID); ViewBag.StudentID = new SelectList(db.Students, "ID", "LastName", enrollment.StudentID); return(View(enrollment)); }
public ActionResult Create(CatalogModel catalogmodel) { if (ModelState.IsValid) { db.Catalogs.Add(catalogmodel); catalogmodel.CreateTime = DateTime.Now; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(catalogmodel)); }
public bool Create(Category item) { try { context.Categories.Add(item); context.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public bool Create(Product item) { try { context.Products.Add(item); context.SaveChanges(); return(true); } catch (Exception) { return(false); } }
private void AddCatalogItems(CatalogDBContext context) { var preconfiguredItems = _dataSettings.UseCustomizationData ? GetCatalogItemsFromFile(context) : PreconfiguredData.GetPreconfiguredCatalogItems(); foreach (var item in preconfiguredItems) { if (context.CatalogItems.FirstOrDefault(x => x.Name.Equals(item.Name)) == null) { item.Id = 0; context.CatalogItems.Add(item); } } context.SaveChanges(); }
private void AddCatalogBrands(CatalogDBContext context) { var preconfiguredBrands = _dataSettings.UseCustomizationData ? GetCatalogBrandsFromFile() : PreconfiguredData.GetPreconfiguredCatalogBrands(); foreach (var brand in preconfiguredBrands) { if (context.CatalogBrands.FirstOrDefault(x => x.Id.Equals(brand.Id)) == null) { brand.Id = brand.Id; context.CatalogBrands.Add(brand); } } context.SaveChanges(); }
private void AddCatalogTypes(CatalogDBContext context) { var preconfiguredTypes = _dataSettings.UseCustomizationData ? GetCatalogTypesFromFile() : PreconfiguredData.GetPreconfiguredCatalogTypes(); foreach (var type in preconfiguredTypes) { if (context.CatalogTypes.FirstOrDefault(x => x.Id.Equals(type.Id)) == null) { type.Id = type.Id; context.CatalogTypes.Add(type); } } context.SaveChanges(); }
public void CreateCatalogItem(CatalogItem catalogItem) { catalogItem.Id = indexGenerator.GetNextSequenceValue(db); db.CatalogItems.Add(catalogItem); db.SaveChanges(); }
public void CreateCatalogItem(CatalogItem catalogItem) { db.CatalogItems.Add(catalogItem); db.SaveChanges(); }
public bool SaveChanges() { return(context.SaveChanges() > 0); }