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); } }
public void UpdateRoutePoint(RoutePoint routePoint) { using (var db = new ServiceContext()) { db.Update(routePoint); db.SaveChanges(); } }
public int InsertRoutePoint(RoutePoint routePoint) { using (var db = new ServiceContext()) { db.Add(routePoint); db.SaveChanges(); return(routePoint.RoutePointId); } }
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(); } }