コード例 #1
0
        public void UpdateByID(int routeID, string newDescription)
        {
            Models.ApproachRoute route = (from r in db.ApproachRoutes
                                          where r.ApproachRouteId == routeID
                                          select r).FirstOrDefault();

            if (route != null)
            {
                Models.ApproachRoute newroute = new Models.ApproachRoute();

                newroute.ApproachRouteId = route.ApproachRouteId;
                newroute.RouteName       = newDescription;
                try
                {
                    db.Entry(route).CurrentValues.SetValues(newroute);
                    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.ApproachRouteRepository";
                    error.Function        = "UpdateByID";
                    error.Description     = ex.Message;
                    error.SeverityLevel   = ApplicationEvent.SeverityLevels.High;
                    error.Timestamp       = DateTime.Now;
                    repository.Add(error);
                    throw;
                }
            }
        }
コード例 #2
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;
                }
            }
        }
コード例 #3
0
        public void Update(Models.Detector detector)
        {
            Models.Detector g = (from r in db.Detectors
                                 where r.ID == detector.ID
                                 select r).FirstOrDefault();
            if (g != null)
            {
                foreach (int i in detector.DetectionTypeIDs)
                {
                    Models.DetectionType t = (from r in db.DetectionTypes
                                              where r.DetectionTypeID == i
                                              select r).FirstOrDefault();

                    detector.DetectionTypes.Add(t);
                }
                try
                {
                    db.Entry(g).CurrentValues.SetValues(detector);
                    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.DetectorRepository";
                    error.Function        = "Update";
                    error.Description     = ex.Message;
                    error.SeverityLevel   = ApplicationEvent.SeverityLevels.High;
                    error.Timestamp       = DateTime.Now;
                    repository.Add(error);
                    throw;
                }
            }
        }