public void Add(RouteSignal newRouteDetail) { try { if (!db.RouteSignals.Any(s => s.SignalId == newRouteDetail.SignalId && s.RouteId == newRouteDetail.RouteId)) { db.RouteSignals.Add(newRouteDetail); db.SaveChanges(); } } catch (Exception ex) { //var repository = // ApplicationEventRepositoryFactory.Create(); //var error = new ApplicationEvent(); //error.ApplicationName = "MOE.Common"; //error.Class = "Models.Repository.ApproachRouteDetailsRepository"; //error.Function = "UpdateByRouteAndApproachID"; //error.Description = ex.Message; //error.SeverityLevel = ApplicationEvent.SeverityLevels.High; //error.Timestamp = DateTime.Now; //repository.Add(error); //throw; } }
public void UpdateByRouteAndApproachID(int routeID, string signalId, int newOrderNumber) { var RouteDetail = (from r in db.RouteSignals where r.RouteId == routeID && r.SignalId == signalId select r).FirstOrDefault(); if (RouteDetail != null) { var newRouteDetail = new RouteSignal(); newRouteDetail.Order = newOrderNumber; try { db.Entry(RouteDetail).CurrentValues.SetValues(newRouteDetail); db.SaveChanges(); } catch (Exception ex) { //var repository = // ApplicationEventRepositoryFactory.Create(); //var error = new ApplicationEvent(); //error.ApplicationName = "MOE.Common"; //error.Class = "Models.Repository.ApproachRouteDetailsRepository"; //error.Function = "UpdateByRouteAndApproachID"; //error.Description = ex.Message; //error.SeverityLevel = ApplicationEvent.SeverityLevels.High; //error.Timestamp = DateTime.Now; //repository.Add(error); //throw; } } }
private static List <RoutePhaseDirection> CreateRoutePhaseDirections(RouteSignal signal, OldRouteDetail detail, Approach approach, SPM db) { List <RoutePhaseDirection> phaseDirecitons = new List <RoutePhaseDirection>(); RoutePhaseDirection phaseDireciton = new RoutePhaseDirection(); phaseDireciton.RouteSignal = signal; phaseDireciton.DirectionTypeId = approach.DirectionTypeID; phaseDireciton.Phase = approach.ProtectedPhaseNumber; phaseDireciton.IsOverlap = approach.IsProtectedPhaseOverlap; phaseDireciton.IsPrimaryApproach = true; phaseDirecitons.Add(phaseDireciton); return(phaseDirecitons); }
//// GET: RouteSignals/Details/5 //public ActionResult Details(int? id) //{ // if (id == null) // { // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); // } // RouteSignal routeSignal = db.RouteSignals.Find(id); // if (routeSignal == null) // { // return HttpNotFound(); // } // return View(routeSignal); //} //// GET: RouteSignals/Create //public ActionResult Create() //{ // ViewBag.RouteId = new SelectList(db.Routes, "Id", "RouteName"); // return View(); //} //// GET: RouteSignals/Edit/5 //public ActionResult Edit(int? id) //{ // if (id == null) // { // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); // } // RouteSignal routeSignal = db.RouteSignals.Find(id); // if (routeSignal == null) // { // return HttpNotFound(); // } // ViewBag.RouteId = new SelectList(db.Routes, "Id", "RouteName", routeSignal.RouteId); // return View(routeSignal); //} //// POST: RouteSignals/Edit/5 //// To protect from overposting attacks, please enable the specific properties you want to bind to, for //// more details see https://go.microsoft.com/fwlink/?LinkId=317598. //[HttpPost] //[ValidateAntiForgeryToken] //public ActionResult Edit([Bind(Include = "Id,RouteId,Order,SignalId")] RouteSignal routeSignal) //{ // if (ModelState.IsValid) // { // db.Entry(routeSignal).State = EntityState.Modified; // db.SaveChanges(); // return RedirectToAction("Index"); // } // ViewBag.RouteId = new SelectList(db.Routes, "Id", "RouteName", routeSignal.RouteId); // return View(routeSignal); //} // GET: RouteSignals/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var routeSignalRepository = MOE.Common.Models.Repositories.RouteSignalsRepositoryFactory.Create(); RouteSignal routeSignal = routeSignalRepository.GetByRouteSignalId(id.Value); if (routeSignal == null) { return(HttpNotFound()); } return(PartialView(routeSignal)); }
private static List <RouteSignal> CreateRouteSignals(OldRoute oldRoute, Route newRoute, SPM db) { List <RouteSignal> signals = new List <RouteSignal>(); IApproachRepository appRepo = ApproachRepositoryFactory.Create(db); foreach (var detail in oldRoute.Details) { var approach = appRepo.GetApproachByApproachID(detail.ApproachId); RouteSignal signal = new RouteSignal(); signal.Route = newRoute; signal.Order = detail.Order; signal.SignalId = approach.SignalID; signal.PhaseDirections = CreateRoutePhaseDirections(signal, detail, approach, db); signals.Add(signal); } return(signals); }
public ActionResult Create([Bind(Include = "RouteId,SignalId")] RouteSignal routeSignal) { MOE.Common.Models.Repositories.IRouteRepository routeRepository = MOE.Common.Models.Repositories.RouteRepositoryFactory.Create(); var route = routeRepository.GetRouteByID(routeSignal.RouteId); if (route.RouteSignals == null) { route.RouteSignals = new List <RouteSignal>(); } routeSignal.Order = route.RouteSignals.Count + 1; if (TryValidateModel(routeSignal)) { routeSignalsRepository.Add(routeSignal); } return(Content(routeSignal.Id.ToString())); }
public void Add(RouteSignal newRouteDetail) { throw new System.NotImplementedException(); }