public async Task Initialization()
        {
            var customerID = await _serviceCustomer.GetById <Data.Model.Customer>(APIService.CustomerId);

            customer = customerID;

            var request = new BookingSearchRequest
            {
                CustomerID = customer.CustomerId
            };

            BookingList.Clear();
            var list = await _serviceBooking.Get <List <Data.Model.Booking> >(request);

            foreach (var item in list)
            {
                if (item.CommentStatus == false && item.EndDate.Date <= DateTime.Now.Date)
                {
                    BookingList.Add(item);
                }
            }
            if (BookingList.Count == 0)
            {
                await Application.Current.MainPage.DisplayAlert("Warning", "The list is empty. You can leave a comment on the reserved vehicle after the reservation expires or you have not booked yet. Please, try again later.", "OK");
            }
        }
        public IEnumerable <BookingSearchResponse> Search(BookingSearchRequest req)
        {
            var result = from eachFlight in _dbCtx.Flights.AsNoTracking()
                         join eachBooking in _dbCtx.Bookings.AsNoTracking() on eachFlight.Id equals eachBooking.FlightId
                         join eachFromCity in _dbCtx.Cities.AsNoTracking() on eachFlight.DepartingCityId equals eachFromCity.Id
                         join eachToCity in _dbCtx.Cities.AsNoTracking() on eachFlight.ArrivalCityId equals eachToCity.Id
                         join eachPassenger in _dbCtx.Passengers.AsNoTracking() on eachBooking.PassengerId equals eachPassenger.Id
                         where (string.IsNullOrEmpty(req.DepartureCity) || eachFromCity.CityName == req.DepartureCity) &&
                         (string.IsNullOrEmpty(req.ArrivalCity) || eachToCity.CityName == req.ArrivalCity) &&
                         (!req.TravelDate.HasValue || eachBooking.TravelDay == req.TravelDate) &&
                         (string.IsNullOrEmpty(req.FlightNumber) || eachFlight.FlightNo == req.FlightNumber) &&
                         (string.IsNullOrEmpty(req.PassengerName) || req.PassengerName == eachPassenger.FirstName + " " + eachPassenger.LastName)
                         select new { eachFlight, eachBooking, eachPassenger };

            var formed = result.AsEnumerable().Select(joined => new BookingSearchResponse()
            {
                ArrivalTime        = joined.eachBooking.TravelDay.Value.AddTicks(joined.eachFlight.FlightArrivalTime.Ticks),
                DepartureTime      = joined.eachBooking.TravelDay.Value.AddTicks(joined.eachFlight.FlightBoardingTime.Ticks),
                FlightName         = joined.eachFlight.FlightName,
                FlightNo           = joined.eachFlight.FlightNo,
                PassengerFirstName = joined.eachPassenger.FirstName,
                PassengerLastName  = joined.eachPassenger.LastName
            });

            var y = formed.ToList();

            return(formed);
        }
        public async Task AllBookings()
        {
            var customerID = await _serviceCustomer.GetById <Data.Model.Customer>(APIService.CustomerId);

            customer = customerID;

            var request = new BookingSearchRequest
            {
                CustomerID = customer.CustomerId
            };

            BookingList.Clear();
            var list = await _serviceBooking.Get <List <Data.Model.Booking> >(request);

            foreach (var item in list)
            {
                item.EndDate = item.EndDate.AddHours(8).Date;
                BookingList.Add(item);
            }

            if (BookingList.Count == 0)
            {
                await Application.Current.MainPage.DisplayAlert("Warning", "You don't have any bookings yet.", "OK");
            }
        }
 /// <summary>
 /// Booking main screen
 /// </summary>
 public ActionResult Index(BookingSearchRequest request)
 {
     try
     {
         if (request.OperationWorkPlaceCode != null && request.OperationWorkPlaceId != 0)
         {
             var booking = new BookingViewModel()
             {
                 OperationWorkPlaceCode = request.OperationWorkPlaceCode,
                 OperationWorkPlaceId   = request.OperationWorkPlaceId,
                 StartDt = request.StartDt,
                 EndDt   = request.EndDt
             };
             TempData["Booking"]         = booking;
             CompleteBookingData.Booking = booking;
             return(RedirectToAction("HireGroup"));
         }
         ViewBag.OperationWorkPlaces = webApiService.GetOperationWorkplaceList(1);
         return(View());
     }
     catch (Exception exp)
     {
         string a = exp.Message;
         throw;
     }
 }
Beispiel #5
0
        public async Task RentCar()
        {
            try
            {
                if (StartDate.Date < DateTime.Now.Date)
                {
                    await Application.Current.MainPage.DisplayAlert("Error", "You cannot book before today", "Try again");

                    return;
                }

                if (StartDate.Date == EndDate.Date || EndDate.Date <= StartDate.Date)
                {
                    await Application.Current.MainPage.DisplayAlert("Error", "The scope of booking period must be at least 1 day and the end date must be greater than the start date.", "Try again");

                    return;
                }

                var search = new BookingSearchRequest
                {
                    VehicleID = Vehicle.VehicleId
                };
                var listBooking = await _serviceBooking.Get <List <Data.Model.Booking> >(search);

                foreach (var item in listBooking)
                {
                    if (item.EndDate.Date > DateTime.Now.Date)               // VIDJET  !!!!
                    {
                        await Application.Current.MainPage.DisplayAlert("Error", "The vehicle is already reserved. After the reservation expires, you can reserve the vehicle again", "Try again");

                        return;
                    }
                }

                var request = new BookingUpsert
                {
                    CustomerId    = APIService.CustomerId,
                    StartDate     = StartDate.Date,
                    EndDate       = EndDate.Date,
                    VehicleId     = Vehicle.VehicleId,
                    RatingStatus  = false,
                    CommentStatus = false
                };
                await _serviceBooking.Insert <Data.Model.Booking>(request);

                var days  = (request.EndDate.Date - request.StartDate.Date).TotalDays;
                var total = Vehicle.DailyPrice * days;

                var message = string.Format("Successfully! Total price for {0} days of reservation cost {1} KM.", days, total);
                await Application.Current.MainPage.DisplayAlert("Message", message, "OK");
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("Error", "Somethning went wrong", "Try again");
            }
        }
Beispiel #6
0
        private async void btnBooking_Click(object sender, EventArgs e)
        {
            var search = new BookingSearchRequest()
            {
                FirstName        = txtBookingSearch.Text,
                StartDate        = dtStartDate.Value.Date,
                EndDate          = dtEndDate.Value.Date,
                LastName         = txtLastName.Text,
                ManufacturerName = txtManufacturerName.Text,
                ModelName        = txtModelName.Text
            };

            if (chkDate.Checked)
            {
                search.StartDate = null;
                search.EndDate   = null;
            }
            else
            {
                if (search.EndDate.Value.Date <= search.StartDate.Value.Date)
                {
                    MessageBox.Show("The scope of period days must be at least 1 day and the end date must be greater than the start date.", "Try again", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }

            var result = await _serviceBooking.Get <List <Data.Model.Booking> >(search);

            List <frmAllBookingVM> finalList = new List <frmAllBookingVM>();

            foreach (var item in result)
            {
                frmAllBookingVM form = new frmAllBookingVM
                {
                    BookingId        = item.BookingId,
                    StartDate        = item.StartDate,
                    EndDate          = item.EndDate,
                    FirstName        = item.Customer.FirstName,
                    LastName         = item.Customer.LastName,
                    ManufacturerName = item.Vehicle.VehicleModel.Manufacturer.ManufacturerName,
                    ModelName        = item.Vehicle.VehicleModel.ModelName
                };
                finalList.Add(form);
            }
            dgvBooking.AutoGenerateColumns = false;
            dgvBooking.DataSource          = finalList;

            if (finalList.Count == 0)
            {
                MessageBox.Show("There are no results for this search", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        public async Task SearchBookingCar()
        {
            if (EndDate == StartDate)
            {
                await Application.Current.MainPage.DisplayAlert("Warning", "The search interval should be at least 1 day", "Try again");

                return;
            }
            if (EndDate <= StartDate)
            {
                await Application.Current.MainPage.DisplayAlert("Warning", "End date must be greater than start date", "Try again");

                return;
            }

            var request = new BookingSearchRequest
            {
                ManufacturerName = ManufacturerName,
                StartDate        = StartDate,
                EndDate          = EndDate
            };

            var list = await _serviceBooking.Get <IEnumerable <Data.Model.Booking> >(request);

            BookingList.Clear();

            foreach (var item in list)
            {
                item.EndDate = item.EndDate.AddHours(8).Date;
                BookingList.Add(item);
            }
            if (BookingList.Count == 0)
            {
                await Application.Current.MainPage.DisplayAlert("Warning", "There are no results for this search", "Try again");
            }
        }
 public IEnumerable <BookingSearchResponse> Search([FromBody] BookingSearchRequest req) => _BookingRep.Search(req);