public ActionResult Vote(string tagIds, List <String> newTags, string raceId, string split) { ModelState.Clear(); //we must do this so that the input values can change on each partial view var race = db.Races.Find(raceId); if (race == null) { return(HttpNotFound()); } //create new tags, if any var newTagIds = SaveNewTags(newTags, split); // existing tags, we need to increment count var tagList = String.IsNullOrEmpty(tagIds) ? new List <int>() : tagIds.Split(',').Select(Int32.Parse).ToList(); tagList.AddRange(newTagIds); IncrementTagCount(race.Conditions, tagList); //setup for next partial view var viewModel = new RaceConditionsViewModel(); viewModel.Race = race; switch (split) { case "swim": //setup for bike: viewModel.Split = "bike"; viewModel.Tags = db.Tags.Where( t => t.Type == TagType.BikeLayout || t.Type == TagType.BikeMedium || t.Type == TagType.BikeWeather || t.Type == TagType.BikeOther ).ToList(); break; case "bike": //setup for run: viewModel.Split = "run"; viewModel.Tags = db.Tags.Where( t => t.Type == TagType.RunLayout || t.Type == TagType.RunMedium || t.Type == TagType.RunWeather || t.Type == TagType.RunOther ).ToList(); break; case "run": return(Json("<h3>Thank You for your contributions!</h3>")); } return(PartialView("_Splits", viewModel)); }
// GET: RaceConditions/Edit/5 NOTE, this is the raceId, not the conditionsId public ActionResult ShowRaceConditions(string id) { if (String.IsNullOrEmpty(id)) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var race = db.Races.Find(id); if (race == null) { return(HttpNotFound()); } var viewModel = new RaceConditionsViewModel(); viewModel.Race = race; viewModel.Tags = db.Tags.ToList(); return(PartialView("~/Views/Shared/_RaceConditions.cshtml", viewModel)); }
public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var race = db.Races.Find(id); if (race == null) { return(HttpNotFound()); } var viewModel = new RaceConditionsViewModel(); viewModel.Race = race; viewModel.Tags = db.Tags.ToList(); return(View(viewModel)); }
// GET: Races/Conditions/5 public ActionResult Conditions(string id) //this is the race id { if (String.IsNullOrEmpty(id)) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Race race = _DBContext.Races.Find(id); if (race == null) { return(HttpNotFound()); } var viewModel = new RaceConditionsViewModel(); viewModel.Race = race; viewModel.Tags = _DBContext.Tags.ToList(); return(View(viewModel)); }
// GET: RaceConditions/Create/5 NOTE, this is the raceId, not the conditionsId public ActionResult Create(string id /*raceid*/) { if (String.IsNullOrEmpty(id)) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var race = db.Races.Find(id); if (race == null) { return(HttpNotFound()); } var viewModel = new RaceConditionsViewModel(); viewModel.Race = race; viewModel.Split = "swim"; viewModel.Tags = db.Tags.Where( t => t.Type == TagType.SwimLayout || t.Type == TagType.SwimMedium || t.Type == TagType.SwimWeather || t.Type == TagType.SwimOther ).ToList(); return(View(viewModel)); }