예제 #1
0
        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));
        }
예제 #2
0
        public ActionResult Create([Bind(Include = "id,name")] Catalog catalog)
        {
            if (ModelState.IsValid)
            {
                db.Catalogs.Add(catalog);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(catalog));
        }
예제 #3
0
        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));
        }
예제 #4
0
        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));
        }
예제 #5
0
        public ActionResult Create(CatalogModel catalogmodel)
        {
            if (ModelState.IsValid)
            {
                db.Catalogs.Add(catalogmodel);
                catalogmodel.CreateTime = DateTime.Now;
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            return(View(catalogmodel));
        }
예제 #6
0
        public bool Create(Category item)
        {
            try
            {
                context.Categories.Add(item);
                context.SaveChanges();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
예제 #7
0
        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();
        }
예제 #11
0
 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();
 }
예제 #13
0
 public bool SaveChanges()
 {
     return(context.SaveChanges() > 0);
 }