コード例 #1
0
        public ActionResult Create(Course course)
        {
            if (ModelState.IsValid)
            {
                db.Courses.Add(course);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(course);
        }
コード例 #2
0
 private void AddMessage(Course course, string message)
 {
     User user =
            (from u in db.Users
             where u.userName == User.Identity.Name
             select u).SingleOrDefault();
     if (user != null && message != "")
     {
         ChatMessage newMessage = new ChatMessage();
         newMessage.PostTime = System.DateTime.Now;
         newMessage.UserName = user.userName;
         newMessage.Course = course;
         newMessage.Message = message;
         db.Messages.Add(newMessage);
         db.SaveChanges();
     }
 }
コード例 #3
0
 public ActionResult Edit(Course course)
 {
     if (ModelState.IsValid)
     {
         db.Entry(course).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(course);
 }