Inheritance: MonoBehaviour
Exemplo n.º 1
0
    private void GetAvailableRides()
    {
        String registeredCondition = (Session["UserId"] != null) ? "AND o.User_Id != '" + Session["UserId"].ToString() + "'" : "";
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["RidersConnectionConnectionString"].ConnectionString);
        string selectstatement = "SELECT o.*, u.Firstname AS Firstname FROM Offers AS o, Users as u WHERE o.status = 0 AND o.User_Id = u.Id " + registeredCondition;
        con.Open();
        //will pull all rides, filter handled by client
        SqlCommand selectcommand = new SqlCommand(selectstatement, con);
        SqlDataReader reader = selectcommand.ExecuteReader();
        Data data = new Data();
        while (reader.Read())
        {
            Ride ride = new Ride
            {
                Id = int.Parse(reader["Id"].ToString()),
                address = reader["Address"].ToString(),
                latitude = reader["Latitude"].ToString(),
                longitude = reader["Longitude"].ToString(),
                rate = reader["Rate"].ToString(),
                max_distance = reader["MaxDistance"].ToString(),
                max_capacity = reader["Capacity"].ToString(),
                user_id = reader["User_Id"].ToString(),
                username = reader["Firstname"].ToString()
            };

            data.rides.Add(ride);
        }
        con.Close();
        Out(data, 200);
    }
Exemplo n.º 2
0
        public async Task PutAsync(Ride ride)
        {
            string url = String.Format(CultureInfo.InvariantCulture
                , "{0}rides/Put", _urlPrefix);

            await base.PutAsync<Ride>(url, ride);
        }
Exemplo n.º 3
0
 public void UnMountRide()
 {
     if(null != ride)
     {
         ride.UnMount();
     }
     ride = null;
 }
Exemplo n.º 4
0
 public static void AtendeCarona(User usr, Ride rd)
 {
     using (elmatEntities entities = new elmatEntities())
     {
         var ride = (from R in entities.RIDE.Where(x => x.RideID == rd.RideID) select R).FirstOrDefault();
         ride.DriverID = usr.UserID;
         entities.SaveChanges();
     }
 }
Exemplo n.º 5
0
    public void MountRide(int modelId)
    {
        ride = null;

        rideModelId = modelId;
        if(IsMainBodyReady)
        {
            ride = new Ride(modelId, MainBody);
            //ride.PlayAnim(EAnimType.Walk_Fore);
            rideModelId = 0;
        }
    }
Exemplo n.º 6
0
        public ActionResult <String> CreateRide([FromBody] Ride ride)
        {
            bool alreadyInDb = (from p in motherload.Rides where p.Driver == ride.Driver &&
                                p.Date == ride.Date && p.Time == ride.Time select p).Count() > 0;

            if (alreadyInDb)
            {
                return("alreadyExists");
            }
            else
            {
                motherload.Rides.Add(ride);
                motherload.SaveChanges();
                return("created");
            }
        }
Exemplo n.º 7
0
        public ActionResult Index(RegisterViewModel model)
        {
            var viewModel = new MemberViewModel()
            {
                Rolename       = model.RoleName,
                Email          = model.Email,
                Cars           = unitOfWork.Car.GetCars(),
                AvailableSeats = Ride.CreateAvailableSeatsForDrivers()
            };

            if (model.RoleName == RoleName.Driver)
            {
                return(View("DriverForm", viewModel));
            }
            return(View("PassengerForm", viewModel));
        }
        public List <Ride> AddBooking(Ride ride, Booking booking, Employee employee, Client client)
        {
            ((BookingDBRepository)_bookingRepository).Save(booking);

            var allRides = ((RideDBRepository)_rideRepository).FindAll().ToList();

            foreach (var x in _observers.Keys)
            {
                if (x != employee.UserName)
                {
                    Task.Run(() => _observers[x].AddBooking(allRides));
                }
            }

            return(allRides);
        }
        private void listView_Click(object sender, RoutedEventArgs e)
        {
            Marketplace marketplace  = Marketplace.Instance;
            List <Ride> buyableRides = marketplace.GetBuyableRides(park.ParkInventory);

            var item = (sender as ListView).SelectedItem;

            if (item != null)
            {
                Ride ride = item as Ride;

                NameLabel.Content     = "Name: " + ride.Name;
                DurationLabel.Content = "Duration: " + ride.Duration;
                EntryFee.Content      = "Entry Fee: " + ride.EntryFee.ToString();
            }
        }
Exemplo n.º 10
0
            public void ApplyRide(Ride r)
            {
                var d = r.DistToStart(CurRow, CurRow);

                CurT += d;
                if (r.StartT < CurT)
                {
                    CurT = r.StartT;
                }

                CurT  += r.Length();
                CurRow = r.FinishRow;
                CurCol = r.FinishCol;

                Rides.Add(r);
            }
Exemplo n.º 11
0
 public RideDTO(Ride r)
 {
     if (r != null)
     {
         AvailableSeats        = r.AvailableSeats;
         DropOffLocation       = r.DropOffLocation;
         IsSoldOut             = r.IsSoldOut;
         PassengerContribution = r.PassengerContribution;
         PickUpLocation        = r.PickUpLocation;
         RideId              = r.RideId;
         Stopovers           = r.Stopovers;
         TotalAvailableSeats = r.TotalAvailableSeats;
         TravelDate          = r.TravelDate;
         Owner = new UserDTO(r.Owner);
     }
 }
Exemplo n.º 12
0
        // PUT: api/Rides/5
        public async Task PutAsync(int id, [FromBody] RideDTO ride)
        {
            Ride rideEntity = new Ride()
            {
                Id       = id,
                Rider    = ride.Rider,
                RideTime = ride.Time,
                Porpoise = new Porpoise()
                {
                    Name    = ride.Porpoise.Name,
                    Species = ride.Porpoise.Species
                }
            };

            await _rideManagementService.UpdateRideAsync(rideEntity);
        }
Exemplo n.º 13
0
        // RIDE LEGS ******************
        public async Task <Ride> AddRideLegsAsync(Ride ride, params RideLeg[] rideLegs)
        {
            foreach (RideLeg rideLeg in rideLegs)
            {
                ValidateRideLeg(rideLeg);

                // Todo: Set time and distance for each leg
                // Can reuse calculated distance for return trip if origin and distination are the same

                _uow.RideLegs.Add(rideLeg);
                ride.RideLegs.Add(rideLeg);
            }
            await _uow.SaveChangesAsync();

            return(ride);
        }
Exemplo n.º 14
0
        public async Task <decimal> GetRideCostAsync(Ride rideOffer, Ride rideRequest)
        {
            var     rideCost = rideOffer.RideCost;
            decimal cost     = rideCost.BaseCost;

            var newRide = await AddRideRequestToOfferAsync(rideOffer, rideRequest);

            var extraDistance = newRide.Distance - rideOffer.Distance;
            var extraTime     = newRide.TravelTime - rideOffer.TravelTime;

            cost += rideCost.CostPerMile * (decimal)newRide.Distance;
            cost += rideCost.PickupCostPerMile * (decimal)extraDistance;
            cost += rideCost.PickupCostPerHour * (decimal)extraTime.TotalHours;

            return(cost);
        }
Exemplo n.º 15
0
        public List <Report> GetReportsForRide(int id)
        {
            query = $"SELECT * FROM Reports WHERE RideId = '{id}'";
            var data = cDB.ExecuteQuery(query);

            Ride theRide = GetRide(id);

            return(data.Tables[0].AsEnumerable().Select(dataRow => new Report
            {
                Id = dataRow.Field <int>("Id"),
                RideReportedOn = theRide,
                Status = (StatusOptions)System.Enum.Parse(typeof(StatusOptions), dataRow.Field <string>("Status")),
                ReportTime = dataRow.Field <DateTime>("ReportTime"),
                Notes = dataRow.Field <string>("Notes")
            }).ToList());
        }
Exemplo n.º 16
0
        public IActionResult GetById(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(BadRequest());
            }

            Ride ride = this._rideServices.GetById(id);

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

            return(Ok(ride));
        }
Exemplo n.º 17
0
        private void dgRides_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            tblkBreakdownNumber.Text    = "";
            tblkCategory.Text           = "";
            tblkDaysSinceBreakdown.Text = "";
            tblkName.Text   = "";
            tblkStatus.Text = "";

            Ride r = (dgRides.SelectedItem as Ride);

            tblkName.Text               = r.Name;
            tblkStatus.Text             = r.Status.ToString();
            tblkCategory.Text           = r.Category.ToString();
            tblkBreakdownNumber.Text    = r.NumberOfShutdowns().ToString();
            tblkDaysSinceBreakdown.Text = r.DaysSinceLastShutdown().ToString();
        }
Exemplo n.º 18
0
        public List <Ride> GetRides()
        {
            Ride ride1 = new Ride {
                Hour = "17:54", Room = 3, Destination = "ראשון לציון"
            };
            Ride ride2 = new Ride {
                Hour = "18:10", Room = 2, Destination = "רעננה"
            };
            Ride ride3 = new Ride {
                Hour = "18:15", Room = 4, Destination = "נתניה"
            };

            return(new List <Ride> {
                ride1, ride2, ride3
            });
        }
Exemplo n.º 19
0
        public async Task <RideDTO> CancelRide(Ride ride)
        {
            if (ride != null && ride.RideStatus != null && ride.RideStatus.Code == Core.Constant.RideStatus.Waiting)
            {
                ride.IsActive = false;
                await this.UnitOfWork.RideRepository.Update(ride);

                await this.UnitOfWork.SaveAsync();

                return(new RideDTO(ride));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 20
0
        // GET: Ride/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Ride   ride     = db.Rides.Find(id);
            string userName = User.Identity.Name;

            ViewBag.UserName = userName;
            if (ride == null)
            {
                return(HttpNotFound());
            }
            return(View(ride));
        }
Exemplo n.º 21
0
        //Create
        public string CreateRide(Ride ride)
        {
            ride.RideType = "Truck";
            string        message    = "";
            string        connection = ConfigurationManager.ConnectionStrings["temp_transport"].ConnectionString;
            SqlConnection con        = new SqlConnection(connection);

            con.Open();
            int RideExpenses = int.Parse(ride.RideCommisionCharge.ToString())
                               + int.Parse(ride.RideDieselExpense.ToString()) + int.Parse(ride.RideDriverCharge.ToString())
                               + int.Parse(ride.RideFoodExpense.ToString()) + int.Parse(ride.RideMaintainanceExpense.ToString()) +
                               int.Parse(ride.RideMobileExpense.ToString()) + int.Parse(ride.RideTaxExpense.ToString());
            int        RideFare   = int.Parse(ride.RideFare.ToString());
            int        RideProfit = RideFare - RideExpenses;
            SqlCommand cmd        = new SqlCommand("sp_Ride_create", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@Ride_Source", ride.RideSource.ToString());
            cmd.Parameters.AddWithValue("@Ride_Destination", ride.RideDestination.ToString());
            cmd.Parameters.AddWithValue("@Ride_DieselExpenses", int.Parse(ride.RideDieselExpense.ToString()));
            cmd.Parameters.AddWithValue("@Ride_MaintainanceExpenses", int.Parse(ride.RideMaintainanceExpense.ToString()));
            cmd.Parameters.AddWithValue("@Ride_FoodExpenses", int.Parse(ride.RideFoodExpense.ToString()));
            cmd.Parameters.AddWithValue("@Ride_MobileExpenses", int.Parse(ride.RideMobileExpense.ToString()));
            cmd.Parameters.AddWithValue("@Ride_TaxExpenses", int.Parse(ride.RideTaxExpense.ToString()));
            cmd.Parameters.AddWithValue("@Ride_DriverCharges", int.Parse(ride.RideDriverCharge.ToString()));
            cmd.Parameters.AddWithValue("@Ride_CommisionCharges", int.Parse(ride.RideCommisionCharge.ToString()));
            cmd.Parameters.AddWithValue("@Ride_DieselQuantity", ride.RideDieselQuantity.ToString());
            cmd.Parameters.AddWithValue("@Ride_DriverId", int.Parse(ride.RideDriverId.ToString()));
            cmd.Parameters.AddWithValue("@Ride_VehicleNumber", ride.RideVehicleNumber.ToString());
            cmd.Parameters.AddWithValue("@Ride_ProfitLoss", RideProfit);
            cmd.Parameters.AddWithValue("@RideSeller", ride.RideSeller.ToString());
            cmd.Parameters.AddWithValue("@RideBuyer", ride.RideBuyer);
            cmd.Parameters.AddWithValue("@RideFare", RideFare);
            cmd.Parameters.AddWithValue("@RideDate", ride.RideDate.Date);
            cmd.Parameters.AddWithValue("@RideDetail", ride.RideDetail.ToString());
            cmd.Parameters.AddWithValue("@RideType", ride.RideType.ToString());
            cmd.Parameters.AddWithValue("@companyId", ride.CompanyId);
            int result = cmd.ExecuteNonQuery();

            if (result > 0)
            {
                message = "Ride Added Successfully";
                ride    = new Ride();
            }
            con.Close();
            return(message);
        }
Exemplo n.º 22
0
        public async Task UpdateAsync_WithInvalidModel_ReturnsFalse()
        {
            // Arrange
            var context = new PoolItDbContext(new DbContextOptionsBuilder <PoolItDbContext>()
                                              .UseInMemoryDatabase(Guid.NewGuid().ToString())
                                              .Options);

            var ride = new Ride
            {
                Title          = "Initial Title",
                PhoneNumber    = "0000000000",
                Notes          = "Initial Notes",
                Car            = new Car(),
                Date           = DateTime.UtcNow,
                AvailableSeats = 1,
                From           = "Test From",
                To             = "Test To"
            };

            await context.Rides.AddAsync(ride);

            await context.SaveChangesAsync();

            var ridesService = new RidesService(new EfRepository <Ride>(context), null, null, null);

            var serviceModel = new RideServiceModel()
            {
                Id             = ride.Id,
                Notes          = "Updated Notes",
                CarId          = ride.CarId,
                AvailableSeats = ride.AvailableSeats,
                From           = ride.From,
                To             = ride.To
            };

            var initialTitle = ride.Title;

            // Act
            var result = await ridesService.UpdateAsync(serviceModel);

            // Assert
            Assert.False(result);

            var dbModel = await context.Rides.SingleAsync();

            Assert.Equal(initialTitle, dbModel.Title);
        }
Exemplo n.º 23
0
        public IActionResult AdminPut(int id, [FromBody] Ride ride)
        {
            var existingRide = _Context.Rides.Find(id);

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

            existingRide.Name        = ride.Name;
            existingRide.Destination = ride.Destination;
            existingRide.Source      = ride.Source;

            _Context.SaveChanges();

            return(Ok(existingRide));
        }
        public List <Ride> AddBooking(Ride ride, Booking booking, Employee employee, Client client)
        {
            var clientDto   = DTOUtils.GetClientDto(client);
            var bookingDto  = DTOUtils.GetBookingDto(booking);
            var rideDto     = DTOUtils.GetRideDto(ride);
            var employeeDto = DTOUtils.GetEmployeeDto(employee);

            SendRequest(new BookingRequest(bookingDto, rideDto, employeeDto, clientDto));
            var response = ReadResponse();

            if (response is ErrorResponse)
            {
                throw new Exception("Error add reservation");
            }

            return(((GetRidesResponse)response).Rides.Select(DTOUtils.GetFromDto).ToList());
        }
 public int PriceEstimattion(Ride ride)
 {
     while (true)
     {
         display.Print("Distance from starting point :");
         try
         {
             ride.Destination.DistancefromStartPoint = int.Parse(display.Scan());
             break;
         }
         catch (FormatException)
         {
             display.Print("Check format of distance");
         }
     }
     return((ride.Priceperkm * ride.Destination.DistancefromStartPoint));
 }
Exemplo n.º 26
0
        public void AddRide_ReturnsFalseRideWasntAdded()
        {
            //Arrange
            Member    member    = new Member();
            BikeRoute bikeRoute = new BikeRoute();

            bikeRoute.Difficulty = Difficulty.Hard;
            Ride ride = new Ride();

            ride.Route = bikeRoute;


            //Act

            //Assert
            Assert.False(member.Add(ride));
        }
Exemplo n.º 27
0
        public void AddRide_ReturnsTrueRideWasAdded()
        {
            //Arrange
            Member    member    = new Member();
            BikeRoute bikeRoute = new BikeRoute();

            bikeRoute.Difficulty = Difficulty.Easy;
            Ride ride = new Ride();

            ride.Route = bikeRoute;


            //Act

            //Assert
            Assert.True(member.Add(ride));
        }
Exemplo n.º 28
0
        public ActionResult UpDate(Ride ride) // Ananewsh Request
        {
            var requestDB = unitOfWork.Requests.SpecificRequest(ride.RideID, User.Identity.GetUserId());
            // Epistrofh stoixeiwn diadromhs
            var rideDB = unitOfWork.Rides.GetRideInfo(ride.RideID);

            requestDB.UpDateRequest(rideDB, requestDB, ride.SelectNumberOfSeats);

            var viewModel = new RequestViewModel()
            {
                Ride    = rideDB,
                Heading = "Η Διαδρομή Ανανεώθηκε Επιτυχώς"
            };

            unitOfWork.Complete();
            return(View("SaveRequest", viewModel));
        }
Exemplo n.º 29
0
        public List <Ride> FindOfferedRides(string providerId)
        {
            List <Ride> rides            = new List <Ride>();
            string      connectionString = Configuration.ConnectionString;

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                string     sql     = $"Select * From Ride where ProviderId='{providerId}' ";
                SqlCommand command = new SqlCommand(sql, connection);
                using (SqlDataReader dataReader = command.ExecuteReader())
                {
                    while (dataReader.Read())
                    {
                        List <string> locations;
                        Ride          Ride = new Ride
                        {
                            Id = Convert.ToInt32(dataReader["Id"]),
                            NoOfOfferedSeats = Convert.ToInt32(dataReader["NoOfOfferedSeats"]),
                            StartDate        = Convert.ToDateTime(dataReader["StartDate"]),
                            UnitDistanceCost = float.Parse(Convert.ToString(dataReader["UnitDistanceCost"])),
                            VehicleId        = Convert.ToString(dataReader["VehicleId"]),
                            Time             = Convert.ToString(dataReader["Time"])
                        };
                        locations         = Convert.ToString(dataReader["locations"]).Split(",").ToList();
                        Ride.VehicleType  = VehicleDal.GetVehicleType(Ride.VehicleId);
                        Ride.ProviderName = UserDal.GetUserName(Ride.ProviderId);
                        Ride.Route        = new Route()
                        {
                            Source      = locations.First(),
                            Destination = locations.Last(),
                            ViaPoints   = new List <ViaPoint>()
                        };
                        locations.RemoveAt(0);
                        locations.RemoveAt(locations.Count - 1);
                        locations.ForEach(_ => Ride.Route.ViaPoints.Add(new ViaPoint()
                        {
                            Location = _
                        }));
                        rides.Add(Ride);
                    }
                }
                connection.Close();
            }
            return(rides);
        }
Exemplo n.º 30
0
        private Ride BuildRide(Ride ride, string driverName, Vehicle vehicle, Employee employee)
        {
            var created = new Ride
            {
                CarrierId      = ride.CarrierId,
                Id             = ride.Id,
                Comments       = ride.Comments,
                Cost           = ride.Cost,
                Distance       = ride.Distance,
                Duration       = ride.Duration,
                EndAddress     = ride.EndAddress,
                StartAddress   = ride.StartAddress,
                EndDateTime    = ride.EndDateTime,
                StartDateTime  = ride.StartDateTime,
                StartLatitude  = 10,
                EndLatitude    = 10,
                StartLongitude = 10,
                EndLongitude   = 10,
                Rating         = ride.Rating,
                RideId         = ride.RideId,
                VehicleId      = ride.VehicleId,
                Vehicle        = vehicle == null ? null : new Vehicle()
                {
                    LicensePlate = vehicle.LicensePlate,
                    Model        = vehicle.Model,
                    Picture      = vehicle.Picture,
                    Make         = vehicle.Make,
                    Rate         = vehicle.Rate
                },
                DriverId = ride.DriverId,
                Driver   = new Driver()
                {
                    DriverId = ride.DriverId,
                    Name     = driverName
                },
                EmployeeId = ride.EmployeeId,
                Employee   = employee == null ? null : new Employee()
                {
                    EmployeeId = employee.EmployeeId,
                    Picture    = employee.Picture,
                    Name       = employee.Name
                }
            };

            return(created);
        }
Exemplo n.º 31
0
        public void GetStatus_ReturnsCorrectWithOneReport()
        {
            //Assign
            Ride   ride   = new Ride();
            Report report = new Report();

            report.Status = Status.BeingRepaired;
            Status expectedStatus = Status.BeingRepaired;

            ride.AddReport(report);

            //Action
            Status actualStatus = ride.Status;

            //Assert
            Assert.Equal <Status>(expectedStatus, actualStatus);
        }
Exemplo n.º 32
0
        public void IsValidRide_ReturnsTrueWithValidRide()
        {
            Member    member = new Member();
            BikeRoute route  = new BikeRoute();

            route.Difficulty = Difficulty.Easy;
            Ride     ride = new Ride();
            DateTime date = DateTime.Today.AddDays(-10);

            ride.Member   = member;
            ride.Route    = route;
            ride.RideDate = date;

            (bool isValid, string errMsg)result = ride.IsValidRide;

            Assert.True(result.isValid, result.errMsg);
        }
        public void EditExistingDetails(int rideId, DateTime rideDate, decimal?rideDistance, decimal?rideTime, int rideAscent, int bikeId)
        {
            Ride existingRide = Entities.Rides.Where(r => r.RideID == rideId).SingleOrDefault();

            if (existingRide == null)
            {
                return;
            }

            existingRide.RideDate        = rideDate;
            existingRide.DistanceInMiles = rideDistance;
            existingRide.TimeInMinutes   = rideTime;
            existingRide.Ascent          = rideAscent;
            existingRide.BikeID          = bikeId;

            Entities.SaveChanges();
        }
Exemplo n.º 34
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Ride = await _context.Ride.FindAsync(id);

            if (Ride != null)
            {
                _context.Ride.Remove(Ride);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
        public int CreateNewEntry(DateTime rideDate, decimal?rideDistance, decimal?rideTime, int rideAscent, int bikeId)
        {
            Ride newRide = new Ride
            {
                RideDate        = rideDate,
                DistanceInMiles = rideDistance,
                TimeInMinutes   = rideTime,
                Ascent          = rideAscent,
                Bike            = BikeList.Where(b => b.BikeID == bikeId).FirstOrDefault(),
                BikeID          = bikeId
            };

            Entities.Rides.Add(newRide);
            Entities.SaveChanges();

            return(newRide.RideID);
        }
Exemplo n.º 36
0
 public static Ride CadastraRide(Ride r)
 {
     using (elmatEntities entities = new elmatEntities())
     {
         RIDE R = RideToRIDE(r);
         try
         {
             entities.RIDE.Add(R);
             entities.SaveChanges();
             r.RideID = R.RideID;
             return r;
         }
         catch (Exception e)
         {
             throw e;
         }
     }
 }
Exemplo n.º 37
0
        public bool SaveVehicleRoute(Ride.Business.Objects.Employee employee, Ride.Business.Objects.Vehicles.Vehicle vehicle, Ride.Business.Objects.Routes.Route route)
        {
            try
                {
                    using (RideWCFServiceImplementation client = GetSyncClient())
                    {

                        VehicleRoute request = new VehicleRoute();
                        SaveResponse response = null;
                        string gpsGateUser = string.Empty;
                        request.UniqueID = Guid.NewGuid().ToString();
                        request.VehicleID = vehicle.VehicleID;
                        request.VehicleIDSpecified = true;
                        if (employee == null)
                            request.PersonID = 0;
                        else
                            request.PersonID = employee.PersonID;
                        request.PersonIDSpecified = true;
                        if (route == null)
                            request.RouteID = 0;
                        else
                            request.RouteID = route.RouteID;
                        request.RouteIDSpecified = true;
                        //Only get the GPS Gate User if it is required. Otherwise, just move the vehicle/route...
                        if (Config.AppSettings.Ref.ProgramSettings.RequireGPSGateForVehicleRoute)
                        {
                            gpsGateUser = Config.AppSettings.Ref.GetGPSGateUser();
                            //If we don't have a GPS Gate User, then exit out because we dont have a user to update with
                            if (string.IsNullOrEmpty(gpsGateUser))
                                return false;
                            request.GpsGateUserName = gpsGateUser;
                            response = client.SaveVehicleRoute(_rideCredential, request);

                        }
                        else
                        {
                            response = client.MoveVehicleToRouteWithoutGPSGateUser(_rideCredential, request);
                        }
                        if (response == null)
                            return false;
                        return response.Success;

                    }
                }
                catch (System.Net.WebException ex)
                {
                    Console.Write(ex.Message);
                    return false;
                }
                catch (Exception ex)
                {

                    throw ex;
                }
        }
Exemplo n.º 38
0
        private Ride BuildRide(Ride ride, string driverName, Vehicle vehicle, Employee employee)
        {
            var created = new Ride
            {
                CarrierId = ride.CarrierId,
                Id = ride.Id,
                Comments = ride.Comments,
                Cost = ride.Cost,
                Distance = ride.Distance,
                Duration = ride.Duration,
                EndAddress = ride.EndAddress,
                StartAddress = ride.StartAddress,
                EndDateTime = ride.EndDateTime,
                StartDateTime = ride.StartDateTime,
                StartLatitude = 10,
                EndLatitude = 10,
                StartLongitude = 10,
                EndLongitude = 10,
                Rating = ride.Rating,
                RideId = ride.RideId,
                VehicleId = ride.VehicleId,
                Vehicle = vehicle == null ? null : new Vehicle()
                {
                    LicensePlate = vehicle.LicensePlate,
                    Model = vehicle.Model,
                    Picture = vehicle.Picture,
                    Make = vehicle.Make,
                    Rate = vehicle.Rate
                },
                DriverId = ride.DriverId,
                Driver = new Driver()
                {
                    DriverId = ride.DriverId,
                    Name = driverName
                },
                EmployeeId = ride.EmployeeId,
                Employee = employee == null ? null : new Employee()
                {
                    EmployeeId = employee.EmployeeId,
                    Picture = employee.Picture,
                    Name = employee.Name
                }
            };

            return created;
        }
Exemplo n.º 39
0
        private static Ride RIDEToRide(RIDE R)
        {
            Ride r = new Ride();

            r.DriverID = R.DriverID != null ? R.DriverID.Value : 0;
            r.RideID = R.RideID;
            r.usr.UserID = R.UserID;
            r.Hour = R.Hour;
            r.LatOrigem = R.LatOrg;
            r.LatDestino = R.LatDest;
            r.LonDestino = R.LonDest;
            r.LonOrigem = R.LonOrg;
            return r;
        }
Exemplo n.º 40
0
 private static RIDE RideToRIDE(Ride r)
 {
     RIDE R = new RIDE();
     R.UserID = r.usr.UserID;
     R.Hour = r.Hour;
     R.LatOrg = r.LatOrigem;
     R.LatDest = r.LatDestino;
     R.LonDest = r.LonDestino;
     R.LonOrg = r.LonOrigem;
     return R;
 }
        private static void CreateRides(int carrierId, MyShuttleContext context)
        {
            var employeeList = context.Employees.Select(e => e.EmployeeId).ToList();

            var rides = new List<Ride>();

            int rideId = 0;
            if (context.Rides.Any())
                rideId = context.Rides.Max(e => e.RideId);

            foreach (Vehicle vehicle in context.Vehicles)
            {
                var startDateTime01 = DateTime.UtcNow.AddDays(-Randomize.Next(15, 30));
                var startDateTime02 = DateTime.UtcNow.AddDays(-Randomize.Next(15, 30));
                var startDateTime03 = DateTime.UtcNow.AddDays(-Randomize.Next(0, 15));
                var startDateTime04 = DateTime.UtcNow.AddDays(-Randomize.Next(0, 15));
                var startDateTime05 = DateTime.UtcNow.AddDays(-Randomize.Next(10, 20));
                var startDateTime06 = DateTime.UtcNow.AddDays(-Randomize.Next(0, 10));


                var distance = Randomize.Next(20, 40);
                var endTime = startDateTime01.AddMinutes(3 * distance);
                var duration = distance * 3;
                var cost = distance * vehicle.Rate;

                var ride = new Ride
                {
                    RideId = rideId + 1,
                    Id = Guid.NewGuid().ToString(),
                    StartDateTime = startDateTime01,
                    EndDateTime = endTime,
                    VehicleId = vehicle.VehicleId,
                    DriverId = vehicle.DriverId,
                    Cost = cost,
                    EmployeeId = employeeList[Randomize.Next(0, employeeList.Count() - 1)],
                    Comments = string.Empty,
                    CarrierId = carrierId,
                    Distance = distance,
                    Duration = duration,
                    Rating = Randomize.Next(3, 5),
                    Signature = null,
                    StartAddress = "199 E 23rd St",
                    EndAddress = "S Michigan Ave, Chicago",
                    StartLatitude = 41.851117,
                    StartLongitude = -87.623197,
                    EndLatitude = 41.848999,
                    EndLongitude = -87.623703,
                };
                rides.Add(ride);

                distance = Randomize.Next(20, 40);
                endTime = startDateTime02.AddMinutes(3 * distance);
                duration = distance * 3;
                cost = distance * vehicle.Rate;

                ride = new Ride
                {
                    RideId = rideId + 2,
                    Id = Guid.NewGuid().ToString(),
                    StartDateTime = startDateTime02,
                    EndDateTime = endTime,
                    VehicleId = vehicle.VehicleId,
                    DriverId = vehicle.DriverId,
                    Cost = cost,
                    EmployeeId = employeeList[Randomize.Next(0, employeeList.Count() - 1)],
                    Comments = string.Empty,
                    CarrierId = carrierId,
                    Distance = distance,
                    Duration = 20,
                    Rating = Randomize.Next(3, 5),
                    Signature = null,
                    StartAddress = "199 E 23rd St",
                    EndAddress = "S Michigan Ave, Chicago",
                    StartLatitude = 41.851117,
                    StartLongitude = -87.623197,
                    EndLatitude = 41.848999,
                    EndLongitude = -87.623703,

                };
                rides.Add(ride);

                distance = Randomize.Next(20, 40);
                endTime = startDateTime03.AddMinutes(3 * distance);
                duration = distance * 3;
                cost = distance * vehicle.Rate;

                ride = new Ride
                {
                    RideId = rideId + 3,
                    Id = Guid.NewGuid().ToString(),
                    StartDateTime = startDateTime03,
                    EndDateTime = endTime,
                    VehicleId = vehicle.VehicleId,
                    DriverId = vehicle.DriverId,
                    Cost = cost,
                    EmployeeId = employeeList[Randomize.Next(0, employeeList.Count() - 1)],
                    Comments = string.Empty,
                    CarrierId = carrierId,
                    Distance = distance,
                    Duration = duration,
                    Rating = Randomize.Next(2, 5),
                    Signature = null,
                    StartAddress = "199 E 23rd St",
                    EndAddress = "S Michigan Ave, Chicago",
                    StartLatitude = 41.851117,
                    StartLongitude = -87.623197,
                    EndLatitude = 41.848999,
                    EndLongitude = -87.623703,
                };
                rides.Add(ride);

                distance = Randomize.Next(20, 40);
                endTime = startDateTime04.AddMinutes(3 * distance);
                duration = distance * 3;
                cost = distance * vehicle.Rate;
                ride = new Ride
                {
                    RideId = rideId + 4,
                    Id = Guid.NewGuid().ToString(),
                    StartDateTime = startDateTime04,
                    EndDateTime = endTime,
                    VehicleId = vehicle.VehicleId,
                    DriverId = vehicle.DriverId,
                    Cost = cost,
                    EmployeeId = employeeList[Randomize.Next(0, employeeList.Count() - 1)],
                    Comments = string.Empty,
                    CarrierId = carrierId,
                    Distance = distance,
                    Duration = duration,
                    Rating = Randomize.Next(2, 5),
                    Signature = null,
                    StartAddress = "E Cermak Rd, Chicago",
                    EndAddress = "1589 E Marquette Rd",
                    StartLatitude = 41.852798,
                    StartLongitude = -87.624329,
                    EndLatitude = 41.775157,
                    EndLongitude = 87.586632,
                };
                rides.Add(ride);

                distance = Randomize.Next(20, 40);
                endTime = startDateTime05.AddMinutes(3 * distance);
                duration = distance * 3;
                cost = distance * vehicle.Rate;
                ride = new Ride
                {
                    RideId = rideId + 5,
                    Id = Guid.NewGuid().ToString(),
                    StartDateTime = startDateTime05,
                    EndDateTime = endTime,
                    VehicleId = vehicle.VehicleId,
                    DriverId = vehicle.DriverId,
                    Cost = cost,
                    EmployeeId = employeeList[Randomize.Next(0, employeeList.Count() - 1)],
                    Comments = string.Empty,
                    CarrierId = carrierId,
                    Distance = distance,
                    Duration = duration,
                    Rating = Randomize.Next(2, 5),
                    Signature = null,
                    StartAddress = "2050 S Calumet Ave, Chicago",
                    EndAddress = "1589 E Marquette Rd",
                    StartLatitude = 41.854950,
                    StartLongitude = -87.619094,
                    EndLatitude = 41.775157,
                    EndLongitude = 87.586632,
                };
                rides.Add(ride);

                distance = Randomize.Next(20, 40);
                endTime = startDateTime06.AddMinutes(3 * distance);
                duration = distance * 3;
                cost = distance * vehicle.Rate;
                ride = new Ride
                {
                    RideId = rideId + 6,
                    Id = Guid.NewGuid().ToString(),
                    StartDateTime = startDateTime06,
                    EndDateTime = endTime,
                    VehicleId = vehicle.VehicleId,
                    DriverId = vehicle.DriverId,
                    Cost = cost,
                    EmployeeId = employeeList[Randomize.Next(0, employeeList.Count() - 1)],
                    Comments = "Great service!",
                    CarrierId = carrierId,
                    Distance = distance,
                    Duration = duration,
                    Rating = Randomize.Next(2, 5),
                    Signature = null,
                    StartAddress = "2050 S Calumet Ave, Chicago",
                    EndAddress = "1589 E Marquette Rd",
                    StartLatitude = 41.854950,
                    StartLongitude = -87.619094,
                    EndLatitude = 41.775157,
                    EndLongitude = 87.586632,
                };
                rides.Add(ride);

                rideId = rideId + 6;


            }

            context.Rides.AddRange(rides.ToArray<Ride>());
            context.SaveChanges();
        }
Exemplo n.º 42
0
        public async Task UpdateAsync(Ride ride)
        {
            _context.Rides.Update(ride);

            await _context.SaveChangesAsync();
        }
        private static void CreateRides(int carrierId, MyShuttleContext context)
        {
            var employeeList = context.Employees.Select(e => e.EmployeeId).ToList();

            var rides = new List<Ride>();

            int rideId = 0;
            if (context.Rides.Any())
                rideId = context.Rides.Max(e => e.RideId);

            foreach (Vehicle vehicle in context.Vehicles)
            {
                var startDateTime01 = DateTime.UtcNow.AddDays(-Randomize.Next(15, 30));
                var startDateTime02 = DateTime.UtcNow.AddDays(-Randomize.Next(15, 30));
                var startDateTime03 = DateTime.UtcNow.AddDays(-Randomize.Next(0, 15));
                var startDateTime04 = DateTime.UtcNow.AddDays(-Randomize.Next(0, 15));
                var startDateTime05 = DateTime.UtcNow.AddDays(-Randomize.Next(10, 20));
                var startDateTime06 = DateTime.UtcNow.AddDays(-Randomize.Next(0, 10));


                var distance = Randomize.Next(20, 40);
                var endTime = startDateTime01.AddMinutes(3 * distance);
                var duration = distance * 3;
                var cost = distance * vehicle.Rate;

                var ride = new Ride
                {
                    Id = Guid.NewGuid().ToString(),
                    StartDateTime = startDateTime01,
                    EndDateTime = endTime,
                    VehicleId = vehicle.VehicleId,
                    DriverId = vehicle.DriverId,
                    Cost = cost,
                    EmployeeId = employeeList[Randomize.Next(0, employeeList.Count() - 1)],
                    Comments = string.Empty,
                    CarrierId = carrierId,
                    Distance = distance,
                    Duration = duration,
                    Rating = Randomize.Next(3, 5),
                    Signature = null,
                    StartAddress = "Madison Ave 10037",
                    EndAddress = "217 Broadway",
                    StartLatitude = 40.721847,
                    StartLongitude = -74.007326,
                    EndLatitude = 40.721847,
                    EndLongitude = -74.007326,
                };
                rides.Add(ride);

                distance = Randomize.Next(20, 40);
                endTime = startDateTime02.AddMinutes(3 * distance);
                duration = distance * 3;
                cost = distance * vehicle.Rate;

                ride = new Ride
                {
                    Id = Guid.NewGuid().ToString(),
                    StartDateTime = startDateTime02,
                    EndDateTime = endTime,
                    VehicleId = vehicle.VehicleId,
                    DriverId = vehicle.DriverId,
                    Cost = cost,
                    EmployeeId = employeeList[Randomize.Next(0, employeeList.Count() - 1)],
                    Comments = string.Empty,
                    CarrierId = carrierId,
                    Distance = distance,
                    Duration = 20,
                    Rating = Randomize.Next(3, 5),
                    Signature = null,
                    StartAddress = "217 Broadway",
                    EndAddress = "E 156th St, Bronx",
                    StartLatitude = 40.721847,
                    StartLongitude = -74.007326,
                    EndLatitude = 40.721847,
                    EndLongitude = -74.007326,
                };
                rides.Add(ride);

                distance = Randomize.Next(20, 40);
                endTime = startDateTime03.AddMinutes(3 * distance);
                duration = distance * 3;
                cost = distance * vehicle.Rate;

                ride = new Ride
                {
                    Id = Guid.NewGuid().ToString(),
                    StartDateTime = startDateTime03,
                    EndDateTime = endTime,
                    VehicleId = vehicle.VehicleId,
                    DriverId = vehicle.DriverId,
                    Cost = cost,
                    EmployeeId = employeeList[Randomize.Next(0, employeeList.Count() - 1)],
                    Comments = string.Empty,
                    CarrierId = carrierId,
                    Distance = distance,
                    Duration = duration,
                    Rating = Randomize.Next(2, 5),
                    Signature = null,
                    StartAddress = "54 Fulton St",
                    EndAddress = "E 156th St, Bronx",
                    StartLatitude = 40.721847,
                    StartLongitude = -74.007326,
                    EndLatitude = 40.721847,
                    EndLongitude = -74.007326,
                };
                rides.Add(ride);

                distance = Randomize.Next(20, 40);
                endTime = startDateTime04.AddMinutes(3 * distance);
                duration = distance * 3;
                cost = distance * vehicle.Rate;
                ride = new Ride
                {
                    Id = Guid.NewGuid().ToString(),
                    StartDateTime = startDateTime04,
                    EndDateTime = endTime,
                    VehicleId = vehicle.VehicleId,
                    DriverId = vehicle.DriverId,
                    Cost = cost,
                    EmployeeId = employeeList[Randomize.Next(0, employeeList.Count() - 1)],
                    Comments = string.Empty,
                    CarrierId = carrierId,
                    Distance = distance,
                    Duration = duration,
                    Rating = Randomize.Next(2, 5),
                    Signature = null,
                    StartAddress = "E 156th St, Bronx",
                    EndAddress = "33 Wooster St",
                    StartLatitude = 40.721847,
                    StartLongitude = -74.007326,
                    EndLatitude = 40.721847,
                    EndLongitude = -74.007326,
                };
                rides.Add(ride);

                distance = Randomize.Next(20, 40);
                endTime = startDateTime05.AddMinutes(3 * distance);
                duration = distance * 3;
                cost = distance * vehicle.Rate;
                ride = new Ride
                {
                    Id = Guid.NewGuid().ToString(),
                    StartDateTime = startDateTime05,
                    EndDateTime = endTime,
                    VehicleId = vehicle.VehicleId,
                    DriverId = vehicle.DriverId,
                    Cost = cost,
                    EmployeeId = employeeList[Randomize.Next(0, employeeList.Count() - 1)],
                    Comments = string.Empty,
                    CarrierId = carrierId,
                    Distance = distance,
                    Duration = duration,
                    Rating = Randomize.Next(2, 5),
                    Signature = null,
                    StartAddress = "48 Wall St",
                    EndAddress = "Madison Ave 10037",
                    StartLatitude = 40.721847,
                    StartLongitude = -74.007326,
                    EndLatitude = 40.721847,
                    EndLongitude = -74.007326,
                };
                rides.Add(ride);

                distance = Randomize.Next(20, 40);
                endTime = startDateTime06.AddMinutes(3 * distance);
                duration = distance * 3;
                cost = distance * vehicle.Rate;
                ride = new Ride
                {
                    Id = Guid.NewGuid().ToString(),
                    StartDateTime = startDateTime06,
                    EndDateTime = endTime,
                    VehicleId = vehicle.VehicleId,
                    DriverId = vehicle.DriverId,
                    Cost = cost,
                    EmployeeId = employeeList[Randomize.Next(0, employeeList.Count() - 1)],
                    Comments = "Great service!",
                    CarrierId = carrierId,
                    Distance = distance,
                    Duration = duration,
                    Rating = Randomize.Next(2, 5),
                    Signature = null,
                    StartAddress = "33 Wooster St",
                    EndAddress = "48 Wall St",
                    StartLatitude = 40.721847,
                    StartLongitude = -74.007326,
                    EndLatitude = 40.721847,
                    EndLongitude = -74.007326,
                };
                rides.Add(ride);

            }

            context.Rides.AddRange(rides.ToArray<Ride>());
            context.SaveChanges();
        }