public ActionResult Edit([Bind(Include = "ID,Logged,Level,Message,Username,RemoteAddress,Callsite,Exception")] Log log)
 {
     if (ModelState.IsValid)
     {
         db.Entry(log).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(log));
 }
示例#2
0
 public ActionResult Edit([Bind(Include = "ID,ShortName,LongName,Description,FlagStopsOnly")] Route route)
 {
     if (ModelState.IsValid)
     {
         db.Entry(route).State = EntityState.Modified;
         db.SaveChanges();
         logger.Info($"Updated route '{route.ShortName}' ({route.Description})");
         return(RedirectToAction("Index"));
     }
     return(View(route));
 }
示例#3
0
 public ActionResult Edit([Bind(Include = "ID,RouteID,StopID,StopSequence")] RouteStop routeStop)
 {
     if (ModelState.IsValid)
     {
         db.Entry(routeStop).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.RouteID = new SelectList(db.Routes, "ID", "ShortName", routeStop.RouteID);
     ViewBag.StopID  = new SelectList(db.Stops, "ID", "Name", routeStop.StopID);
     return(View(routeStop));
 }
示例#4
0
        public ActionResult Edit([Bind(Include = "ID,TrolleyName,Number,IconColorRGB,CurrentLat,CurrentLon")] Trolley trolley)
        {
            if (ModelState.IsValid)
            {
                db.Entry(trolley).State = EntityState.Modified;
                db.SaveChanges();
                logger.Info($"Updated trolley # {trolley.Number} '{trolley.TrolleyName}'");

                return(RedirectToAction("Index"));
            }
            return(View(trolley));
        }
示例#5
0
 public ActionResult Edit([Bind(Include = "ID,UseSyncromatics")] AppSettings appSettings)
 {
     if (ModelState.IsValid)
     {
         using (var db = new TrolleyTrackerContext())
         {
             db.Entry(appSettings).State = EntityState.Modified;
             db.SaveChanges();
             AppSettingsInterface.UpdateSettings(appSettings);
             return(RedirectToAction("Index"));
         }
     }
     return(View(appSettings));
 }
示例#6
0
        public ActionResult Edit([Bind(Include = "ID,RouteID,DayOfWeek,StartTime,EndTime")] RouteSchedule routeSchedule)
        {
            if (ModelState.IsValid)
            {
                routeSchedule.StartTime       = ExtractTimeValue(routeSchedule.StartTime);
                routeSchedule.EndTime         = ExtractTimeValue(routeSchedule.EndTime);
                db.Entry(routeSchedule).State = EntityState.Modified;
                db.SaveChanges();

                routeSchedule.Route = db.Routes.Find(routeSchedule.RouteID);
                logger.Info($"Updated fixed route schedule for '{routeSchedule.Route.ShortName}' - '{BuildScheduleView.daysOfWeek[routeSchedule.DayOfWeek]}' {routeSchedule.StartTime.TimeOfDay}-{routeSchedule.EndTime.TimeOfDay} ");

                return(RedirectToAction("Index"));
            }
            ViewBag.RouteID = new SelectList(db.Routes, "ID", "ShortName", routeSchedule.RouteID);
            return(View(routeSchedule));
        }
        public ActionResult Edit([Bind(Include = "ID,NewRouteID,OverrideDate,OverrideType,OverriddenRouteID,StartTime,EndTime")] RouteScheduleOverride routeScheduleOverride)
        {
            bool ok = true;

            if (routeScheduleOverride.OverrideType != RouteScheduleOverride.OverrideRule.NoService &&
                routeScheduleOverride.NewRouteID == -1)
            {
                ModelState.AddModelError("NewRouteID", "Added or Replacement route is required");
                ok = false;
            }

            if (routeScheduleOverride.StartTime > routeScheduleOverride.EndTime)
            {
                ModelState.AddModelError("StartTime", "Start time must be before end time");
                ok = false;
            }

            if (ok && ModelState.IsValid)
            {
                if (routeScheduleOverride.NewRouteID == -1)
                {
                    // Was cancellation case
                    routeScheduleOverride.NewRouteID = null;
                }
                if (routeScheduleOverride.OverriddenRouteID == -1)
                {
                    // No specific target route
                    routeScheduleOverride.OverriddenRouteID = null;
                }
                routeScheduleOverride.StartTime = ExtractTimeValue(routeScheduleOverride.StartTime);
                routeScheduleOverride.EndTime   = ExtractTimeValue(routeScheduleOverride.EndTime);

                using (var db = new TrolleyTrackerContext())
                {
                    db.Entry(routeScheduleOverride).State = EntityState.Modified;
                    db.SaveChanges();
                }

                logger.Info($"Edited special schedule type '{routeScheduleOverride.OverrideType.ToString()}' at  {routeScheduleOverride.OverrideDate} '{routeScheduleOverride.StartTime.TimeOfDay} - {routeScheduleOverride.EndTime.TimeOfDay}");

                return(RedirectToAction("Index"));
            }
            ViewBag.NewRouteID        = new SelectList(RouteSelectList(""), "ID", "ShortName", routeScheduleOverride.NewRouteID);
            ViewBag.OverriddenRouteID = new SelectList(RouteSelectList("** All **"), "ID", "ShortName", routeScheduleOverride.OverriddenRouteID);
            return(View(routeScheduleOverride));
        }