コード例 #1
0
        public void UpdateByRouteAndApproachID(int routeID, int approachID, int newOrderNumber)
        {
            Models.ApproachRouteDetail RouteDetail = (from r in db.ApproachRouteDetails
                                                      where r.ApproachRouteId == routeID &&
                                                      r.ApproachID == approachID
                                                      select r).FirstOrDefault();
            if (RouteDetail != null)
            {
                Models.ApproachRouteDetail newRouteDetail = new Models.ApproachRouteDetail();
                newRouteDetail.ApproachOrder = newOrderNumber;

                try
                {
                    db.Entry(RouteDetail).CurrentValues.SetValues(newRouteDetail);
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    MOE.Common.Models.Repositories.IApplicationEventRepository repository =
                        MOE.Common.Models.Repositories.ApplicationEventRepositoryFactory.Create();
                    MOE.Common.Models.ApplicationEvent 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;
                }
            }
        }
コード例 #2
0
ファイル: Converter.cs プロジェクト: zfx1982/ATSPM
        public void ConvertApproachDetailDirections()
        {
            Console.WriteLine("Creating Approaches");
            List <MOE.Common.Models.ApproachRoute> ApproachRoutes = new List <Models.ApproachRoute>();

            foreach (var ApproachRouteRow in RouteTable)
            {
                MOE.Common.Models.ApproachRoute approachRoute = new Models.ApproachRoute();
                approachRoute.RouteName            = ApproachRouteRow.RouteName;
                approachRoute.ApproachRouteId      = ApproachRouteRow.ApproachRouteId;
                approachRoute.ApproachRouteDetails = new List <Models.ApproachRouteDetail>();
                ApproachRoutes.Add(approachRoute);
            }
            foreach (var DetailRow in RouteDetailTable)
            {
                var approachRoute = ApproachRoutes.Where(ar => ar.ApproachRouteId == DetailRow.ApproachRouteId).FirstOrDefault();
                var approach      = db.Approaches
                                    .Where(a => a.SignalID == DetailRow.SignalID && a.DirectionType.Description == DetailRow.Direction)
                                    .FirstOrDefault();
                if (approach != null)
                {
                    Models.ApproachRouteDetail ard = new Models.ApproachRouteDetail();
                    ard.ApproachOrder = DetailRow.ApproachOrder;
                    ard.ApproachID    = approach.ApproachID;
                    approachRoute.ApproachRouteDetails.Add(ard);
                }
            }
            db.ApproachRoutes.AddRange(ApproachRoutes);
            Console.WriteLine("Saving Approaches");
            db.SaveChanges();
        }
コード例 #3
0
 public void Add(Models.ApproachRouteDetail newRouteDetail)
 {
     try
     {
         db.ApproachRouteDetails.Add(newRouteDetail);
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         MOE.Common.Models.Repositories.IApplicationEventRepository repository =
             MOE.Common.Models.Repositories.ApplicationEventRepositoryFactory.Create();
         MOE.Common.Models.ApplicationEvent 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;
     }
 }