public ActionResult DeleteConfirmed(int id) { TrainingRide trainingRide = db.TrainingRides.Find(id); db.TrainingRides.Remove(trainingRide); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,Date,StartOdometer,EndOdometer,StartTime,EndTime,RideTimeHours,RideTimeMinutes,RideTimeSeconds,AverageHR,MaxHR,AverageCadence,ElevationGain,MaxSpeed,WindSpeed,WindDirection,Temperature,Precipitation,BikeId,RouteId,Notes")] TrainingRide trainingRide) { if (ModelState.IsValid) { db.Entry(trainingRide).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.BikeId = new SelectList(db.Bikes, "Id", "Name", trainingRide.BikeId); ViewBag.RouteId = new SelectList(db.Routes, "Id", "Name", trainingRide.RouteId); return(View(trainingRide)); }
// GET: TrainingRides/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TrainingRide trainingRide = db.TrainingRides.Find(id); if (trainingRide == null) { return(HttpNotFound()); } return(View(trainingRide)); }
// GET: TrainingRides/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TrainingRide trainingRide = db.TrainingRides.Find(id); if (trainingRide == null) { return(HttpNotFound()); } ViewBag.BikeId = new SelectList(db.Bikes, "Id", "Name", trainingRide.BikeId); ViewBag.RouteId = new SelectList(db.Routes, "Id", "Name", trainingRide.RouteId); return(View(trainingRide)); }
public ActionResult Create([Bind(Include = "Id,Date,StartOdometer,EndOdometer,StartTime,EndTime,RideTimeHours,RideTimeMinutes,RideTimeSeconds,AverageHR,MaxHR,AverageCadence,ElevationGain,MaxSpeed,WindSpeed,WindDirection,Temperature,Precipitation,BikeId,RouteId,Notes")] TrainingRide trainingRide) { HttpRequestMessage request = new HttpRequestMessage(); MediaTypeFormatter[] formatter = new MediaTypeFormatter[] { new JsonMediaTypeFormatter() }; var content = new StringContent(trainingRide.ToString(), Encoding.UTF8, "application/json");//request.CreateContent<TrainingRide>(obj, MediaTypeHeaderValue.Parse("application/json"), formatter, new FormatterSelector()); HttpResponseMessage response = client.PostAsync(requestURI, content).Result; return(View(response.Content.ToString())); if (ModelState.IsValid) { db.TrainingRides.Add(trainingRide); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.BikeId = new SelectList(db.Bikes, "Id", "Name", trainingRide.BikeId); ViewBag.RouteId = new SelectList(db.Routes, "Id", "Name", trainingRide.RouteId); return(View(trainingRide)); }