public ActionResult Create([Bind(Include = "Id,Title,Excerpts,Content")] MTB_Articles mTB_Articles) { if (ModelState.IsValid) { db.MTB_Articles.Add(mTB_Articles); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(mTB_Articles)); }
public ActionResult Create([Bind(Include = "AthleteId,FirstName,LastName,Email")] Athlete athlete) { if (ModelState.IsValid) { db.Athletes.Add(athlete); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(athlete)); }
public ActionResult Create([Bind(Include = "WorkoutId,AthleteId,WorkoutType,WorkoutDate,WorkoutDistance,WorkoutHours,WorkoutMinutes,WorkoutSeconds,AverageHeartRate,PreviousNightSleepHours,PreviousNightSleepMinutes")] Workout workout, string workoutType) { if (ModelState.IsValid) { workout.WorkoutType = workoutType; db.Workouts.Add(workout); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(workout)); }
public ActionResult GetGameData() { if (!HttpContext.User.Identity.IsAuthenticated) { return(Json(new GameData() { Error = true }, JsonRequestBehavior.AllowGet)); } var countries = db.Countries .Include(country => country.cites) .ToList(); var userId = int.Parse(HttpContext.User.Identity.Name); var settings = db.UserSettings .FirstOrDefault(s => s.UserId == userId); if (settings == null) { settings = new UserSetting { Enlarg = true, Helper = true, Speech = true, UserId = userId }; db.UserSettings.Add(settings); db.SaveChanges(); } var level = db.UserLevels.FirstOrDefault(l => l.UserId == userId); //временно if (level == null) { level = new UserLevel { UserId = userId, Level = 3 }; db.UserLevels.Add(level); db.SaveChanges(); } //временно if (level.Level < 7) { RemoveCities(countries, level.Level); } return(Json(new GameData() { Countries = countries, Enlarg = settings.Enlarg, Helper = settings.Helper, Speech = settings.Speech }, JsonRequestBehavior.AllowGet)); }