예제 #1
0
        public bool addScheduledRoute(ScheduledRoute route)
        {
            if (this.routes.Contains(route))
            {
                return(false);
            }

            DateTime returnTime = route.getReturnTime();

            if (DateTime.Compare(route.depatureTime, beginDate ?? DateTime.Now) >= 0 &&
                DateTime.Compare(route.depatureTime, endDate ?? DateTime.Now) <= 0 &&
                DateTime.Compare(returnTime, endDate ?? DateTime.Now) <= 0)
            {
                DAL.ScheduleRoute entity = MainClass.Instance.db.ScheduleRoute.Where(v => v.routeId == route.id).FirstOrDefault();

                if (entity == null && (entity = route.saveInDB()) == null)
                {
                    return(false);
                }

                entity.shedule_plan_id = this.id;
                MainClass.Instance.db.SaveChanges();
                this.routes.Add(route);
                return(true);
            }
            return(false);
        }
예제 #2
0
 public GroupTrip(ScheduledRoute scheduledRoute, Ship ship)
 {
     this.route        = scheduledRoute ?? throw new ArgumentNullException(nameof(scheduledRoute));
     this.depatureTime = scheduledRoute.depatureTime;
     this.returnTime   = scheduledRoute.getReturnTime();
     this.tripType     = scheduledRoute.tripType;
     this.ship         = ship ?? throw new ArgumentNullException(nameof(ship));
 }