コード例 #1
0
        public ActionResult Create([Bind(Include = "CourseID,Title,Credits")] Course course)
        {
            if (ModelState.IsValid)
            {
                db.Cources.Add(course);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(course));
        }
コード例 #2
0
        public ActionResult Create([Bind(Include = "TransactionID,PacketID,Routes,Date")] Transaction transaction)
        {
            if (ModelState.IsValid)
            {
                db.Transactions.Add(transaction);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(transaction));
        }
コード例 #3
0
        public Course CreateCourse(string title)
        {
            var newCourse = new Course {
                Title = title
            };

            using (SolutionAcceleratorContext context = new SolutionAcceleratorContext())
            {
                var createdCourse = context.Cources.Add(newCourse);
                context.SaveChanges();
                return(createdCourse);
            }
        }