public Instructor AddInstructor(Instructor instructor) { var result = _db.Instructors.Add(instructor); _db.SaveChanges(); return(result); }
public ActionResult Create([Bind(Include = "Id,type,duration,caloriesBurnt,startTime")] Workout workout) { if (Session["user"] == null) { return(Redirect("/")); } if (ModelState.IsValid) { db.Workouts.Add(workout); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(workout)); }
public User UnsubscribeUserFromClass(string userId, int classId) { var user = db.Users.Find(userId); if (user != null) { var tobedeleted = user.Classes.First(c => c.Id == classId); if (tobedeleted != null) { user.Classes.Remove(tobedeleted); db.Entry(user).State = EntityState.Modified; db.SaveChanges(); } } return(user); }
public ActionResult Create([Bind(Include = "Id,fName,lName,password")] User user) { if (Session["user"] == null) { return(Redirect("/")); } if (ModelState.IsValid) { db.Users.Add(user); db.SaveChanges(); Session["user"] = user; List <User> list = new List <User>(); list.Add(user); return(View("Index", list)); } return(View(user)); }
public virtual T Add(T t) { _context.Set <T>().Add(t); _context.SaveChanges(); return(t); }
public void Post([FromBody] Exercise exercise) { _db.Exercises.Add(exercise); _db.SaveChanges(); }
public void Complete() { _context.SaveChanges(); }