public ActionResult Create(Course course) { if (ModelState.IsValid) { db.Courses.Add(course); db.SaveChanges(); return RedirectToAction("Index"); } return View(course); }
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(); } }
public ActionResult Edit(Course course) { if (ModelState.IsValid) { db.Entry(course).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(course); }