Example #1
0
        public async Task AddLocationReturnsCorrectType()
        {
            var newLocation = ModelFakes.LocationFake.Generate();

            var returnLocation = await _testLocationService.AddLocation(newLocation);

            returnLocation.Should().BeOfType <Location>();
        }
Example #2
0
        public ActionResult Create(LocationFormViewModel model)
        {
            LocationDisplaySetting locationDisplaySetting = new LocationDisplaySetting();

            if (ViewData.ModelState.IsValid)
            {
                model.UserId = UserService.GetUser(User.Identity.Name).UserID;
                var location = model.getLocationFromViewModel();

                if (model.CurrentDisplaySetting)
                {
                    if (string.IsNullOrWhiteSpace(model.DisplayName))
                    {
                        ModelState.AddModelError("", "Мора да внесете име на новиот поглед");
                        PopulateAddLocationViewModel(model);
                        return(View(model));
                    }

                    locationDisplaySetting = model.getLocationDisplaySettingFromViewModel();
                    var resultDisplay = LocationService.AddLocationDisplaySetting(locationDisplaySetting);

                    if (!resultDisplay.IsOK)
                    {
                        PopulateAddLocationViewModel(model);

                        foreach (var message in resultDisplay.Messages.Union(resultDisplay.ExceptionMessages))
                        {
                            ModelState.AddModelError("", message);
                        }

                        return(View(model));
                    }

                    location.DisplaySettings = locationDisplaySetting.ID;
                }

                var result = LocationService.AddLocation(location);

                if (result.IsOK)
                {
                    return(RedirectToAction("Details", new { id = location.ID }));
                }
                else
                {
                    PopulateAddLocationViewModel(model);

                    foreach (var message in result.Messages.Union(result.ExceptionMessages))
                    {
                        ModelState.AddModelError("", message);
                    }

                    return(View(model));
                }
            }
            else
            {
                PopulateAddLocationViewModel(model);
                return(View(model));
            }
        }
Example #3
0
 private void AddSession()
 {
     if (MessageBox.Show("Are you sure", "", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
     {
         var sessions = SessionService.GetAllSessions().Where(d => d.CourseId == SelectedCourse.Id);
         if (ScheduleConflict(sessions))
         {
             //if Session Start is within Start and End of existing session for the same course - there is a schedule conflict and the operation must not be allowed
             MessageBox.Show("Schedule Conflict");
             return;
         }
         //create location from strings
         var address = AddressService.AddAddress(new Address()
         {
             ZipCode = VenueAddress,
         });
         var location = LocationService.AddLocation(new Location()
         {
             Address  = address,
             Capacity = VenueCapacity
         });
         Session = SessionService.AddSession(Session);
         var sessionLocation = SessionLocationService.Add(new Session_Location()
         {
             Session  = Session,
             Location = location
         });
         BackProc();
     }
 }
Example #4
0
        public ApplicationLocationViewModel()
        {
            List <Location> locations = LocationService.GetLocations();

            foreach (Location l in locations)
            {
                Locations.Add(new LocationModel(l));
            }

            Locations.CollectionChanged += (o, e) =>
            {
                if (e.Action.ToString().Equals("Add"))
                {
                    LocationModel locationModel = null;
                    foreach (LocationModel lm in e.NewItems)
                    {
                        locationModel = lm;
                    }

                    LocationService.AddLocation(locationModel.Location);
                }
                else if (e.Action.ToString().Equals("Remove"))
                {
                    LocationModel locationModel = null;
                    foreach (LocationModel lm in e.OldItems)
                    {
                        locationModel = lm;
                    }

                    LocationService.RemoveLocation(locationModel.Location);
                }
                OnPropertyChanged("Locations");
            };
        }
        public override async Task OnAddButtonClick(CancellationToken token)
        {
            if (!await ValidateLocation(token))
            {
                RunOnUiThread(() =>
                {
                    AddButton.Enabled = true;
                });

                return;
            }

            var result = await LocationService.AddLocation(Entity, token);

            if (result.Error.Any())
            {
                RunOnUiThread(() =>
                {
                    ShowToastMessage(Resource.String.ErrorOccurred);
                    AddButton.Enabled = true;
                });

                return;
            }

            RunOnUiThread(() =>
            {
                NavigationManager.GoToLocations();
            });
        }
        private async void OnTimedEvent(Object source, ElapsedEventArgs e)
        {
            LocationUpdateTimer.Stop();
            try
            {
                Location Newlocation = await locationService.GetCurrentLocation();

                if (Newlocation != LastKnownlocation)
                {
                    LastKnownlocation = Newlocation;
                }
                if (await locationService.AddLocation(ParseLastKnownLocation()) != null)
                {
                }
            }
            catch (Exception ex) {
                await DisplayAlert("ex location service", ex.Message + ex.InnerException, "ok");
            }
            if (Device.RuntimePlatform == Device.Android)
            {
                try
                {
                    if (Application.Current.Properties.ContainsKey("UserID"))
                    {
                        if (await userService.CheckIfCurrentUserRoleIsCourier(Convert.ToInt32(Application.Current.Properties["UserID"])))
                        {
                            var list = await deliveryService.GetUncofirmedForCourier();

                            if (list.Count() > 0)
                            {
                                notificationNumber++;
                                string title   = $"Local Notification #{notificationNumber} BaraBara";
                                string message = $"You have now received {notificationNumber} notifications!" + Environment.NewLine + "Stigla nova dostava.";
                                notificationManager.ScheduleNotification(title, message);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    await DisplayAlert("ex notification service", ex.Message + ex.InnerException, "ok");
                }
            }
            LocationUpdateTimer.Start();
        }
Example #7
0
 public IActionResult AddLocation([FromForm] AddLocationViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest());
     }
     locationService.AddLocation(model.City, model.Country, model.Address, model.OrchestraId);
     return(Redirect(Url.Action("Index", "Locations")));
 }
        public IActionResult NewLocation([FromBody] Location newLocation)
        {
            Location addedLocation = locationService.AddLocation(newLocation);

            if (addedLocation == null)
            {
                return(BadRequest());
            }
            return(Ok(newLocation));
        }
        private async void OnTimedEvent(Object source, System.Timers.ElapsedEventArgs e)
        {
            Location Newlocation = await locationService.GetCurrentLocation();

            if (Newlocation != LastKnownlocation)
            {
                LastKnownlocation = Newlocation;
                if (await locationService.AddLocation(ParseLastKnownLocation()) != null)
                {
                    try
                    {
                        await locationService.AddLocation(ParseLastKnownLocation());
                        await DisplayAlert("Location update", "Location sent to server.", "ok");
                    }
                    catch (Exception ex) { throw ex; }
                }
            }
            else
            {
                await DisplayAlert("Location", "Location stayed asame", "ok");
            }
        }
Example #10
0
        public void OnLocationChanged(Location location)
        {
            var intent = new Intent("testAction");

            intent.PutExtra("x", $"{DateTime.Now.ToString("HH:mm:ss")} - location set");
            //_localBroadcastManager.SendBroadcast(intent);

            _locationService.AddLocation(location);

            _locationUploaderService.UploadLocations();

            Task.Run(() =>
            {
                var model = new LocationChangedModel(location);
                var json  = JsonConvert.SerializeObject(model);

                var intent = new Intent("LocationChanged");
                intent.PutExtra("Location", json);

                _localBroadcastManager.SendBroadcast(intent);
            });

            var settings = _settingsService.GetSettings();

            if (!settings.IsTelegramUploadEnabled)
            {
                return;
            }

            Task.Run(() =>
            {
                try
                {
                    _telegramClient.SendLocation(location.Latitude, location.Longitude);

                    var intentTelegram = new Intent("testAction");
                    intentTelegram.PutExtra("x", $"{DateTime.Now.ToString("HH:mm:ss")} - location sent in Telegram");
                    //_localBroadcastManager.SendBroadcast(intentTelegram);
                }
                catch (Exception ex)
                {
                    var intentTelegram = new Intent("testAction");
                    intentTelegram.PutExtra("x", $"{DateTime.Now.ToString("HH:mm:ss")} - location sending in Telegram failed");
                    _localBroadcastManager.SendBroadcast(intentTelegram);

                    throw;
                }
            });
        }
Example #11
0
        private void AddSessionAndLocation()
        {
            var randomCourse  = CourseService.GetAllCourses()[random.Next(100)];
            var randomAddress = AddressService.GetAllAdresses()[random.Next(100)];
            var newLocation   = LocationService.AddLocation(new Location()
            {
                Address = randomAddress,
            });
            var addedSession = new Session()
            {
                Course = randomCourse
            };

            SessionService.AddSession(addedSession);
            SessionLocationService.Add(new Session_Location()
            {
                Session  = addedSession,
                Location = newLocation
            });
        }
        //private async Task<bool> AddLocationToSqlite(LocationModel lm)
        //{
        //    try
        //    {
        //        int x = await _connection.InsertAsync(lm);
        //        if (x > 0)
        //            return true;
        //        else return false;
        //    }
        //    catch (Exception ex)
        //    {
        //        await DisplayAlert("Error",ex.Message+ex.InnerException,"ok");
        //        return false;
        //    }

        //}
        private async Task <bool> AddLocationToAddress()
        {
            if (SelectedLocation != null)
            {
                try
                {
                    LocationModel l = new LocationModel()
                    {
                        Latitude  = SelectedLocation.Latitude,
                        Longitude = SelectedLocation.Longitude,
                        DToffSet  = DateTimeOffset.Now,
                        UserID    = Convert.ToInt32(Application.Current.Properties["UserID"])
                    };

                    try { l.Altitude = Convert.ToDouble(SelectedLocation.Altitude); }
                    catch { l.Altitude = 0; }
                    var locationFromDb = await locationService.AddLocation(l);

                    if (SenderReciver)
                    {
                        Application.Current.Properties.Add("StartLocationID", locationFromDb.LocationID);
                    }
                    else
                    {
                        Application.Current.Properties.Add("EndLocationID", locationFromDb.LocationID);
                    }
                    //if (await AddLocationToSqlite(locationFromDb))
                    return(true);
                }
                catch (Exception ex)
                {
                    await DisplayAlert("error", "msg: " + ex.Message + "IE : " + ex.InnerException, "ok");

                    return(false);
                }
            }
            else
            {
                return(true);
            }
        }
        public void WhenAddressDoesNotExist_ItShouldBeAdded()
        {
            // Arrange
            var geocodeServiceMock = new Mock <IGeocodeService>();

            geocodeServiceMock.Setup(m => m.GeocodeAddress(It.IsAny <String>(), It.IsAny <String>(), It.IsAny <String>()))
            .Returns(FIELD_MUSEUM);

            var locationRepositoryMock = new Mock <ILocationRepository>();

            locationRepositoryMock.Setup(m => m.ContainsAddress(It.IsAny <String>()))
            .Returns(false);

            LocationService service = new LocationService(geocodeServiceMock.Object, locationRepositoryMock.Object);

            // Act
            service.AddLocation("Field Museum", "1400 S Lakeshore", "Chicago", "IL");


            // Assert
            locationRepositoryMock.Verify(m => m.AddLocation(It.IsAny <Location>()), Times.Once);
        }
Example #14
0
        static void Main(string[] args)
        {
            DbClient client              = new DbClient(new MongoClient());
            var      citizenService      = new CitizenService(Client);
            var      municipalityService = new MunicipalityService(Client);
            var      locationService     = new LocationService(Client, municipalityService);
            var      testCenterService   = new TestCenterService(Client);
            var      testService         = new TestService(Client);

            bool run = true;

            while (run)
            {
                Console.WriteLine("[A] Add new Citizen");
                Console.WriteLine("[B] Add new TestCenter and TestCenterManagement");
                Console.WriteLine("[C] Add new Test");
                Console.WriteLine("[D] Add Test to all Citizens");
                Console.WriteLine("[E] Add new Location");
                Console.WriteLine("[F] Add Locations to all Citizens");
                Console.WriteLine("[G] Seed data");
                Console.WriteLine("[H] View active cases for Municipalities");
                Console.WriteLine("[I] View active cases by Sex");
                Console.WriteLine("[J] View active cases by Age");
                Console.WriteLine("[K] View possible cases by Location three days prior");
                Console.WriteLine("[X] Quit");
                Console.WriteLine("INPUT: ");

                var userInput = Console.ReadKey();

                switch (userInput.KeyChar)
                {
                case 'A':
                {
                    Console.Write("Firstname: ");
                    string firstname = Console.ReadLine();
                    Console.Write("Lastname: ");
                    string lastname = Console.ReadLine();
                    Console.Write("SSN (XXXXXX-XXXX): ");
                    string ssn = Console.ReadLine();
                    Console.Write("Age: ");
                    string age = Console.ReadLine();
                    Console.Write("Sex: ");
                    string sex = Console.ReadLine();
                    Console.Write("Municipality: ");
                    string municipalityName = Console.ReadLine();

                    int municipalityId = municipalityService.GetId(municipalityName);

                    var newCitizen = new Citizen
                    {
                        Firstname       = firstname,
                        Lastname        = lastname,
                        SSN             = ssn,
                        Age             = int.Parse(age),
                        Sex             = sex,
                        Tests           = new List <Test>(),
                        Location_id     = new List <int>(),
                        Municipality_id = municipalityId
                    };

                    citizenService.AddCitizen(newCitizen);
                }
                break;

                case 'B':
                {
                    Console.Write("Municipality: ");
                    string municipalityName = Console.ReadLine();
                    Console.Write("Hours: ");
                    int hours = int.Parse(Console.ReadLine());
                    Console.Write("Phonenumber: ");
                    int phonenumber = int.Parse(Console.ReadLine());
                    Console.Write("Email: ");
                    string email = Console.ReadLine();

                    testCenterService.AddTestCenter(municipalityName, hours, phonenumber, email);
                }
                break;

                case 'C':
                {
                    Console.Write("Citizen-ID: ");
                    int citizenId = int.Parse(Console.ReadLine());
                    Console.Write("TestCenter-ID: ");
                    int testCenterId = int.Parse(Console.ReadLine());

                    if (Client.TestCenters.Find(t => t.TestCenterId == testCenterId).Any())
                    {
                        Console.WriteLine("No TestCenter with ID {0} exists.", testCenterId);
                        break;
                    }
                    else if (Client.Citizens.Find(c => c.CitizenId == citizenId).Any())
                    {
                        Console.WriteLine("No Citizen with ID {0} exists.", citizenId);
                        break;
                    }

                    testService.TestCitizen(citizenId, testCenterId);
                }
                break;

                case 'D':
                {
                    testService.TestAllCitizens();
                    Console.WriteLine("All citizens tested.");
                }
                break;

                case 'E':
                {
                    Console.Write("Citizen-ID: ");
                    int citizenId = int.Parse(Console.ReadLine());
                    Console.Write("Address: ");
                    string address = Console.ReadLine();
                    Console.Write("Zip: ");
                    int zip = int.Parse(Console.ReadLine());
                    Console.Write("Municipality name: ");
                    string municipalityName = Console.ReadLine();

                    locationService.AddLocation(citizenId, address, zip, municipalityName);
                }
                break;

                case 'F':
                {
                    locationService.AddLocationToAllCitizen();
                    Console.WriteLine("All Citizen have now locations");
                }
                break;

                case 'G':
                {
                    Console.WriteLine("Sure you want to seed? Seeding will reset all Citizens and Municipalities[Y/N]");
                    string userKey = Console.ReadLine();

                    if (userKey.Contains('Y'))
                    {
                        Seed();
                        Console.WriteLine("Seeding done!");
                    }
                    else
                    {
                        Console.WriteLine("Seeding canceled.");
                    }
                }
                break;

                case 'H':
                {
                    testCenterService.ActiveCovidCasesPerMunicipality();
                }
                break;

                case 'I':
                {
                    testCenterService.ActiveCovidCasesSex();
                }
                break;

                case 'J':
                {
                    Console.Write("Min age: ");
                    int minAge = int.Parse(Console.ReadLine());
                    Console.Write("Max age: ");
                    int maxAge = int.Parse(Console.ReadLine());
                    int cases  = testCenterService.ActiveCovidCasesAge(minAge, maxAge);
                    Console.WriteLine("Total number of cases: {0}", cases);
                }
                break;

                case 'K':
                {
                    Console.Write("Infected citizen's ID: ");
                    int            citizenId = int.Parse(Console.ReadLine());
                    List <Citizen> citizens  = citizenService.CitizensAtSameLocation(citizenId);
                    Console.WriteLine("Citizens which has been the at the same location as an infected: ");
                    foreach (var citizen in citizens)
                    {
                        Console.WriteLine("-------------------------------------------------------");
                        Console.WriteLine($"ID: {citizen.CitizenId}");
                        Console.WriteLine($"Name: {citizen.Firstname} {citizen.Lastname}");
                        Console.WriteLine($"SSN : {citizen.SSN}");
                        Console.WriteLine("-------------------------------------------------------");
                    }
                }
                break;

                case 'X':
                    run = false;
                    break;
                }

                Console.WriteLine("\nPress any key.");
                Console.ReadKey();
                Console.Clear();
            }
        }
        public async void FinishAction(object sender, EventArgs e)
        {
            var mi = ((MenuItem)sender);

            try
            {
                if (int.TryParse(mi.CommandParameter.ToString(), out int IDint))
                {
                    DeliveryModel selectedDelivery = listOfDeliveries.Where(x => x.DeliveryID == IDint).First();
                    if (selectedDelivery != null)
                    {
                        selectedDelivery.DeliveryStatus = 4;
                        Xamarin.Essentials.Location l = await locationService.GetCurrentLocation();

                        if (l != null)
                        {
                            LocationModel lm = new LocationModel()
                            {
                                Latitude = l.Latitude, Longitude = l.Longitude, Altitude = Convert.ToDouble(l.Altitude.ToString()), UserID = Convert.ToInt32(Application.Current.Properties["UserID"].ToString()), DToffSet = l.Timestamp
                            };

                            LocationModel lmReturned = await locationService.AddLocation(lm);

                            if (lmReturned.LocationID > 1)
                            {
                                FullAddressModel endAddress = await addressService.GetAddressByIDAsync(selectedDelivery.EndAddressID);

                                endAddress.LocationID = lmReturned.LocationID;
                            }
                            selectedDelivery.EndTime = DateTime.Now;
                            var response = await deliveryService.EditDelivery(selectedDelivery);

                            if (response != null)
                            {
                                await DisplayAlert("Succses", "Delivery finished.", "ok");
                            }
                            else
                            {
                                await DisplayAlert("Delivery confimation failed.", " Try again. Check internet connection.", "ok");
                            }
                        }
                        else
                        {
                            await DisplayAlert("Location Error.", "Please enable location service on device.", "ok");
                        }
                    }
                    else
                    {
                        await DisplayAlert("Delivery confimation failed.", " Try again.", "ok");
                    }
                }
                else
                {
                    await DisplayAlert("Delivery confimation failed.", " Try again. Check internet connection.", "ok");
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Delivery confimation failed.", " Try again. Check internet connection. Error : " + ex.Message + ex.InnerException, "ok");
            }
        }
Example #16
0
        public static void Presentation()
        {
            DatabaseService     DatabaseService     = new DatabaseService();
            UserService         UserService         = new UserService();
            BookingService      BookingService      = new BookingService();
            OfferService        OfferService        = new OfferService();
            OfferRequestService OfferRequestService = new OfferRequestService();
            PaymentService      PaymentService      = new PaymentService();
            LocationService     LocationService     = new LocationService();

            DatabaseService.MoveDataToJson();
            DatabaseService.GetDataFromJson();
            LocationService.AddLocation("MIYAPUR", 17.512510, 78.352226);
            LocationService.AddLocation("MADHAPUR", 17.448294, 78.391487);
            LocationService.AddLocation("KOTI", 17.385042, 78.485753);
            LocationService.AddLocation("AMEERPET", 17.437462, 78.448288);
            LocationService.AddLocation("JUBILEE HILLS", 17.426161, 78.412537);
            LocationService.AddLocation("HITECH CITY", 17.445190, 78.385117);
            LocationService.AddLocation("LINGAMPALLY", 17.487400, 78.314453);
            LocationService.AddLocation("DILSUKHNAGAR", 17.361718, 78.525805);
            LocationService.AddLocation("LB NAGAR", 17.352533, 78.555088);
            LocationService.AddLocation("BACHUPALLY", 17.526719, 78.354426);


            while (true)
            {
Login:
                Console.WriteLine("1 -> SignUp\n2 -> SignIn\n0 -> Exit");

                IEnums.CarPoolOptions Option = (IEnums.CarPoolOptions)Convert.ToInt32(Console.ReadLine());
                switch (Option)
                {
                case IEnums.CarPoolOptions.SignUp:
                {
                    Console.WriteLine("enter name:");
                    string Name = Console.ReadLine();
                    Console.WriteLine("enter Password:"******"Name: " + NewUser.Name);
                    Console.WriteLine("UserId: " + NewUser.UserId);
                    Console.WriteLine("Account Created Successfully!!");
                    break;
                }

                case IEnums.CarPoolOptions.SignIn:
                {
                    Console.WriteLine("enter UserId:");
                    string UserId = Console.ReadLine();
                    Console.WriteLine("enter Password:"******"Your Booking Status: " + Booking.Status);
                                if (Booking.Status.Equals(IEnums.BookingStatus.Confirmed))
                                {
                                    Offer Offer = OfferService.GetDriverDetails(Booking.RiderId);
                                    Console.WriteLine("Drivername: " + Offer.DriverName + ", VehicleNumber: " + Offer.VehicleRegNumber + ", VehicleModel: " + Offer.VehicleModel);
                                }
                                Console.ReadKey();
                                Console.WriteLine("1 -> Book a Ride\n5 -> Display bookings history\n6 -> Display created offers history\n7 -> Cancel Ride\n10 -> Pay\n11 -> Add money to wallet\n" +
                                                  "13 -> wallet Balance\n14 -> display payment History\n0 -> Logout");
                            }
                            else if (OfferService.AnyActiveOffer(UserId))
                            {
                                Console.WriteLine("4 -> Display Offer requests\n5 -> Display bookings history\n" +
                                                  "6 -> Display offers history\n8 -> Cancel Offer\n9 -> End Ride\n15 -> End Offer\n10 -> Pay\n11 -> Add money to wallet\n" +
                                                  "13 -> wallet Balance\n14 -> display payment History\n0 -> Logout");
                            }
                            else
                            {
                                Console.WriteLine("1 -> Book a Ride\n2 -> Offer a Ride\n5 -> Display booking history\n" +
                                                  "6 -> Display offers history\n10 -> Pay\n11 -> Add money to wallet\n" +
                                                  "13 -> wallet Balance\n14 -> display payment History\n0 -> Logout");
                            }

                            IEnums.UserOptions UserOption = (IEnums.UserOptions)Convert.ToInt32(Console.ReadLine());
                            switch (UserOption)
                            {
                            case IEnums.UserOptions.BookARide:
                            {
                                if (PaymentService.IsEligibleToBook(UserId))
                                {
                                    Console.WriteLine("enter pick-up location:");
                                    string   PickUpLocation = Console.ReadLine();
                                    Location FromLocation   = LocationService.GetLocation(PickUpLocation.ToUpper());
                                    if (FromLocation != null)
                                    {
                                        Console.WriteLine("enter Destination:");
                                        string   Destination = Console.ReadLine();
                                        Location ToLocation  = LocationService.GetLocation(Destination.ToUpper());
                                        if (ToLocation != null)
                                        {
                                            Console.WriteLine("number of passengers:");
                                            int          NumberOfPassengers = Convert.ToInt32(Console.ReadLine());
                                            List <Offer> ActiveOffers       = OfferService.GetActiveOffers(FromLocation, ToLocation, NumberOfPassengers);
                                            if (ActiveOffers.Count == 0)
                                            {
                                                Console.WriteLine("no active offers");
                                            }
                                            else
                                            {
                                                foreach (var offer in ActiveOffers)
                                                {
                                                    Console.WriteLine("Drivername: " + offer.DriverName + " RiderId " + offer.RiderId + " Vehicle Number: " + offer.VehicleRegNumber + " Vehicle Model: " + offer.VehicleModel + " Phone Number: " + offer.PhoneNumber);
                                                }
                                                Console.WriteLine("enter Riders userId to select the offer\nRider UserId:");
                                                string RiderId = Console.ReadLine();
                                                OfferRequestService.SendRideRequest(FromLocation, ToLocation, NumberOfPassengers, RiderId.ToUpper(), UserId.ToUpper());
                                                Booking NewBooking = BookingService.CreateBooking(RiderId, UserId, FromLocation, ToLocation, NumberOfPassengers);
                                            }
                                        }
                                        else
                                        {
                                            Console.WriteLine(Destination + " not found");
                                        }
                                    }
                                    else
                                    {
                                        Console.WriteLine(PickUpLocation + " not found");
                                    }
                                }
                                else
                                {
                                    Console.WriteLine("pay your pending dues to book for next ride");
                                    Console.WriteLine("do you want to pay now?");
                                    Console.WriteLine("1 -> paynow\n2 -> later");
                                    IEnums.PaymentDecision Decision = (IEnums.PaymentDecision)Convert.ToInt32(Console.ReadLine());
                                    if (Decision.Equals(IEnums.PaymentDecision.Now))
                                    {
                                        List <Payment> PaymentDues = PaymentService.GetPendingDues(UserId);
                                        foreach (var payment in PaymentDues)
                                        {
                                            Console.WriteLine("BookingId: " + payment.PaymentID + ", amount to be paid: " + payment.Fair);
                                        }
                                        Console.WriteLine("enter paymentId: ");
                                        string PaymentId = Console.ReadLine();
                                        if (PaymentService.Pay(PaymentId))
                                        {
                                            Console.WriteLine("payment done successfully!!");
                                        }
                                        else
                                        {
                                            Console.WriteLine("insufficient wallet balance");
                                            Console.WriteLine("Do you want to add money to the wallet?");
                                            Console.WriteLine("1 -> yes\n2 -> no");
                                            IEnums.YesOrNo Choice = (IEnums.YesOrNo)Convert.ToInt32(Console.ReadLine());
                                            if (Choice.Equals(IEnums.YesOrNo.Yes))
                                            {
                                                Console.WriteLine("enter amount: ");
                                                double Amount = Convert.ToDouble(Console.ReadLine());
                                                UserService.AddMoneyToWallet(Amount, UserId);
                                                Console.WriteLine("Money added successfully!!");
                                            }
                                        }
                                    }
                                }
                                break;
                            }

                            case IEnums.UserOptions.OfferARide:
                            {
                                Console.WriteLine("enter name:");
                                string Name = Console.ReadLine();
                                Console.WriteLine("enter From location:");
                                string   FromLocation = Console.ReadLine();
                                Location StartPoint   = LocationService.GetLocation(FromLocation.ToUpper());
                                if (StartPoint != null)
                                {
                                    Console.WriteLine("enter To location:");
                                    string   ToLocation = Console.ReadLine();
                                    Location EndPoint   = LocationService.GetLocation(ToLocation.ToUpper());
                                    if (EndPoint != null)
                                    {
                                        Console.WriteLine("enter Availability");
                                        int Availability = Convert.ToInt32(Console.ReadLine());
                                        Console.WriteLine("enter Vehicle Number");
                                        string VehicleNumber = Console.ReadLine();
                                        Console.WriteLine("enter Vehicle Model");
                                        string VehicleModel = Console.ReadLine();
                                        if (OfferService.VehicleVerification(VehicleNumber))
                                        {
                                            Offer           Offer     = OfferService.CreateOffer(Name.ToUpper(), UserId, StartPoint, EndPoint, Availability, VehicleNumber.ToUpper(), VehicleModel.ToUpper());
                                            List <Location> ViaPoints = LocationService.GetViaPoints(StartPoint, EndPoint);
                                            if (ViaPoints.Count != 0)
                                            {
                                                Offer.ViaPoints.Add(StartPoint);
                                                int SelectViaPoint = 0;
                                                do
                                                {
                                                    Console.WriteLine("you might touch these locations: ");
                                                    foreach (var location in ViaPoints)
                                                    {
                                                        Console.WriteLine(location.Index + " -> " + location.Name);
                                                    }
                                                    Console.WriteLine("0 -> end");
                                                    Console.WriteLine("selects the locations: ");
                                                    SelectViaPoint = Convert.ToInt32(Console.ReadLine());
                                                    IEnums.LocationIndex LocationIndex = (IEnums.LocationIndex)SelectViaPoint;
                                                    OfferService.AddViaPoint(Offer, LocationIndex);
                                                } while (SelectViaPoint != 0);
                                                Offer.ViaPoints.Add(EndPoint);
                                                Console.WriteLine("offer created successfully!!");
                                            }
                                            else
                                            {
                                                Console.WriteLine("Cannot use same vehicle for two offers");
                                            }
                                        }
                                    }
                                    else
                                    {
                                        Console.WriteLine(ToLocation + " not found");
                                    }
                                }
                                else
                                {
                                    Console.WriteLine(FromLocation + " not found");
                                }
                                break;
                            }

                            case IEnums.UserOptions.DisplayCurrentBookingStatus:
                            {
                                Booking Booking = BookingService.ViewBookingStatus(UserId);
                                if (Booking != null)
                                {
                                    Console.WriteLine("Rider: " + Booking.RiderId + " From " + Booking.FromLocation + " To " + Booking.ToLocation + " Status " + Booking.Status);
                                }
                                else
                                {
                                    Console.WriteLine("you have no current bookings");
                                }
                                break;
                            }

                            case IEnums.UserOptions.DisplayOfferRequests:
                            {
                                if (OfferRequestService.AnyOfferRequest(UserId))
                                {
                                    List <OfferRequest> OfferRequests = OfferRequestService.GetOfferRequests(UserId);
                                    foreach (var offerRequest in OfferRequests)
                                    {
                                        Console.WriteLine("RequestId: " + offerRequest.RequestId + " from " + offerRequest.FromLocation + " to " + offerRequest.ToLocation);
                                    }
                                    Console.WriteLine("enter the RequestId to accept or reject offer request");
                                    string RequestId = Console.ReadLine();
                                    Console.WriteLine("1 -> Accept offer\n2 -> reject offer");
                                    IEnums.Decisions Decision = (IEnums.Decisions)Convert.ToInt32(Console.ReadLine());
                                    OfferRequestService.OfferRequestApproval(RequestId.ToUpper(), Decision);
                                }
                                else
                                {
                                    Console.WriteLine("no offers requests to display");
                                }
                                break;
                            }

                            case IEnums.UserOptions.DisplayBookingHistory:
                            {
                                List <Booking> AllBookings = BookingService.GetBookingsHistory(UserId);
                                if (AllBookings != null)
                                {
                                    foreach (var booking in AllBookings)
                                    {
                                        Console.WriteLine("From: " + booking.FromLocation.Name + " to " + booking.ToLocation.Name + " Status: " + booking.Status);
                                    }
                                }
                                else
                                {
                                    Console.WriteLine("no bookings to display");
                                }
                                break;
                            }

                            case IEnums.UserOptions.DisplayOfferHistory:
                            {
                                List <Offer> AllOffers = OfferService.GetOffersHistory(UserId);
                                if (AllOffers != null)
                                {
                                    foreach (var offer in AllOffers)
                                    {
                                        Console.WriteLine("From: " + offer.FromLocation.Name + " to " + offer.ToLocation.Name + " Status: " + offer.Status);
                                    }
                                }
                                else
                                {
                                    Console.WriteLine("no offers to display");
                                }
                                break;
                            }

                            case IEnums.UserOptions.CancelRide:
                            {
                                List <Booking> ActiveBookings = BookingService.GetActiveBookings(UserId);
                                if (ActiveBookings != null)
                                {
                                    foreach (var booking in ActiveBookings)
                                    {
                                        Console.WriteLine("RiderId: " + booking.RiderId + " From " + booking.FromLocation.Name + " to " + booking.ToLocation.Name + " Status: " + booking.Status);
                                    }
                                    Console.WriteLine("enter RiderId to cancel: ");
                                    string RiderId = Console.ReadLine();
                                    BookingService.CancelRide(RiderId);
                                    Console.WriteLine("Ride Cancelled");
                                }
                                else
                                {
                                    Console.WriteLine("no active bookings to cancel");
                                }
                                break;
                            }

                            case IEnums.UserOptions.CancelOffer:
                            {
                                OfferService.CancelOffer(UserId);
                                Console.WriteLine("Offer Cancelled");
                                break;
                            }

                            case IEnums.UserOptions.EndRide:
                            {
                                List <string> PassengersInVehicle = BookingService.GetPassengersInVehicle(UserId);
                                foreach (var Passenger in PassengersInVehicle)
                                {
                                    Console.WriteLine("RideeId: " + Passenger);
                                }
                                Console.WriteLine("enter ridee Id");
                                string RideeId = Console.ReadLine();
                                BookingService.EndRide(UserId, RideeId);
                                break;
                            }

                            case IEnums.UserOptions.Pay:
                            {
                                List <Payment> PendingPayments = PaymentService.GetPendingDues(UserId);
                                if (PendingPayments.Count != 0)
                                {
                                    foreach (var payment in PendingPayments)
                                    {
                                        Console.WriteLine("PaymentId: " + payment.PaymentID + ", Fair: " + payment.Fair);
                                    }
                                    Console.WriteLine("enter paymentId: ");
                                    string PaymentId = Console.ReadLine();
                                    if (PaymentService.Pay(PaymentId))
                                    {
                                        Console.WriteLine("payment done successfully!!");
                                    }
                                    else
                                    {
                                        Console.WriteLine("insufficient wallet balance");
                                        Console.WriteLine("Do you want to add money to the wallet?");
                                        Console.WriteLine("1 -> yes\n2 -> no");
                                        IEnums.YesOrNo Choice = (IEnums.YesOrNo)Convert.ToInt32(Console.ReadLine());
                                        if (Choice.Equals(IEnums.YesOrNo.Yes))
                                        {
                                            Console.WriteLine("enter amount: ");
                                            double Amount = Convert.ToDouble(Console.ReadLine());
                                            UserService.AddMoneyToWallet(Amount, UserId);
                                            Console.WriteLine("Money added successfully!!");
                                        }
                                    }
                                }
                                else
                                {
                                    Console.WriteLine("no pending dues");
                                }
                                break;
                            }

                            case IEnums.UserOptions.AddMoneyToWallet:
                            {
                                Console.WriteLine("enter amount: ");
                                double Amount = Convert.ToDouble(Console.ReadLine());
                                UserService.AddMoneyToWallet(Amount, UserId);
                                Console.WriteLine("Money added successfully!!");
                                break;
                            }

                            case IEnums.UserOptions.WalletBalance:
                            {
                                Console.WriteLine("your wallet balance: " + UserService.GetWalletBalance(UserId));
                                break;
                            }

                            case IEnums.UserOptions.DisplayPaymentHistory:
                            {
                                List <Payment> AllPayments = PaymentService.GetPaymentHistory(UserId);
                                if (AllPayments.Count != 0)
                                {
                                    foreach (var payment in AllPayments)
                                    {
                                        if (payment.RideeId.Equals(UserId))
                                        {
                                            Console.WriteLine("PaymentId: " + payment.PaymentID + " to " + payment.RiderId + " Status: " + payment.Status);
                                        }
                                        else if (payment.RiderId.Equals(UserId))
                                        {
                                            Console.WriteLine("PaymentId: " + payment.PaymentID + " from " + payment.RideeId + " Status: " + payment.Status);
                                        }
                                    }
                                }
                                else
                                {
                                    Console.WriteLine("you have no payments to display");
                                }
                                break;
                            }

                            case IEnums.UserOptions.Logout:
                            {
                                goto Login;
                            }
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("Incorrect userId or password");
                    }
                    break;
                }

                case IEnums.CarPoolOptions.Exit:
                {
                    System.Environment.Exit(0);
                    break;
                }
                }

                DatabaseService.MoveDataToJson();
            }
        }