Пример #1
0
        public int InsertRouteMark(RouteMark routeMark)
        {
            using (var db = new ServiceContext())
            {
                if (routeMark.RouteSheet != null)
                {
                    RouteSheet routeSheet = db.RouteSheets.FirstOrDefault(x => x.Barcode == routeMark.RouteSheet.Barcode);
                    if (routeSheet != null)
                    {
                        routeMark.RouteSheetId = routeSheet.RouteSheetId;
                    }
                    else
                    {
                        db.Add(routeMark.RouteSheet);
                    }
                }

                if (routeMark.RoutePoint != null)
                {
                    RoutePoint routePoint = db.RoutePoints.FirstOrDefault(x => x.Name == routeMark.RoutePoint.Name);
                    if (routePoint != null)
                    {
                        routeMark.RoutePointId = routePoint.RoutePointId;
                    }
                    else
                    {
                        db.Add(routeMark.RoutePoint);
                    }
                }

                db.Add(routeMark);
                db.SaveChanges();
                return(routeMark.RouteMarkId);
            }
        }
Пример #2
0
 public void UpdateRoutePoint(RoutePoint routePoint)
 {
     using (var db = new ServiceContext())
     {
         db.Update(routePoint);
         db.SaveChanges();
     }
 }
Пример #3
0
 public int InsertRoutePoint(RoutePoint routePoint)
 {
     using (var db = new ServiceContext())
     {
         db.Add(routePoint);
         db.SaveChanges();
         return(routePoint.RoutePointId);
     }
 }
Пример #4
0
 public void DeleteRoutePoint(int routePointId)
 {
     using (var db = new ServiceContext())
     {
         RoutePoint routePoint = new RoutePoint {
             RoutePointId = routePointId
         };
         db.RoutePoints.Attach(routePoint);
         db.RoutePoints.Remove(routePoint);
         db.SaveChanges();
     }
 }