public ActionResult AddPoint(RaceModel race) { try { RaceModel newRace = MgtRace.GetInstance().GetRace(race.Id).ToModel(); newRace.Points = new List <PointModel>(); newRace.Distance = race.Distance; var check = Request.Form["checkbox"]; if (check == null) { race.point.isPoi = false; race.point.Category = null; } else { race.point.isPoi = true; } newRace.Points.Add(race.point); var result = MgtRace.GetInstance().UpdateRace(newRace.ToBo()); RaceModel reloadRace = MgtRace.GetInstance().GetRace(race.Id).ToModel(); if (result) { return(Json(reloadRace)); } else { return(RedirectToAction("Index")); } } catch (Exception e) { return(View()); } }
public ActionResult Create(RaceModel race) { try { JavaScriptSerializer js = new JavaScriptSerializer(); LatLng[] listePoints = js.Deserialize <LatLng[]>(race.AjaxPoints); bool valid = true; if (ModelState.IsValid) { //Ajout de la course race = MgtRace.GetInstance().AddRace(race.ToBo()).ToModel(); //Ajout des points for (int i = 0; i < listePoints.Length; i++) { Point point = new Point(); point.Titre = "Titre " + i; point.Latitude = listePoints[i].lat; point.Longitude = listePoints[i].lng; point.Ordre = i; // VALEUR HARCODE => //TODO: modify if (i == 0) { point.TypePointId = 1; } else if (i == listePoints.Length - 1) { point.TypePointId = 2; } else { point.TypePointId = 4; //Correspond au KM } point.CourseId = race.Id; valid = valid && MgtPoint.GetInstance().AddPoint(point); } if (valid) { return(RedirectToAction("Index")); } else { return(View()); } } else { return(View()); } } catch (Exception ex) { Console.WriteLine(ex); return(View()); } }
public ActionResult Edit(RaceModel race) { try { var result = MgtRace.GetInstance().UpdateRace(race.ToBo()); if (result) { return(RedirectToAction("Index")); } else { return(View()); } } catch { return(View()); } }
public ActionResult Edit(RaceModel race) { try { race.Points = new List <PointModel>(); race.Points.Add(race.point); var result = MgtRace.GetInstance().UpdateRace(race.ToBo()); if (result) { return(RedirectToAction("Index")); } else { return(View()); } } catch (Exception e) { return(View()); } }
// Le flag ci-dessus permet de préciser à l'action Create qu'il faut vérifier // si le token issu du cookie d'authentification a été bien été défini dans // la requête HTTP POST pour l'envoi du formulaire public ActionResult Create(RaceModel race) { try { if (MgtRace.GetInstance().AddRace(race.ToBo())) { PersonneModel user = (PersonneModel)Session.Contents["User"]; int lastId = MgtRace.GetInstance().GetAllItems().Max(x => x.Id); MgtRace.GetInstance().SuscribeRace(user.ToBo(), lastId); return(RedirectToAction("Edit", new { id = lastId })); } else { return(View()); } } catch (Exception e) { return(View()); } }
public ActionResult Create(RaceModel race) { try { // Met en évidence le ValidationSummary(false) dans la vue //ModelState.AddModelError(string.Empty, "Erreur visble via le ValidationSummary(true) mais pas par le ValidationSummary(false)"); if (ModelState.IsValid && serviceRace.AddRace(race.ToBo())) { //MgtRace.GetInstance() return(RedirectToAction("Index")); } else { return(View()); } } catch { return(View()); } }