public void Update(RoutePhaseDirection newRoutePhaseDirection) { CheckForExistingApproach(newRoutePhaseDirection); var routePhaseDirection = db.RoutePhaseDirections.Where(r => r.Id == newRoutePhaseDirection.Id).FirstOrDefault(); if (routePhaseDirection != null) { try { db.Entry(routePhaseDirection).CurrentValues.SetValues(newRoutePhaseDirection); db.SaveChanges(); } catch (Exception e) { var errorLog = ApplicationEventRepositoryFactory.Create(); errorLog.QuickAdd(Assembly.GetExecutingAssembly().GetName().ToString(), GetType().DisplayName(), e.TargetSite.ToString(), ApplicationEvent.SeverityLevels.High, e.Message); throw new Exception(""); } } else { Add(newRoutePhaseDirection); } }
public void UpdateApproach(RoutePhaseDirection routePhaseDirection) { if (ModelState.IsValid) { var routePhaseDirectionRepository = MOE.Common.Models.Repositories.RoutePhaseDirectionRepositoryFactory.Create(); routePhaseDirectionRepository.Update(routePhaseDirection); } }
private void CheckForExistingApproach(RoutePhaseDirection newRoutePhaseDirection) { var routePhaseDirection = db.RoutePhaseDirections.Where(r => r.RouteSignalId == newRoutePhaseDirection.RouteSignalId && r.IsPrimaryApproach == newRoutePhaseDirection.IsPrimaryApproach).FirstOrDefault(); if (routePhaseDirection != null) { db.RoutePhaseDirections.Remove(routePhaseDirection); db.SaveChanges(); } }
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); }
public void Add(RoutePhaseDirection newRoutePhaseDirection) { try { db.RoutePhaseDirections.Add(newRoutePhaseDirection); db.SaveChanges(); } catch (Exception e) { var errorLog = ApplicationEventRepositoryFactory.Create(); errorLog.QuickAdd(Assembly.GetExecutingAssembly().GetName().ToString(), GetType().DisplayName(), e.TargetSite.ToString(), ApplicationEvent.SeverityLevels.High, e.Message); throw new Exception(""); } }
public void Update(RoutePhaseDirection routePhaseDirection) { throw new System.NotImplementedException(); }
public RoutePhaseDirection GetByID(int routeID) { RoutePhaseDirection pd = _db.RoutePhaseDirection.Find(r => r.Id == routeID); return(pd); }
public void Add(RoutePhaseDirection newRRoutePhaseDirection) { throw new System.NotImplementedException(); }