Пример #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            TrainingRide trainingRide = db.TrainingRides.Find(id);

            db.TrainingRides.Remove(trainingRide);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #2
0
 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));
 }
Пример #3
0
        // 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));
        }
Пример #4
0
        // 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));
        }
Пример #5
0
        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));
        }