Ejemplo n.º 1
0
 public void SaveTrip(Trip trip)
 {
     if (trip.Id == 0)
     {
         Db.Trips.Add(trip);
     }
     else
     {
         Trip dbEntry = Db.Trips.Find(trip.Id);
         if (dbEntry != null)
         {
             dbEntry.ClientID = trip.ClientID;
             dbEntry.CountryID = trip.CountryID;
             dbEntry.DaysCount = trip.DaysCount;
             dbEntry.FlightID = trip.FlightID;
             dbEntry.HotelID = trip.HotelID;
             dbEntry.ResortID = trip.ResortID;
             dbEntry.Vehicle = trip.Vehicle;
             dbEntry.Client = trip.Client;
             dbEntry.Country = trip.Country;
             dbEntry.Flight = trip.Flight;
             dbEntry.Hotel = trip.Hotel;
             dbEntry.Resort = trip.Resort;
         }
     }
     Db.SaveChanges();
 }
Ejemplo n.º 2
0
        public ActionResult Trips_Create([DataSourceRequest]DataSourceRequest request, TripGridInputModel trip)
        {
            var newId = 0;
            if (this.ModelState.IsValid)
            {
                var from = this.locations.GetAll().FirstOrDefault(x => x.Name == trip.From);
                var to = this.locations.GetAll().FirstOrDefault(x => x.Name == trip.To);

                var entity = new Trip
                {
                    FromId = from.Id,
                    ToId = to.Id,
                    AvailableSeats = trip.AvailableSeats,
                    StartDate = trip.StartDate,
                    Description = trip.Description
                };

                this.trips.Create(entity);
                newId = entity.Id;
            }

            var tripToDisplay = this.trips
                .GetAll()
                .To<TripGridViewModel>()
                .FirstOrDefault(x => x.Id == newId);

            return this.Json(new[] { tripToDisplay }.ToDataSourceResult(request, this.ModelState));
        }
Ejemplo n.º 3
0
        public void given_trip_with_date_not_after_today_when_checking_is_valid_should_be_false()
        {
	        var results = new List<ValidationResult>();
            var trip = new Trip { Date = 23.November(1972) };
            trip.TryValidate(results).Should().BeFalse();
	        results.Should().NotBeEmpty();
        }
Ejemplo n.º 4
0
        public ActionResult Trips_Destroy([DataSourceRequest]DataSourceRequest request, Trip trip)
        {
            var tripToDelete = this.trips.GetByIntId(trip.Id);
            this.trips.Delete(tripToDelete);

            return this.Json(new[] { trip }.ToDataSourceResult(request, this.ModelState));
        }
Ejemplo n.º 5
0
        public ViewResult CreateTripAction(CreateTrip createTrip)
        {
            if (ModelState.IsValid)
            {
                Trip trip = new Trip
                {
                    Description = createTrip.Description,
                    Destination = createTrip.Destination,
                    StartDate = createTrip.Begin.Date.ToString(),
                    EndDate = createTrip.End.Date.ToString(),
                    MyName = createTrip.MyName
                };

                trip.TripUsers = new List<TripUser>();

                TripUser userMe = new TripUser
                {
                    DisplayName = createTrip.MyName,
                    Phone = createTrip.MyPhone
                };

                trip.TripUsers.Add(userMe);

                return View("InviteFriends", trip);
            }

            else
            {
                var errors = ModelState.Values.SelectMany(v => v.Errors);
                return View("CreateTrip", createTrip);
            }
        }
 /// <summary>
 /// Initializes a new instance of the TripViewModel class.
 /// </summary>
 public CurrentTripViewModel()
 {
     Trip trip = new Trip();
     trip.Name = "Australie en famille 2014";
     trip.BeginDate = DateTime.Now.AddDays(-20);
     trip.EndDate = DateTime.Now.AddDays(-12);
     CurrentTrip = trip;
 }
Ejemplo n.º 7
0
        public async Task EnsureSeedDataAsync()
        {
            if (await _userManager.FindByEmailAsync("*****@*****.**") == null)
            {
                //Add the user
                var newUser = new WorldUser()
                {
                    UserName = "******",
                    Email = "*****@*****.**"
                };

                await _userManager.CreateAsync(newUser, "abcd1234");
            }
            if (!_context.Trips.Any())
            {
                //Add New Data
                var usTrip = new Trip()
                {
                    Name = "US Trip",
                    Created = DateTime.UtcNow,
                    UserName = "******",
                    Stops = new List <Stop>()
                    {
                        new Stop() {Name = "Atlanta, GA", Arrival = new DateTime(2014, 5, 21), Latitude = 33.7550, Longitude = 84.3900, Order = 0},
                        new Stop() {Name = "Phoenix, AZ", Arrival = new DateTime(2014, 5, 25), Latitude = 33.4500, Longitude = 112.0667, Order = 1},
                        new Stop() {Name = "Los Angeles, CA", Arrival = new DateTime(2014, 6, 10), Latitude = 34.0500, Longitude = 118.2500, Order = 2},
                        new Stop() {Name = "Dallas, TX", Arrival = new DateTime(2014, 6, 25), Latitude = 32.7767, Longitude = 96.7970, Order = 3},
                        new Stop() {Name = "Atlanta, GA", Arrival = new DateTime(2014, 7, 3), Latitude = 33.7550, Longitude = 84.3900, Order = 4}

                    }

                };

                _context.Trips.Add(usTrip);
                _context.Stops.AddRange(usTrip.Stops);
                var worldTrip = new Trip()
                {
                    Name = "World Trip",
                    Created = DateTime.UtcNow,
                    UserName = "******",
                    Stops = new List<Stop>()
                    {
                        new Stop() {Name = "Country 1", Arrival = new DateTime(2015, 4, 21), Latitude = 33.7550, Longitude = 84.3900, Order = 0},
                        new Stop() {Name = "Country 2", Arrival = new DateTime(2015, 4, 25), Latitude = 33.4500, Longitude = 112.0667, Order = 1},
                        new Stop() {Name = "Country 3", Arrival = new DateTime(2015, 5, 10), Latitude = 34.0500, Longitude = 118.2500, Order = 2},
                        new Stop() {Name = "Country 4", Arrival = new DateTime(2015, 5, 25), Latitude = 32.7767, Longitude = 96.7970, Order = 3},
                        new Stop() {Name = "Country 5", Arrival = new DateTime(2015, 6, 3), Latitude = 33.7550, Longitude = 84.3900, Order = 4}
                    }

                };

                _context.Trips.Add(worldTrip);
                _context.Stops.AddRange(worldTrip.Stops);

                _context.SaveChanges();
            }
        }
Ejemplo n.º 8
0
        public void ShouldReturnTripsByLoggedUser()
        {
            var friend = new User ();
            var trip = new Trip ();
            userSession.Setup (x => x.GetLoggedUser()).Returns(friend);
            var user = new Mock<User>();
            user.Setup (x => x.GetFriends()).Returns (new List<User> {friend, friend});
            tripDao.Setup (x => x.FindTripsByUser (It.IsAny<User> ())).Returns (new List<Trip> { trip });

            var tripsOfFiends = tripService.GetTripsByUser (user.Object);

            Assert.AreEqual(1, tripsOfFiends.Count);
        }
Ejemplo n.º 9
0
 public ActionResult Create(Trip trip)
 {
     try
     {
         // TODO: Add insert logic here
         db.AddTrip(trip);
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }
Ejemplo n.º 10
0
 public void UpdateTrip(Trip trip)
 {
     var original = db.Trip.SingleOrDefault(m => m.IDTrip == trip.IDTrip);
     if (original != null) {
         original.Name = trip.Name;
         original.Includes = trip.Includes;
         original.Minimum = trip.Minimum;
         original.Operation = trip.Operation;
         original.PickupTime = trip.PickupTime;
         original.Price = trip.Price;
         db.SaveChanges();
     }
 }
Ejemplo n.º 11
0
        public ActionResult Create(Trip trip)
        {
            if (ModelState.IsValid)
            {
                trip.TripID = Guid.NewGuid();

                repository.Add(trip);
                repository.Commit();

                return RedirectToAction("Details",
                    new RouteValueDictionary(new { id = trip.TripID}));
            }

            return View(trip);
        }
Ejemplo n.º 12
0
        public ActionResult Index()
        {
            List<SelectListItem> items;
            lock (_sync)
            {
                items = _reportBuilder.GetReportWriters().
                    Select(writer => new SelectListItem { Text = writer.Key, Value = writer.Key }).ToList();
            }

            var model = new Trip()
            {
                FormatTypes = items
            };

            return View(model);
        }
Ejemplo n.º 13
0
        public void AddView(Trip trip, string ip)
        {
            bool userAlreadySeenThisTrip = trip.Views
                .Where(v => v.TripId == trip.Id && v.Ip == ip)
                .Any();

            if (!userAlreadySeenThisTrip)
            {
                View view = new View()
                {
                    TripId = trip.Id,
                    Ip = ip
                };

                this.viewRepos.Add(view);
                this.viewRepos.Save();
            }
        }
Ejemplo n.º 14
0
    public static void Main(string[] args)
    {
        string s;

        while ((s = Console.ReadLine()) != "-1")
        {
            string[] ss = s.Split(' ');
            Trip trip = new Trip(int.Parse(ss[0]));
            int m = int.Parse(ss[1]);

            while (m-- > 0)
            {
                string[] input = Console.ReadLine().Split(' ');

                trip.AddEdge(int.Parse(input[0]) - 1, int.Parse(input[1]) - 1, int.Parse(input[2]));
            }
            trip.Gao();
        }
    }
Ejemplo n.º 15
0
        public TripControllerTest()
        {
            userTrip = new Trip(loggedInUser.UserID);
            userTrip.current_weight = 10;
            userTrip.description = "My Trip";
            userTrip.destination = "Egypt";
            userTrip.total_capacity = 15;
            userTrip.weather = "Sunny";
            repository.Add(userTrip);

            notUserTrip = new Trip(Guid.NewGuid());
            notUserTrip.current_weight = 15;
            notUserTrip.description = "Trip 1";
            notUserTrip.destination = "Seattle";
            notUserTrip.total_capacity = 20;
            notUserTrip.weather = "Rainy";
            notUserRepository.Add(notUserTrip);

            provider = new MockAuthenticatedUserProvider(loggedInUser);
        }
Ejemplo n.º 16
0
        private static void InsertDestination()
        {
            var destination = new Destination
            {
                Country = "Indonesia",
                Description = "EcoTourism at its best in exquisite Bali",
                Name = "Bali is the new place to be"
            };

            var trip = new Trip
            {
                CostUSD = 800,
                StartDate = new DateTime(2011,9,1),
                EndDate = new DateTime(2011,9,14)
            };

            var person = new Person
            {
                FirstName = "Hugo",
                LastName = "Girard",
                SocialSecurityNumber = 12345678
            };

            using (var context = new BreakAwayContext())
            {
                context.Persons.Add(person);
                context.Trips.Add(trip);
                context.Destinations.Add(destination);
                context.SaveChanges();
            }

            using (var context = new BreakAwayContext())
            {
                // Here the update behind will add a where clause to the SocialSecurity number (page 50 book Code First)
                var people = context.Persons.FirstOrDefault();
                people.FirstName = "John";
                context.SaveChanges();
            }
        }
Ejemplo n.º 17
0
        public ActionResult CreateTrip(CreateTripViewModel tripToRegister)
        {
            if (!this.ModelState.IsValid)
            {
                return this.View(tripToRegister);
            }

            var locations = this.locations.GetAll().ToList();
            this.ViewBag.Locations = new SelectList(locations, "Id", "Name");

            var tripToCreate = new Trip()
            {
                Description = tripToRegister.Description,
                StartDate = tripToRegister.StartDate,
                AvailableSeats = tripToRegister.AvailableSeats,
                FromId = tripToRegister.From,
                ToId = tripToRegister.To,
                DriverId = this.User.Identity.GetUserId()
            };

            this.trips.Create(tripToCreate);

            return this.RedirectToAction("Index", "Home", new { area = string.Empty });
        }
Ejemplo n.º 18
0
        public void AddTripTrails(Trip trip)
        {
            if (_tripTrailLayer != null)
            {
                _map.Layers.Remove(_tripTrailLayer);
            }

            if (_tripInfoLayer != null)
            {
                _map.Layers.Remove(_tripInfoLayer);
            }

            Features trailFeatures = new Features();
            Features infoFeatures  = new Features();

            int          lastSpeedColorIndex = -1;
            Point        lastPoint           = null;
            List <Point> points = new List <Point>();

            double?firstLat = null;
            double?firstLon = null;

            foreach (Video video in trip.Videos)
            {
                foreach (KeyValuePair <int, TrailItem> kvp in video.TrailItems.ToList())
                {
                    var item = kvp.Value;

                    if (item.Longitude == 0 && item.Latitude == 0)
                    {
                        continue;
                    }

                    if (firstLat == null)
                    {
                        firstLat = item.Latitude;
                        firstLon = item.Longitude;
                    }

                    var location = SphericalMercator.FromLonLat(item.Longitude, item.Latitude);

                    if (lastPoint != null && location.Distance(lastPoint) < 35)
                    {
                        continue;
                    }

                    infoFeatures.Add(new Feature()
                    {
                        Geometry    = location,
                        ["Video"]   = video,
                        ["Seconds"] = kvp.Key
                    });

                    lastPoint = location;
                    int index = MapColors.GetStyleIndexFromSpeed(item.SpeedMph);

                    if (index != lastSpeedColorIndex)
                    {
                        if (lastSpeedColorIndex != -1)
                        {
                            points.Add(location);
                        }

                        if (points.Count > 0)
                        {
                            List <IStyle> styleList = new List <IStyle> {
                                MapColors.LineStyles[lastSpeedColorIndex]
                            };
                            trailFeatures.Add(new Feature()
                            {
                                Geometry = new LineString(points),
                                Styles   = styleList
                            });
                        }
                        points.Clear();
                    }

                    points.Add(location);
                    lastSpeedColorIndex = index;
                }
            }

            _tripTrailLayer = new MemoryLayer
            {
                DataSource = new MemoryProvider()
                {
                    Features = trailFeatures
                },
                Name  = "TripLayer",
                Style = null
            };

            _tripInfoLayer = new MemoryLayer
            {
                DataSource = new MemoryProvider()
                {
                    Features = infoFeatures
                },
                Name  = "MoviesLayer",
                Style = new SymbolStyle
                {
                    SymbolScale  = 0.5,
                    SymbolOffset = new Offset(0, 0),
                    SymbolType   = SymbolType.Ellipse,
                    //Line = new Pen(Color.Black, 2),
                    //Fill = new Brush(Color.White),
                    //Opacity = 0.1
                    Line    = new Pen(Color.White, 0),
                    Fill    = new Brush(Color.Transparent),
                    Opacity = 0.0
                }
            };

            _map.Layers.Insert(1, _tripTrailLayer);

            //_map.Layers.Insert(1, _tripInfoLayer);
            _map.InfoLayers.Add(_tripInfoLayer);

            if (_positionLayer != null)
            {
                MemoryProvider dataSource = ((MemoryProvider)((MemoryLayer)_positionLayer).DataSource);
                dataSource.Features.Clear();
            }

            if (firstLat != null && firstLon != null)
            {
                MoveToArea((double)firstLat, (double)firstLon, 0.001);
            }

            MapControl.RefreshData();
        }
 public void Remove(Trip trip)
 {
     _context.Trips.Remove(trip);
 }
Ejemplo n.º 20
0
 public async Task ChangeArrivalDateAsync(Trip trip, DateTime arrivalDate)
 {
     trip.ArriavalDate = arrivalDate;
     await tripRepository.UpdateAsync(trip);
 }
 public TripCategory(string name, Trip trip)
 {
     Name = name;
     Trip = trip;
 }
        private bool grdInputsDocuments_Restore()
        {
            RFMCursorWait.Set(true);
            RFMCursorWait.LockWindowUpdate(FindForm().Handle);

            oInputDocumentCur.ClearOne();

            oInputDocumentList.ClearError();
            oInputDocumentList.ClearFilters();
            oInputDocumentList.ID     = null;
            oInputDocumentList.IDList = null;

            // собираем условия

            // даты
            if (!dtrDates.dtpBegDate.IsEmpty)
            {
                oInputDocumentList.FilterDateBeg = dtrDates.dtpBegDate.Value.Date;
            }
            if (!dtrDates.dtpEndDate.IsEmpty)
            {
                oInputDocumentList.FilterDateEnd = dtrDates.dtpEndDate.Value.Date;
            }

            // доставка?
            if (optDeliveryNeed.Checked)
            {
                oInputDocumentList.FilterDeliveryNeed = true;
            }
            if (optDeliveryNeedNot.Checked)
            {
                oInputDocumentList.FilterDeliveryNeed = false;
            }

            // клиенты-поставщики
            if (txtPartnerSourceNameContext.Text.Trim().Length > 0)
            {
                Partner oPartnerSource = new Partner();
                oPartnerSource.FilterNameContext = txtPartnerSourceNameContext.Text.Trim();
                oPartnerSource.FillData();
                oInputDocumentList.FilterPartnersSourceList = "";
                foreach (DataRow rcs in oPartnerSource.MainTable.Rows)
                {
                    oInputDocumentList.FilterPartnersSourceList += rcs["ID"].ToString() + ",";
                }
            }
            if (ucSelectRecordID_PartnersSource.IsSelectedExist)
            {
                oInputDocumentList.FilterPartnersSourceList += ucSelectRecordID_PartnersSource.GetIdString();
            }

            // клиенты-получатели
            if (txtPartnerTargetNameContext.Text.Trim().Length > 0)
            {
                Partner oPartnerTarget = new Partner();
                oPartnerTarget.FilterNameContext = txtPartnerTargetNameContext.Text.Trim();
                oPartnerTarget.FillData();
                oInputDocumentList.FilterPartnersTargetList = "";
                foreach (DataRow rct in oPartnerTarget.MainTable.Rows)
                {
                    oInputDocumentList.FilterPartnersTargetList += rct["ID"].ToString() + ",";
                }
            }
            if (ucSelectRecordID_PartnersTarget.IsSelectedExist)
            {
                oInputDocumentList.FilterPartnersTargetList += ucSelectRecordID_PartnersTarget.GetIdString();
            }

            // владельцы
            if (ucSelectRecordID_Owners.IsSelectedExist)
            {
                oInputDocumentList.FilterOwnersList = ucSelectRecordID_Owners.GetIdString();
            }

            // рейс?
            if (optTripExists.Checked)
            {
                oInputDocumentList.FilterTripExists = true;
            }
            if (optTripExistsNot.Checked)
            {
                oInputDocumentList.FilterTripExists = false;
            }

            // выбранные товары
            if (sSelectedPackingsIDList.Length > 0)
            {
                oInputDocumentList.FilterPackingsList = sSelectedPackingsIDList;
            }

            // подтверждение
            if (optInputsDocumentsIsConfirmedNot.Checked)
            {
                oInputDocumentList.FilterIsConfirmed = false;
            }
            if (optInputsDocumentsIsConfirmed.Checked)
            {
                oInputDocumentList.FilterIsConfirmed = true;
            }

            // по рейсу
            string sTripsList = "";

            if (txtTripAliasContext.Text.Trim().Length > 0)
            {
                Trip oTripFilter = new Trip();
                oTripFilter.FilterAliasContext = txtTripAliasContext.Text.Trim();
                oTripFilter.FillData();
                if (oTripFilter.ErrorNumber == 0 && oTripFilter.MainTable != null)
                {
                    foreach (DataRow tr in oTripFilter.MainTable.Rows)
                    {
                        sTripsList += tr["ID"].ToString() + ",";
                    }
                }
                oInputDocumentList.FilterTripsList = sTripsList;
            }
            if (numTripID.Value > 0)
            {
                if (oInputDocumentList.FilterTripsList == null)
                {
                    oInputDocumentList.FilterTripsList = Convert.ToInt32(numTripID.Value).ToString();
                }
                else
                {
                    oInputDocumentList.FilterTripsList += Convert.ToInt32(numTripID.Value).ToString();
                }
            }

            // хосты
            if (nUserHostID.HasValue)
            {
                oInputDocumentList.FilterHostsList = nUserHostID.ToString();
            }
            else
            {
                if (ucSelectRecordID_Hosts.IsSelectedExist)
                {
                    oInputDocumentList.FilterHostsList = ucSelectRecordID_Hosts.GetIdString();
                }
            }

            // начальные условия
            if (oInputDocument != null)
            {
                if (oInputDocument.FilterOwnersList != null)
                {
                    oInputDocumentList.FilterOwnersList = oInputDocument.FilterOwnersList;
                }
                if (oInputDocument.FilterPartnersSourceList != null)
                {
                    oInputDocumentList.FilterPartnersSourceList = oInputDocument.FilterPartnersSourceList;
                }
                if (oInputDocument.FilterPartnersTargetList != null)
                {
                    oInputDocumentList.FilterPartnersTargetList = oInputDocument.FilterPartnersTargetList;
                }
                if (oInputDocument.FilterHostsList != null)
                {
                    if (!nUserHostID.HasValue)
                    {
                        oInputDocumentList.FilterHostsList = oInputDocument.FilterHostsList;
                    }
                    else
                    {
                        if (!((string)("," + oInputDocument.FilterHostsList + ",")).Contains("," + nUserHostID.ToString().Trim() + ","))
                        {
                            oInputDocumentList.FilterHostsList = "-1";
                        }
                    }
                }
            }
            //

            grdInputsDocumentsGoods.DataSource = null;

            grdInputsDocuments.GetGridState();

            oInputDocumentList.FillData();
            grdInputsDocuments.IsLockRowChanged = true;
            grdInputsDocuments.Restore(oInputDocumentList.MainTable);
            tmrRestore.Enabled = true;

            RFMCursorWait.LockWindowUpdate(IntPtr.Zero);
            RFMCursorWait.Set(false);

            return(oInputDocumentList.ErrorNumber == 0);
        }
Ejemplo n.º 23
0
 public void ChangeDepartureDate(Trip trip, DateTime departureDate)
 {
     trip.DepartureDate = departureDate;
     tripRepository.Update(trip);
 }
Ejemplo n.º 24
0
        //static void Main()
        //{

        //    var locationsLists = GetLocationsLists();

        //    using (var sr = new StreamReader("App_Data\\Geo-Routes.txt"))
        //    {
        //        var lines = sr.ReadToEnd();
        //        MapTools.routes = JsonConvert.DeserializeObject<Dictionary<string, Route>>(lines) ??
        //                          new Dictionary<string, Route>();
        //    }
        //    using (var sr = new StreamReader("App_Data\\Geo-Location-Names.txt"))
        //    {
        //        var lines = sr.ReadToEnd();
        //        MapTools.locationNames = JsonConvert.DeserializeObject<Dictionary<string, string>>(lines) ??
        //                                 new Dictionary<string, string>();
        //    }
        //    using (var sr = new StreamReader("App_Data\\Geo-Location-Addresses.txt"))
        //    {
        //        var lines = sr.ReadToEnd();
        //        MapTools.locationAddresses = JsonConvert.DeserializeObject<Dictionary<string, Pair<string, string>>>(lines) ??
        //                                     new Dictionary<string, Pair<string, string>>();
        //    }

        //    int tripCount = 0;
        //    foreach (LocationsList locationList in locationsLists)
        //        foreach (Location location in locationList.locations)
        //            foreach (Location l in locationList.locations.Where(l => !l.Equals(location)))
        //            {
        //                tripCount++;
        //                System.Threading.Thread.Sleep(2000);
        //                MapTools.GetRoute(location, l);
        //            }

        //    var routesString = JsonConvert.SerializeObject(MapTools.routes);
        //    var locationNamesString = JsonConvert.SerializeObject(MapTools.locationNames);
        //    var locationAddresses = JsonConvert.SerializeObject(MapTools.locationAddresses);

        //    File.WriteAllText("App_Data\\Geo-Routes.txt", String.Empty);
        //    using (var sr = new StreamWriter("App_Data\\Geo-Routes.txt"))
        //    {
        //        sr.Write(routesString);
        //    }
        //    File.WriteAllText("App_Data\\Geo-Location-Names.txt", String.Empty);
        //    using (var sr = new StreamWriter("App_Data\\Geo-Location-Names.txt"))
        //    {
        //        sr.Write(locationNamesString);
        //    }
        //    File.WriteAllText("App_Data\\Geo-Location-Addresses.txt", String.Empty);
        //    using (var sr = new StreamWriter("App_Data\\Geo-Location-Addresses.txt"))
        //    {
        //        sr.Write(locationAddresses);
        //    }


        //    Console.WriteLine(tripCount + " trips generated");
        //    Console.ReadKey();
        //}

        static void Main()
        {
            const string host             = "mongodb://SG-tripthru-3110.servers.mongodirector.com:27017/";
            const string database         = "TripThru";
            const string nameCollection   = "trips";
            const string pathTripData     = @"C:\Users\OscarErnesto\Downloads\tripData2013\trip_data_1.csv\trip_data_1.csv";
            const string pathTripFare     = @"C:\Users\OscarErnesto\Downloads\faredata2013\trip_fare_1.csv\trip_fare_1.csv";
            const string pathRandomsNames =
                @"C:\Users\OscarErnesto\Documents\Visual Studio 2013\Projects\Gateway\Db\FakeName.csv";

            MongoDB.Bson.Serialization.BsonClassMap.RegisterClassMap <Trip>(cm =>
            {
                cm.AutoMap();
                foreach (var mm in cm.AllMemberMaps)
                {
                    mm.SetIgnoreIfNull(true);
                }
                cm.GetMemberMap(c => c.Status).SetRepresentation(BsonType.String);
                cm.GetMemberMap(c => c.PickupTime).SetIgnoreIfNull(true);
                cm.GetMemberMap(c => c.PickupLocation).SetIgnoreIfNull(true);
                cm.GetMemberMap(c => c.FleetId).SetIgnoreIfNull(true);
                cm.GetMemberMap(c => c.FleetName).SetIgnoreIfNull(true);
                cm.GetMemberMap(c => c.ETA).SetIgnoreIfNull(true);
                cm.GetMemberMap(c => c.DropoffLocation).SetIgnoreIfNull(true);
                cm.GetMemberMap(c => c.DropoffTime).SetIgnoreIfNull(true);
                cm.GetMemberMap(c => c.DriverRouteDuration).SetIgnoreIfNull(true);
                cm.GetMemberMap(c => c.DriverId).SetIgnoreIfNull(true);
                cm.GetMemberMap(c => c.OccupiedDistance).SetIgnoreIfNull(true);
                cm.GetMemberMap(c => c.DriverName).SetIgnoreIfNull(true);
                cm.GetMemberMap(c => c.Price).SetIgnoreIfNull(true);
                cm.GetMemberMap(c => c.ServicingPartnerName).SetIgnoreIfNull(true);
                cm.GetMemberMap(c => c.ServicingPartnerId).SetIgnoreIfNull(true);
                cm.GetMemberMap(c => c.VehicleType).SetIgnoreIfNull(true);
                cm.GetMemberMap(c => c.DriverLocation).SetIgnoreIfNull(true);
                cm.GetMemberMap(c => c.DriverInitiaLocation).SetIgnoreIfNull(true);
                cm.GetMemberMap(c => c.LastUpdate).SetIgnoreIfNull(true);
                cm.GetMemberMap(c => c.loc);
            });

            MongoCollection <Trip> trips;
            var server        = MongoServer.Create(host);
            var tripsDatabase = server.GetDatabase(database);

            trips = tripsDatabase.GetCollection <Trip>(nameCollection);
            var tripReader  = new StreamReader(File.OpenRead(pathTripData));
            var fareReader  = new StreamReader(File.OpenRead(pathTripFare));
            var namesReader = new StreamReader(File.OpenRead(pathRandomsNames));

            var r = new Random(DateTime.Now.Millisecond);

            var listNames          = new Dictionary <string, string>();
            var listPassengerNames = new Dictionary <string, string>();

            var countLines = 1;

            namesReader.ReadLine();
            tripReader.ReadLine();
            fareReader.ReadLine();
            int re = 0;

            while (re < 1000)
            {
                tripReader.ReadLine();
                fareReader.ReadLine();
                re++;
            }

            while (countLines <= 5000)
            {
                var trip     = new Trip();
                var tripLine = tripReader.ReadLine();
                var fareLine = fareReader.ReadLine();
                if (tripLine == null)
                {
                    continue;
                }
                var tripValues = tripLine.Split(',');
                if (fareLine == null)
                {
                    continue;
                }
                var fareValues = fareLine.Split(',');

                if (!listNames.ContainsKey(tripValues[0]))
                {
                    var identity = namesReader.ReadLine();
                    if (identity != null)
                    {
                        var name         = identity.Split('\t');
                        var completeName = name[3] + " " + name[4] + " " + name[5];
                        listNames.Add(tripValues[0], completeName);
                    }
                }
                if (!listPassengerNames.ContainsKey(tripValues[1]))
                {
                    var identity = namesReader.ReadLine();
                    if (identity != null)
                    {
                        var name         = identity.Split('\t');
                        var completeName = name[3] + " " + name[4] + " " + name[5];
                        listPassengerNames.Add(tripValues[1], completeName);
                    }
                }


                try
                {
                    trip.Id         = countLines + "d@[email protected]";
                    trip.DriverName = listNames[tripValues[0]];
                    var lat = Convert.ToDouble(tripValues[13]);
                    var lng = Convert.ToDouble(tripValues[12]);
                    if (Math.Abs(lat) > 0 && Math.Abs(lng) > 0 && Math.Abs(lng) < 180 && Math.Abs(lat) < 180)
                    {
                        trip.DropoffLocation = new Location(lat, lng);
                    }
                    else
                    {
                        Console.WriteLine("Incomplete Trip");
                        continue;
                    }
                    trip.DriverInitiaLocation = new Location(40.769004, -73.981376);
                    trip.DropoffTime          = Convert.ToDateTime(tripValues[6]).AddYears(1).AddMonths(5);
                    trip.DropoffTime          = trip.DropoffTime.Value.AddDays(-1 * trip.DropoffTime.Value.Day);
                    trip.DropoffTime          = trip.DropoffTime.Value.AddDays(r.Next(1, 31));
                    trip.EnrouteDistance      = Convert.ToDouble(tripValues[9]);
                    trip.FleetId                = "30";
                    trip.FleetName              = "NY Taxi";
                    trip.OriginatingPartnerId   = "*****@*****.**";
                    trip.OriginatingPartnerName = "NY Taxi";
                    trip.PassengerName          = listPassengerNames[tripValues[1]];
                    lat = Convert.ToDouble(tripValues[11]);
                    lng = Convert.ToDouble(tripValues[10]);
                    if (Math.Abs(lat) > 0 && Math.Abs(lng) > 0 && Math.Abs(lng) < 180 && Math.Abs(lat) < 180)
                    {
                        trip.PickupLocation = new Location(lat, lng);
                    }
                    else
                    {
                        Console.WriteLine("Incomplete Trip");
                        continue;
                    }
                    trip.PickupTime           = Convert.ToDateTime(tripValues[5]).AddYears(1).AddMonths(5);
                    trip.PickupTime           = trip.PickupTime.Value.AddDays(-1 * trip.PickupTime.Value.Day);
                    trip.PickupTime           = trip.PickupTime.Value.AddDays(trip.DropoffTime.Value.Day);
                    trip.LastUpdate           = trip.DropoffTime;
                    trip.Price                = Convert.ToDouble(fareValues[10]);
                    trip.ServicingPartnerId   = "*****@*****.**";
                    trip.ServicingPartnerName = "NY Taxi";
                    trip.Status               = Status.Complete;

                    trips.Insert(trip);
                    Console.WriteLine(trip.Id);
                    countLines++;
                }
                catch (Exception)
                {
                    Console.WriteLine("ERROR Incomplete Trip");
                }
            }
            foreach (var variable in listNames)
            {
                Console.WriteLine(variable.Value);
            }
            Console.WriteLine(listNames.Count);
            Console.WriteLine(listPassengerNames.Count);
            Console.ReadLine();
        }
Ejemplo n.º 25
0
        // GET: Trip/Details/5
        public ActionResult Details(int?thisTripId)
        {
            if (thisTripId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            // ViewBag value for holding part of google maps url data string
            ViewBag.Markers = "";
            string[] colours = { "red", "green", "blue" };


            Trip trip = dbcontext.Trips.Find(thisTripId);

            if (trip == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }
            ViewEditTripsViewModel model = new ViewEditTripsViewModel();

            model.TripInstance = trip;

            var list = new List <TripLocationsInstanceViewModels>();
            int i    = 0;

            foreach (var item in dbcontext.Trip_Locations.ToList())
            {
                if (item.Id_Trip == thisTripId)
                {
                    foreach (var location in dbcontext.Locations.ToList())
                    {
                        if (item.Id_Location == location.Id)
                        {
                            // Create a marker string using current location data; can be modified for any url string if needed depending on map provider
                            ++i;
                            // cycles the string array in a loop
                            ViewBag.Markers += "&markers=color:" + colours[(i - 1) % 3] + "|label:" + i.ToString() + "|" + location.Name + "," + location.Town + "," + location.Country;
                            // ********************
                            list.Add(new TripLocationsInstanceViewModels
                            {
                                Country         = location.Country,
                                Town            = location.Town,
                                Name            = location.Name,
                                Description     = location.Description,
                                LocationImage   = location.LocationImage,
                                Number          = item.Number,
                                RouteInstanceId = item.Id
                            });
                        }
                    }
                }
            }
            model.Route = new TripLocationsViewModels();
            if (list.Count() > 0)
            {
                model.Route.ListElement = list;
            }
            if (thisTripId != null && dbcontext.Trips.Find(thisTripId) != null)
            {
                model.Route.Id_Trip = (int)thisTripId;
            }


            //return free spots left FOR NOW STATIC VALUES. Bookings controller is not implemented
            model.NumSpotsLeft = countFreeSpots((int)thisTripId);
            //return number of reservations
            model.NumberOfReservations = countReservavtionsMade((int)thisTripId);

            // add coach info to List
            foreach (var item in dbcontext.Coaches.ToList())
            {
                if (trip.CoachNumberId == item.Id)
                {
                    model.CoachBanner = item.VehScreenshot;
                    model.CoachModel  = item.Brand + " " + item.VehModel + " - no." + item.VehicleNumber;
                }
            }

            return(View(model));
        }
Ejemplo n.º 26
0
        public static List <Trip> FindTradeRoutes()
        {
            if (Market.Instance.OrdersByType == null)
            {
                return(null);
            }
            if (Market.Instance.OrdersByType.Count == 0)
            {
                return(null);
            }

            var profitableTx = new List <Transaction>();

            // for each item type
            Parallel.ForEach(Market.Instance.OrdersByType, (orderGroup, state) =>
            {
                var orders = orderGroup.ToList();

                // query volume and name for this item type once
                var type = Db.Instance.Types.Where(t => t.typeID == orderGroup.Key).Select(t => new { typeVolume = t.volume, typeName = t.typeName }).FirstOrDefault();

                // although typeId should return a result every time, an outdated static database may yield null
                if (type == null)
                {
                    return;
                }

                var volume = type.typeVolume;
                var name   = type.typeName;

                foreach (var o in orders)
                {
                    o.TypeVolume = volume;
                    o.TypeName   = name;
                }

                var transactions = from s in orders
                                   join b in orders on s.TypeId equals b.TypeId
                                   where s.Bid == false && b.Bid == true && s.Price < b.Price
                                   //select new { sell = s, buy = b };
                                   select new Transaction(s, b);

                foreach (var tx in transactions)
                {
                    //var tx = new Transaction(t.sell, t.buy);

                    if (Settings.Default.IsHighSec && tx.SellOrder.StationSecurity < 0.5)
                    {
                        continue;
                    }
                    if (tx.Profit < Settings.Default.MinBaseProfit)
                    {
                        continue;
                    }

                    tx.Waypoints = Map.Instance.FindRoute(tx.StartSystemId, tx.EndSystemId);
                    if (tx.Waypoints == null)
                    {
                        continue;
                    }

                    tx.Jumps         = tx.Waypoints.Count;
                    tx.ProfitPerJump = tx.Jumps > 0 ? tx.Profit / (double)tx.Jumps : tx.Profit;

                    if (tx.ProfitPerJump >= Settings.Default.MinProfitPerJump)
                    {
                        profitableTx.Add(tx);
                    }

                    //profitableTx.Add(tx);
                }
            }); // Parallel.ForEach

            if (profitableTx.Count == 0)
            {
                return(null);
            }

            var playerSystemId = Auth.Instance.GetLocation();

            if (playerSystemId == 0)
            {
                playerSystemId = Settings.Default.DefaultLocation;
            }

            var stationPairGroups = profitableTx.GroupBy(x => new { x.StartStationId, x.EndStationId }).
                                    Select(y => y.OrderByDescending(x => x.Profit).ToList());

            var trips = new List <Trip>();

            Parallel.ForEach(stationPairGroups, tx =>
                             //foreach(var tx in stationPairGroups)
            {
                var selectedTx = new List <Transaction>();

                // find the route once for this station pair
                var waypoints = tx.First().Waypoints; //Map.FindRoute(tx.First().StartSystemId, tx.First().EndSystemId);

                var isk = Settings.Default.Capital;
                var vol = Settings.Default.MaxCargo;

                var types = tx.GroupBy(x => x.TypeId).Select(x => x.Key);

                foreach (var typeId in types)
                {
                    var buyOrders  = tx.Where(x => x.TypeId == typeId).Select(x => x.BuyOrder).OrderByDescending(x => x.Price).GroupBy(x => x.OrderId).Select(x => x.First()).ToList();
                    var sellOrders = tx.Where(x => x.TypeId == typeId).Select(x => x.SellOrder).OrderBy(x => x.Price).GroupBy(x => x.OrderId).Select(x => x.First()).ToList();

                    var tracker = sellOrders.GroupBy(x => x.OrderId).Select(x => x.First()).ToDictionary(x => x.OrderId, x => x.VolumeRemaining);

                    // try to fill buy orders
                    foreach (var buyOrder in buyOrders)
                    {
                        var quantityToFill = Math.Max(buyOrder.MinVolume, buyOrder.VolumeRemaining);
                        var temp           = new List <Transaction>();

                        foreach (var sellOrder in sellOrders)
                        {
                            if (tracker[sellOrder.OrderId] <= 0)
                            {
                                continue;
                            }

                            var quantity            = Math.Min(tracker[sellOrder.OrderId], quantityToFill);
                            var partialTx           = new Transaction(sellOrder, buyOrder, quantity);
                            partialTx.Waypoints     = waypoints;
                            partialTx.Jumps         = waypoints.Count;
                            partialTx.ProfitPerJump = partialTx.Jumps > 0 ? partialTx.Profit / (double)partialTx.Jumps : partialTx.Profit;

                            if (partialTx.Cost <= isk && partialTx.Weight <= vol)
                            {
                                quantityToFill -= partialTx.Quantity;
                                isk            -= partialTx.Cost;
                                vol            -= partialTx.Weight;
                                temp.Add(partialTx);
                            }
                            else
                            {
                                //add partially
                                var quantityIsk    = (int)(isk / sellOrder.Price);
                                var quantityWeight = (int)(vol / sellOrder.TypeVolume);
                                var quantityPart   = Math.Min(quantityIsk, quantityWeight);

                                if (quantityPart > 0)
                                {
                                    var partTx           = new Transaction(sellOrder, buyOrder, quantityPart);
                                    partTx.Waypoints     = waypoints;
                                    partTx.Jumps         = waypoints.Count;
                                    partTx.ProfitPerJump = partTx.Jumps > 0
                                        ? partTx.Profit / (double)partTx.Jumps
                                        : partTx.Profit;

                                    if (partTx.Profit > Settings.Default.MinFillerProfit)
                                    {
                                        quantityToFill -= partTx.Quantity;
                                        isk            -= partTx.Cost;
                                        vol            -= partTx.Weight;
                                        temp.Add(partTx);
                                    }
                                }
                            }

                            // Filled buy order
                            if (quantityToFill == 0)
                            {
                                break;
                            }
                        } // foreach sell order

                        // Filling the buy order was successfull, commit
                        if (quantityToFill == 0 || quantityToFill > buyOrder.MinVolume)
                        {
                            selectedTx.AddRange(temp);

                            foreach (var t in temp)
                            {
                                //isk -= t.Cost;
                                //vol -= t.Weight;
                                tracker[t.SellOrder.OrderId] -= t.Quantity;
                                //t.Waypoints = waypoints;
                            }
                        }
                        else // could not fill  buy order completely, undo
                        {
                            foreach (var t in temp)
                            {
                                isk += t.Cost;
                                vol += t.Weight;
                            }
                        }
                    } // foreach buy order
                }     // for each type

                if (selectedTx.Count > 0)
                {
                    // creating a trip out of transactions for this station pair
                    var trip          = new Trip();
                    trip.Transactions = selectedTx;
                    trip.Profit       = trip.Transactions.Sum(x => x.Profit);
                    trip.Cost         = trip.Transactions.Sum(x => x.Cost);
                    trip.Weight       = trip.Transactions.Sum(x => x.Weight);

                    // change playerSystemId here to find remote routes
                    trip.Waypoints = Map.Instance.FindRoute(playerSystemId, trip.Transactions.First().StartSystemId);

                    if (trip.Waypoints != null)
                    {
                        trip.Jumps         = trip.Waypoints.Count + trip.Transactions.First().Jumps;
                        trip.ProfitPerJump = (trip.Jumps > 0 ? trip.Profit / (double)trip.Jumps : trip.Profit);

                        var ssn = Db.Instance.Stations.First(s => s.stationID == trip.Transactions.First().StartStationId).stationName;
                        var bsn = Db.Instance.Stations.First(s => s.stationID == trip.Transactions.First().EndStationId).stationName;

                        // TODO: just save the station names once in the trip class
                        foreach (var t in trip.Transactions)
                        {
                            t.SellOrder.StationName = ssn;
                            t.BuyOrder.StationName  = bsn;
                        }

                        trip.SecurityWaypoints = new List <SolarSystem>();

                        foreach (var systemId in trip.Waypoints.Concat(trip.Transactions.First().Waypoints))
                        {
                            var sec = Db.Instance.SolarSystems.First(x => x.solarSystemID == systemId);
                            trip.SecurityWaypoints.Add(sec);
                        }

                        if (trip.ProfitPerJump >= Settings.Default.MinProfitPerJump)
                        {
                            trips.Add(trip);
                        }
                    }
                }
            });

            return(trips.OrderByDescending(x => x.ProfitPerJump).ToList());
        }
Ejemplo n.º 27
0
        public ActionResult Destroy([DataSourceRequest] DataSourceRequest request, Trip trip)
        {
            this.tripService.MarkAsDeleted(trip);

            return(Json(new[] { trip }.ToDataSourceResult(request, ModelState)));
        }
 public List <Note> LoadNotesFromTrip(Trip trip)
 {
     return(db.notes.Where(x => x.Trip == trip).ToList());
 }
Ejemplo n.º 29
0
        public static string ImportTrips(StationsDbContext context, string jsonString)
        {
            var deserializedTrips = JsonConvert.DeserializeObject <TripDto[]>(jsonString);

            var validTrips = new List <Trip>();

            var sb = new StringBuilder();

            foreach (var tripDto in deserializedTrips)
            {
                if (!IsValid(tripDto))
                {
                    sb.AppendLine(FailureMessage);
                    continue;
                }

                if (tripDto.Status == null)
                {
                    tripDto.Status = "OnTime";
                }

                bool trainExists              = context.Trains.Any(t => t.TrainNumber == tripDto.Train);
                bool originStationExists      = context.Stations.Any(s => s.Name == tripDto.OriginStation);
                bool destinationStationExists = context.Stations.Any(s => s.Name == tripDto.DestinationStation);

                DateTime arrivalTime   = DateTime.ParseExact(tripDto.ArrivalTime, "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);
                DateTime departureTime = DateTime.ParseExact(tripDto.DepartureTime, "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);

                bool departureTimeIsBeforeArrivalTime = departureTime < arrivalTime;

                if (!trainExists || !originStationExists || !destinationStationExists || !departureTimeIsBeforeArrivalTime)
                {
                    sb.AppendLine(FailureMessage);
                    continue;
                }

                TimeSpan?timeDifference = null;
                if (tripDto.TimeDifference != null)
                {
                    timeDifference = TimeSpan.ParseExact(tripDto.TimeDifference, @"hh\:mm", CultureInfo.InvariantCulture);
                }

                int trainId              = context.Trains.AsNoTracking().SingleOrDefault(t => t.TrainNumber == tripDto.Train).Id;
                int originStationId      = context.Stations.AsNoTracking().SingleOrDefault(s => s.Name == tripDto.OriginStation).Id;
                int destinationStationId = context.Stations.AsNoTracking().SingleOrDefault(s => s.Name == tripDto.DestinationStation).Id;
                var tripStatus           = Enum.Parse <TripStatus>(tripDto.Status, true);

                Trip trip = new Trip
                {
                    Status               = tripStatus,
                    TimeDifference       = timeDifference,
                    TrainId              = trainId,
                    OriginStationId      = originStationId,
                    DestinationStationId = destinationStationId,
                    ArrivalTime          = arrivalTime,
                    DepartureTime        = departureTime,
                };

                validTrips.Add(trip);

                sb.AppendLine($"Trip from {tripDto.OriginStation} to {tripDto.DestinationStation} imported.");
            }

            context.Trips.AddRange(validTrips);
            context.SaveChanges();

            string result = sb.ToString().TrimEnd();

            return(result);
        }
Ejemplo n.º 30
0
 public IActionResult UpdateTrip(int tripId, [FromBody] Trip trip)
 {
     _service.UpdateTrip(tripId, trip);
     return(Ok(trip));
 }
 public void Update(Trip trip)
 {
     _context.Trips.Update(trip);
 }
Ejemplo n.º 32
0
 public async Task <Trip> AddTripAsync(User user, Trip trip)
 {
     trip.UserId = user.Id;
     return(await tripRepository.AddAsync(trip));
 }
Ejemplo n.º 33
0
        public ActionResult Create(MileageFormVM model, Trip trip)
        {
            var startAddress = ParseAddress(model.StartAddress);
            var endAddress   = ParseAddress(model.EndAddress);

            string startCityValue     = startAddress[2].Trim();
            string startSiteName      = startAddress[0].Trim();
            string startStreetAddress = startAddress[1].Trim();

            string endCityValue     = endAddress[2].Trim();
            string endSiteName      = endAddress[0].Trim();
            string endStreetAddress = endAddress[1].Trim();

            //create the cities
            var startCity = new City {
                Name = startCityValue
            };
            var endCity = new City {
                Name = endCityValue
            };

            var startAddressCreate = new Address();
            var endAddressCreate   = new Address();

            var checkStartCity = db.Cities.Where(c => c.Name == startCityValue);
            int startCityCount = 0;

            checkStartCity.ToList().ForEach(x => { startCityCount++; });

            if (startCityCount < 1)
            {
                new CitiesController().Create(startCity);
            }

            startAddressCreate.CityID = db.Cities.Where(c => c.Name == startCityValue).SingleOrDefault().ID;

            var checkEndCity = db.Cities.Where(c => c.Name == endCityValue);
            int endCityCount = 0;

            checkEndCity.ToList().ForEach(x => { endCityCount++; });

            if (endCityCount < 1)
            {
                new CitiesController().Create(endCity);
            }

            endAddressCreate.CityID = db.Cities.Where(c => c.Name == endCityValue).SingleOrDefault().ID;

            startAddressCreate.SiteName      = startSiteName;
            startAddressCreate.StreetAddress = startStreetAddress;

            var checkStartAddress = db.Addresses.Where(c => c.SiteName == startSiteName);
            int startAddressCount = 0;

            checkStartAddress.ToList().ForEach(x => { startAddressCount++; });

            if (startAddressCount < 1)
            {
                new AddressesController().Create(startAddressCreate);
            }


            trip.StartAddressID = db.Addresses.Where(a => a.SiteName == startSiteName).SingleOrDefault().ID;

            endAddressCreate.SiteName      = endSiteName;
            endAddressCreate.StreetAddress = endStreetAddress;

            var checkEndAddress = db.Addresses.Where(c => c.SiteName == endSiteName);
            int endAddressCount = 0;

            checkEndAddress.ToList().ForEach(x => { endAddressCount++; });

            if (endAddressCount < 1)
            {
                new AddressesController().Create(endAddressCreate);
            }

            trip.EndAddressID = db.Addresses.Where(a => a.SiteName == endSiteName).SingleOrDefault().ID;

            trip.Distance = model.Distance;
            trip.Date     = model.Date;

            new TripController().Add(trip);

            return(RedirectToAction("Details", "MileageForms", new { id = trip.MileageFormID }));
        }
Ejemplo n.º 34
0
        public void CURDCollectionNavigationPropertyAndRef()
        {
            this.TestClientContext.MergeOption = MergeOption.OverwriteChanges;

            Person person = new Person()
            {
                FirstName = "Sheldon",
                LastName  = "Cooper",
                UserName  = "******"
            };

            this.TestClientContext.AddToPeople(person);
            this.TestClientContext.SaveChanges();
            int personId = person.PersonId;

            var  startDate = DateTime.Now;
            Trip trip1     = new Trip()
            {
                PersonId    = personId,
                TrackGuid   = Guid.NewGuid(),
                ShareId     = new Guid("c95d15e8-582b-44cf-9e97-ff63a5f26091"),
                Name        = "Honeymoon",
                Budget      = 2000.0f,
                Description = "Happy honeymoon trip",
                StartsAt    = startDate,
                EndsAt      = startDate.AddDays(3),
                LastUpdated = DateTime.UtcNow,
            };

            Trip trip2 = new Trip()
            {
                PersonId    = personId,
                TrackGuid   = Guid.NewGuid(),
                ShareId     = new Guid("56947cf5-2133-43b8-81f0-b6c3f1e5e51a"),
                Name        = "Honeymoon",
                Budget      = 3000.0f,
                Description = "Happy honeymoon trip",
                StartsAt    = startDate.AddDays(1),
                EndsAt      = startDate.AddDays(5),
                LastUpdated = DateTime.UtcNow,
            };

            this.TestClientContext.AddToTrips(trip1);
            this.TestClientContext.SaveChanges();

            // Create a related entity by Navigation link
            this.TestClientContext.AddRelatedObject(person, "Trips", trip2);
            this.TestClientContext.SaveChanges();

            // Query Navigation properties.
            var trips = this.TestClientContext.People
                        .ByKey(new Dictionary <string, object> {
                { "PersonId", personId }
            })
                        .Trips.ToList();

            Assert.Equal(2, trips.Count());
            Assert.True(trips.Any(t => t.TripId == trip1.TripId));
            Assert.True(trips.Any(t => t.TripId == trip2.TripId));

            // Get $ref
            HttpWebRequestMessage request = new HttpWebRequestMessage(
                new DataServiceClientRequestMessageArgs(
                    "Get",
                    new Uri(string.Format(this.TestClientContext.BaseUri + "/People({0})/Trips/$ref", personId),
                            UriKind.Absolute),
                    false,
                    false,
                    new Dictionary <string, string>()));

            using (var response = request.GetResponse() as HttpWebResponseMessage)
            {
                Assert.Equal(200, response.StatusCode);
                using (var stream = response.GetStream())
                {
                    StreamReader reader          = new StreamReader(stream);
                    var          expectedPayload = "{"
                                                   + "\r\n"
                                                   + @"  ""@odata.context"":""http://*****:*****@"    {"
                                                   + "\r\n"
                                                   + string.Format(@"      ""@odata.id"":""http://*****:*****@"      ""@odata.id"":""http://localhost:18384/api/Trippin/Trips({0})""", trip2.TripId)
                                                   + "\r\n"
                                                   + "    }"
                                                   + "\r\n"
                                                   + "  ]"
                                                   + "\r\n"
                                                   + "}";
                    var content = reader.ReadToEnd();
                    Assert.Equal(expectedPayload, content);
                }
            }

            // Delete $ref
            this.TestClientContext.DeleteLink(person, "Trips", trip2);
            this.TestClientContext.SaveChanges();

            // Expand Navigation properties
            this.TestClientContext.Detach(trip1);
            person = this.TestClientContext.People
                     .ByKey(new Dictionary <string, object> {
                { "PersonId", personId }
            })
                     .Expand(t => t.Trips)
                     .GetValue();
            Assert.Equal(1, person.Trips.Count);
            Assert.True(person.Trips.Any(t => t.TripId == trip1.TripId));

            Person person2 = new Person()
            {
                FirstName = "Sheldon2",
                LastName  = "Cooper2",
                UserName  = "******"
            };

            this.TestClientContext.AddToPeople(person2);
            this.TestClientContext.SaveChanges();
            personId = person2.PersonId;

            // Add $ref
            this.TestClientContext.AddLink(person2, "Trips", trip2);
            this.TestClientContext.SaveChanges();

            // Expand Navigation properties
            this.TestClientContext.Detach(trip1);
            this.TestClientContext.Detach(trip2);
            person = this.TestClientContext.People
                     .ByKey(new Dictionary <string, object> {
                { "PersonId", personId }
            })
                     .Expand(t => t.Trips)
                     .GetValue();
            Assert.Equal(1, person.Trips.Count);
            Assert.True(person.Trips.Any(t => t.TripId == trip2.TripId));
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.nItem_fragment);

            // DisplayMetrics dm = new DisplayMetrics();
            // WindowManager.DefaultDisplay.GetMetrics(dm);

            // Window.SetLayout(dm.WidthPixels * 80 / 100, dm.HeightPixels * 60 / 100);
            //Window.SetGravity(GravityFlags.Top);

            //ColorDrawable dw = new ColorDrawable(Android.Graphics.Color.Black);
            //Window.SetBackgroundDrawable(dw);
            // this.setBackgroundDrawable(dw);

            var toolBar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolBar);

            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);

            ViewPager viewpager = (ViewPager)FindViewById(Resource.Id.viewPager);

            //Trip Spiner
            Spinner spinner_trip = FindViewById <Spinner>(Resource.Id.additem_trip_spinner);

            var           trip_list       = Trip.search(this, "complete_date = ?", new string[] { "" }, "registration_date ASC");
            List <string> trip_list_array = new List <string>();

            if (trip_list == null)
            {
                trip_list_array.Add("");
            }
            else
            {
                foreach (Trip t in trip_list)
                {
                    trip_list_array.Add(t.destiny);
                }
            }


            var adapter_trip = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem, trip_list_array);

            spinner_trip.Adapter = adapter_trip;


            //Category Spiner
            Spinner       spinner_category = FindViewById <Spinner>(Resource.Id.additem_category_spinner);
            var           category_list    = Category.get_all(this);
            List <string> category_names   = new List <string>();

            foreach (Category c in category_list)
            {
                category_names.Add(c.name);
            }

            var adapter_category = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem, category_names.ToArray());

            spinner_category.Adapter = adapter_category;


            Button add_item = FindViewById <Button>(Resource.Id.additem_buttonAdd);

            add_item.Click += delegate
            {
                var txtValue    = FindViewById <TextView>(Resource.Id.additem_txtValue).Text;
                var txtDetails  = FindViewById <TextView>(Resource.Id.additem_txtDetails).Text;
                var txtCategory = spinner_category.SelectedItem.ToString();
                var txtTrip     = spinner_trip.SelectedItem.ToString();

                Item i = new Item();
                i.value       = txtValue == "" ? float.Parse("0.0") : float.Parse(txtValue);
                i.value      *= -1;
                i.details     = txtDetails == "" ? " -- " : txtDetails;
                i.trip_id     = trip_list.Find(x => x.destiny == spinner_trip.SelectedItem.ToString()).id;
                i.category_id = category_list.Find(x => x.name == spinner_category.SelectedItem.ToString()).id;

                i.save(this);

                Resume_Fragment resumeFragment = MyFragmentAdapter.getLastResumeFragment();
                if (resumeFragment != null)
                {
                    resumeFragment.FillHashList();
                    resumeFragment.adapter.NotifyDataSetChanged();
                }

                TripCurrent_Fragment tripcFragment = MyFragmentAdapter.getlastTripCurrentFragment();
                if (tripcFragment != null)
                {
                    tripcFragment.updateCurrentFragment();
                }

                this.Finish();
            };
        }
Ejemplo n.º 36
0
 public async Task ChangeDepartureDateAsync(Trip trip, DateTime departureDate)
 {
     trip.DepartureDate = departureDate;
     await tripRepository.UpdateAsync(trip);
 }
Ejemplo n.º 37
0
 public Trip AddTrip(User user, Trip trip)
 {
     trip.UserId = user.Id;
     return(tripRepository.Add(trip));
 }
Ejemplo n.º 38
0
        public IEnumerable<SelectListItem> GetleftAvailableSeatsSelectList(Trip trip)
        {
            int carSeats = trip.Driver.Car.TotalSeats;
            int availableLeftSeatsCount = this.tripServices.GetTakenSeatsCount(trip.Id);
            int maxAvailableLeftSeats = carSeats - availableLeftSeatsCount;

            var leftAvailableSeatsSelectList = new List<SelectListItem>();

            for (int i = 0; i <= maxAvailableLeftSeats; i++)
            {
                leftAvailableSeatsSelectList.Add(new SelectListItem()
                {
                    Text = i.ToString(),
                    Value = i.ToString()
                });
            }

            return leftAvailableSeatsSelectList;
        }
Ejemplo n.º 39
0
 protected override void LoadModel(object savedModel)
 {
     trip = (Trip)savedModel;
 }
Ejemplo n.º 40
0
 partial void InsertTrip(Trip instance);
Ejemplo n.º 41
0
        private void Load_Planning_Click(object sender, RoutedEventArgs e)
        {
            selectedTrips = new List <DataGridTrips>();

            City city = new City();
            Trip trip = new Trip();

            //1. get the startCityID
            city.cityName = txtStartCity.Text;
            var startCityResult = city.GetCityName(city.cityName);

            if (startCityResult.Count != 0)
            {
                trip.startCityID = startCityResult[0].cityID;
            }
            else
            {
                trip.startCityID = "";
            }

            //2. get the endCityID
            city.cityName = txtEndCity.Text;
            var endCityResult = city.GetCityName(city.cityName);

            if (endCityResult.Count != 0)
            {
                trip.endCityID = endCityResult[0].cityID;
            }
            else
            {
                trip.endCityID = "";
            }

            //retreive order data
            var viewTrips = trip.GetTripsST(trip.startCityID, trip.endCityID);

            if (viewTrips.Count != 0)
            {
                for (int i = 0; i < viewTrips.Count; i++)
                {
                    trip.orderID   = txtOrderID.Text;
                    trip.startCity = viewTrips[i].startCityID;
                    trip.endCity   = viewTrips[i].endCityID;

                    if (viewTrips[i].startCityID == viewTrips[i].endCityID &&
                        viewTrips[i].startCityID == viewTrips[i].originalCityID)
                    {
                        viewTrips[i].tripStatus = "loading";
                    }
                    else if ((viewTrips[i].startCityID == viewTrips[i].endCityID &&
                              viewTrips[i].endCityID == viewTrips[i].desCityID))
                    {
                        viewTrips[i].tripStatus = "unloading";
                    }
                    else
                    {
                        viewTrips[i].tripStatus = "driving";
                    }

                    selectedTrips.Add(new DataGridTrips
                    {
                        TranNo        = (i + 1).ToString(),
                        startCityName = viewTrips[i].startCityName,
                        endCityName   = viewTrips[i].endCityName,
                        distance      = viewTrips[i].distance,
                        workingTime   = viewTrips[i].workingTime,
                        tripStatus    = viewTrips[i].tripStatus
                    });
                }

                tripResultDataGrid.ItemsSource = selectedTrips;
                tripResultDataGrid.Items.Refresh();
            }
            else
            {
                MessageBox.Show("There is no plan information for the order. Please check the plan information first.",
                                "Check the plan information.");
            }
        }
Ejemplo n.º 42
0
 public void ChangeArivalDate(Trip trip, DateTime arrivalDate)
 {
     trip.ArriavalDate = arrivalDate;
     tripRepository.Update(trip);
 }
Ejemplo n.º 43
0
        public BillingAndPlanning(Order order)
        {
            InitializeComponent();
            var orderList = order.GetOrderDetailWithID(order.orderID);

            if (orderList.Count != 0)
            {
                txtCustomerName.Text = orderList[0].customerName;
                txtOrderID.Text      = orderList[0].orderID;
                txtStartCity.Text    = orderList[0].startCityName.ToString();
                txtEndCity.Text      = orderList[0].endCityName.ToString();

                City city = new City();
                Trip trip = new Trip();

                //1. get the startCityID
                city.cityName = txtStartCity.Text;
                var startCityResult = city.GetCityName(city.cityName);
                trip.startCityID = startCityResult[0].cityID;

                //2. get the endCityID
                city.cityName = txtEndCity.Text;
                var endCityResult = city.GetCityName(city.cityName);
                trip.endCityID = endCityResult[0].cityID;

                //retreive order data
                var viewTrips = trip.GetTripsST(trip.startCityID, trip.endCityID);

                for (int i = 0; i < viewTrips.Count; i++)
                {
                    trip.orderID   = txtOrderID.Text;
                    trip.startCity = viewTrips[i].startCityID;
                    trip.endCity   = viewTrips[i].endCityID;

                    if (viewTrips[i].startCityID == viewTrips[i].endCityID &&
                        viewTrips[i].startCityID == viewTrips[i].originalCityID)
                    {
                        viewTrips[i].tripStatus = "loading";
                    }
                    else if ((viewTrips[i].startCityID == viewTrips[i].endCityID &&
                              viewTrips[i].endCityID == viewTrips[i].desCityID))
                    {
                        viewTrips[i].tripStatus = "unloading";
                    }
                    else
                    {
                        viewTrips[i].tripStatus = "driving";
                    }

                    selectedTrips.Add(new DataGridTrips
                    {
                        TranNo        = (i + 1).ToString(),
                        startCityName = viewTrips[i].startCityName,
                        endCityName   = viewTrips[i].endCityName,
                        distance      = viewTrips[i].distance,
                        workingTime   = viewTrips[i].workingTime,
                        tripStatus    = viewTrips[i].tripStatus
                    });
                }

                tripResultDataGrid.ItemsSource = selectedTrips;
                tripResultDataGrid.Items.Refresh();
            }
            else
            {
                MessageBox.Show("There is no trip information for the order. Please check the trip information first.",
                                "Check the trips information.");
            }
        }
Ejemplo n.º 44
0
 public ViewResult InviteFriends(Trip trip)
 {
     return View(trip);
 }
Ejemplo n.º 45
0
 public void Create_trip_adds_to_repository()
 {
     TripController controller = new TripController(repository, provider);
     Trip newTrip = new Trip(provider.AuthenticatedUser.UserID);
     newTrip.current_weight = 8;
     newTrip.description = "London Trip";
     newTrip.destination = "London";
     newTrip.total_capacity = 12;
     newTrip.weather = "Cloudy";
     controller.Create(newTrip);
     ViewResult result = controller.Index() as ViewResult;
     IQueryable<Trip> model = result.Model as IQueryable<Trip>;
     Assert.IsTrue(model.Contains(newTrip));
     Assert.AreEqual(2, model.Count());
 }
Ejemplo n.º 46
0
 partial void DeleteTrip(Trip instance);
Ejemplo n.º 47
0
    /// <summary>
    /// Return a Trip object from session based on the provided trip ID.
    /// Does not do validation, but will create Trip if validation has been done.
    /// </summary>
    /// <param name="tripId">ID of trip to retrieve</param>
    /// <returns>Initialized trip pulled from session</returns>
    private Trip GetTrip(string tripId)
    {
        if (String.IsNullOrWhiteSpace(tripId)) { return null; }

        Trip trip;

        if (Session["trip"] != null)
        {
            trip = (Trip)Session["trip"];
            if (trip.ID == tripId) { return trip; }
        }

        //TODO: Validate before creating trip
        try { trip = new Trip(tripId); }
        catch { return null; }

        return trip;
    }
Ejemplo n.º 48
0
 protected override void LoadModel(object savedModel)
 {
     trip = (Trip)savedModel;
 }
Ejemplo n.º 49
0
 partial void UpdateTrip(Trip instance);
Ejemplo n.º 50
0
        public IHttpActionResult PutTripInPerson([FromODataUri] string key, [FromODataUri] int tripId, Trip trip)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (tripId != trip.TripId)
            {
                return(BadRequest("The TripId of Trip does not match the tripId."));
            }

            var person = TripPinSvcDataSource.Instance.People.SingleOrDefault(item => item.UserName == key);

            if (person == null)
            {
                return(NotFound());
            }

            var oldTrip = person.Trips.SingleOrDefault(item => item.TripId == tripId);

            if (oldTrip == null)
            {
                return(NotFound());
            }

            person.Trips.Remove(oldTrip);
            person.Trips.Add(trip);
            return(Updated(trip));
        }
Ejemplo n.º 51
0
 protected override void InitializeModel()
 {
     trip = new Trip();
     trip.Mode = TripMode.RoundTrip;
     trip.StartingFrom.Date = DateTime.Today;
     trip.ReturningFrom.Date = DateTime.Today.AddDays(1);
 }
Ejemplo n.º 52
0
 public void Delete(Trip trip)
 {
     this.trips.Delete(trip);
     this.trips.Save();
 }
Ejemplo n.º 53
0
        private void Load_Billing_Btn_Click(object sender, RoutedEventArgs e)
        {
            //get Shipping Route
            Trip trip = new Trip();

            trip.orderID = billingOrderID.Text;
            var billingTripData = trip.GetTripBilling(trip.orderID);

            if (billingTripData.Count != 0)
            {
                trip.carrierID = billingTripData[0].carrierID;

                var shippingRoute = trip.GetShowTripsForBillings(trip.orderID, trip.carrierID);
                //assign values for DataGrid
                IList <DataGridRoute> selectedTrips = new List <DataGridRoute>();

                for (int i = 0; i < shippingRoute.Count; i++)
                {
                    trip.tripID        = shippingRoute[i].tripID;
                    trip.startCityName = shippingRoute[i].startCityName;
                    trip.endCityName   = shippingRoute[i].endCityName;
                    trip.distance      = shippingRoute[i].distance;
                    trip.workingTime   = shippingRoute[i].workingTime;

                    //FTL
                    if (billingJobType.Text == "FTL")
                    {
                        trip.price = 4.985 * shippingRoute[i].distance +
                                     ((4.985 * shippingRoute[i].distance) * 8 / 100);
                        trip.rate = shippingRoute[i].ftlRate;

                        billingTotalAmount.Text = (Convert.ToDouble(billingTotalAmount.Text) + trip.price).ToString("0.##");
                    }
                    //LTL
                    else if (billingJobType.Text == "LTL")
                    {
                        trip.price = 0.2995 * shippingRoute[i].quantity * shippingRoute[i].distance +
                                     ((0.2995 * shippingRoute[i].quantity * shippingRoute[i].distance) * 5 / 100);
                        trip.rate = shippingRoute[i].ltlRate;
                        billingTotalAmount.Text = (Convert.ToDouble(billingTotalAmount.Text) + trip.price).ToString("0.##");
                    }

                    selectedTrips.Add(new DataGridRoute
                    {
                        tripID        = shippingRoute[i].tripID,
                        startCityName = shippingRoute[i].startCityName,
                        endCityName   = shippingRoute[i].endCityName,
                        distance      = shippingRoute[i].distance,
                        workingTime   = shippingRoute[i].workingTime,
                        tripStatus    = shippingRoute[i].tripStatus,
                        rate          = trip.rate.ToString("0.##"),
                        price         = trip.price.ToString("0.##")
                    });
                }

                billingDataGrid.ItemsSource = selectedTrips;
                billingDataGrid.Items.Refresh();
            }
            else
            {
                MessageBox.Show("There is no billing information for the order. Please check the billing information first.",
                                "Check the billing information.");
            }
        }
Ejemplo n.º 54
0
        // GET: Trip/Edit/5
        public ActionResult Edit(int?thisTripId)
        {
            if (thisTripId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            if (!UserRoleHelper.IsAdmin(User.Identity.GetUserId()))
            {
                if (!UserRoleHelper.IsEmployee(User.Identity.GetUserId()))// check if current user has admin or employee rights
                {
                    return(RedirectToAction("AccessDenied", "Manage"));
                }
            }

            //check for reservations. Cannot edit while there are any.
            int NumberOfReservations = countReservavtionsMade((int)thisTripId);

            Trip trip = dbcontext.Trips.Find(thisTripId); //get current trip

            if (trip == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }
            ViewEditTripsViewModel model = new ViewEditTripsViewModel();

            model.TripInstance = trip;


            //check for reservations. Cannot edit while there are any and trip is yet to end
            var currTime = DateTime.Now;

            if (NumberOfReservations > 0 && model.TripInstance.DateBack > currTime)
            {
                return(RedirectToAction("Index", new { Message = ManageMessageId.CannotEditEntry }));
            }


            //get a list of all sub-locations that this trip has
            var list = new List <TripLocationsInstanceViewModels>();

            foreach (var item in dbcontext.Trip_Locations.ToList())
            {
                if (item.Id_Trip == thisTripId)
                {
                    foreach (var location in dbcontext.Locations.ToList())
                    {
                        if (item.Id_Location == location.Id)
                        {
                            list.Add(new TripLocationsInstanceViewModels
                            {
                                Country         = location.Country,
                                Town            = location.Town,
                                Name            = location.Name,
                                Description     = location.Description,
                                LocationImage   = location.LocationImage,
                                Number          = item.Number,
                                RouteInstanceId = item.Id
                            });
                        }
                    }
                }
            }
            model.Route = new TripLocationsViewModels();
            if (list.Count() > 0)
            {
                model.Route.ListElement = list;
            }
            if (thisTripId != null && dbcontext.Trips.Find(thisTripId) != null)
            {
                model.Route.Id_Trip = (int)thisTripId;
            }

            // list that has every coach in database
            var listOfCoaches = dbcontext.Coaches.ToList();

            var currDate = DateTime.Now;

            // go through every trip in db that is in progress atm. A coach assigned to that trip will be removed from our list, so it cant be assigned
            //to this currently edited trip
            foreach (var coach in dbcontext.Coaches.ToList())
            {
                foreach (var tripInstance in dbcontext.Trips.ToList())
                {
                    if (tripInstance.DateDeparture < model.TripInstance.DateDeparture && model.TripInstance.DateDeparture < tripInstance.DateBack)
                    {
                        if (coach.Id == tripInstance.CoachNumberId)
                        {
                            listOfCoaches.Remove(coach);
                        }
                    }
                }
            }
            ViewBag.DateDeparture = model.TripInstance.DateDeparture;
            ViewBag.DateBack      = model.TripInstance.DateBack;

            model.CoachVehicleIdList = new SelectList(listOfCoaches, "Id", "VehicleNumber");

            return(View(model));
        }
Ejemplo n.º 55
0
 public ViewResult InviteFriendsAction(Trip trip)
 {
     return View("TripDetails");
 }
Ejemplo n.º 56
0
        public async Task <bool> DeleteAddOn(int addOnId, int tripId)
        {
            using (_unitOfWork)
            {
                if (addOnId <= 0)
                {
                    return(false);
                }

                AddOnDTO deletedAddOn = null;

                AddOn prevAddOn = null;
                Trip  trip      = await _unitOfWork.TripRepository.FindByID(tripId);

                AddOn currAddOn = await _unitOfWork.AddOnRepository.GetAddOnWithVotable(trip.AddOnId);

                while (true)
                {
                    if (currAddOn.GetDecoratorId() == 0)
                    {
                        break;
                    }

                    if (currAddOn.AddOnId == addOnId)
                    {
                        if (prevAddOn == null)
                        {
                            trip.AddOnId = currAddOn.GetDecoratorId();
                            _unitOfWork.TripRepository.Update(trip);
                        }
                        else
                        {
                            prevAddOn.SetDecoratorId(currAddOn.GetDecoratorId());
                            _unitOfWork.AddOnRepository.Update(prevAddOn);
                        }

                        _unitOfWork.AddOnRepository.Delete(currAddOn.AddOnId);
                        _unitOfWork.VotableRepository.Delete(currAddOn.VotableId);
                        await _unitOfWork.Save();

                        deletedAddOn = _mapper.Map <AddOn, AddOnDTO>(currAddOn);
                        break;
                    }

                    if (currAddOn.GetLvl1DependId() == addOnId || currAddOn.GetLvl2DependId() == addOnId)
                    {
                        if (prevAddOn == null)
                        {
                            trip.AddOnId = currAddOn.GetDecoratorId();
                            _unitOfWork.TripRepository.Update(trip);
                        }
                        else
                        {
                            prevAddOn.SetDecoratorId(currAddOn.GetDecoratorId());
                            _unitOfWork.AddOnRepository.Update(prevAddOn);
                        }

                        _unitOfWork.AddOnRepository.Delete(currAddOn.AddOnId);
                        _unitOfWork.VotableRepository.Delete(currAddOn.VotableId);
                        await _unitOfWork.Save();
                    }
                    else
                    {
                        prevAddOn = currAddOn;
                    }

                    if (prevAddOn == null)
                    {
                        currAddOn = await _unitOfWork.AddOnRepository.GetAddOnWithVotable(trip.AddOnId);
                    }
                    else
                    {
                        currAddOn = await _unitOfWork.AddOnRepository.GetAddOnWithVotable(prevAddOn.GetDecoratorId());
                    }
                }
                await _messageControllerService.NotifyOnTripChanges(tripId, "RemoveAddOn", deletedAddOn);

                return(true);
            }
        }
Ejemplo n.º 57
0
 public void Create(Trip trip)
 {
     this.trips.Add(trip);
     this.trips.Save();
 }
Ejemplo n.º 58
0
 public void AddTrip(Trip trip)
 {
     trips.Add(trip);
 }
Ejemplo n.º 59
0
 public void Update(Trip trip)
 {
     this.trips.Save();
 }
 public async Task AddAsync(Trip trip)
 {
     await _context.Trips.AddAsync(trip);
 }