Exemple #1
0
        /****************Trip***********************/
        public static Trips TripToDB(CommonTrip commonTrip)
        {
            Trips trip = new Trips()
            {
                ClientId       = commonTrip.ClientId,
                BeginTime      = commonTrip.BeginTime,
                BookingStatus  = commonTrip.BookingStatus,
                Date           = commonTrip.Date,
                TotalTripHours = commonTrip.TotalTripHours,
                Polyline       = commonTrip.Polyline,
                LeavingAdrress = commonTrip.LeavingAdrress,
                NumOfPeople    = commonTrip.NumOfPeople,
                Cost           = commonTrip.Cost
            };

            trip.TripSite = new List <TripSite>();
            foreach (int siteId in commonTrip.TripSites)
            {
                TripSite tripSite = new TripSite()
                {
                    TripId = trip.TripId,
                    SiteId = siteId
                };
                trip.TripSite.Add(tripSite);
            }
            // trip.Clients = DataUser.GetUserById(commonTrip.ClientId);
            return(trip);
        }
Exemple #2
0
        //static dbEntities db = new dbEntities();
        public static Boolean AddTrip(CommonTrip trip)
        {
            dbEntities db      = new dbEntities();
            Trips      newTrip = Mapper.TripToDB(trip);

            //newTrip.Date.AddHours(3);
            try
            {
                db.Trips.Add(newTrip);
                db.Calendar.Add(new Calendar {
                    Date = trip.Date, DayStatus = "booked"
                });
                db.SaveChanges();
                return(true);
            }
            catch (DbEntityValidationException dbEx)
            {
                Debug.WriteLine(dbEx.Message);
            }
            return(false);
        }
Exemple #3
0
        public static CommonTrip TripToCommon(Trips trip)
        {
            CommonTrip commonTrip = new CommonTrip()
            {
                TripId         = trip.TripId,
                ClientId       = trip.ClientId,
                BeginTime      = trip.BeginTime,
                BookingStatus  = trip.BookingStatus,
                Date           = trip.Date,
                TotalTripHours = trip.TotalTripHours,
                Polyline       = trip.Polyline,
                LeavingAdrress = trip.LeavingAdrress,
                NumOfPeople    = trip.NumOfPeople,
                Cost           = trip.Cost
            };

            commonTrip.TripSites = new List <int>();
            foreach (TripSite ts in trip.TripSite)
            {
                commonTrip.TripSites.Add(ts.SiteId);
            }
            return(commonTrip);
        }