Beispiel #1
0
        public ReservationList()
        {
            InitializeComponent();
            var reservationListViewModel = new ReservationListViewModel();

            _reservationListViewModel = reservationListViewModel.initialize();
            BindingContext            = _reservationListViewModel ??= reservationListViewModel;
        }
        public IActionResult Index()
        {
            var signedInUserId   = _userManager.GetUserId(HttpContext.User);
            var userReservations = _reservationRepository.GetReservationsForUser(signedInUserId);
            var viewModel        = new ReservationListViewModel {
                Reservations = userReservations, SignedInUserId = signedInUserId
            };

            return(View(viewModel));
        }
Beispiel #3
0
        public async Task <IActionResult> ListReservations(ReservationListViewModel model)
        {
            List <SingleReservationViewModel> items = await _context.Reservations.Select(r => new SingleReservationViewModel()
            {
                Id    = r.Id,
                Email = r.Email
            }).ToListAsync();

            model.Reservations = items;
            return(View(model));
        }
        public ReservationListPage()
        {
            InitializeComponent();
            BindingContext = new ReservationListViewModel();

            reservationListView.ItemSelected += (object sender, SelectedItemChangedEventArgs e) =>
            {
                if (e.SelectedItem == null)
                {
                    return;
                }
                ((ListView)sender).SelectedItem = null;
            };
        }
Beispiel #5
0
        public async Task <IActionResult> AddReservation(ReservationListViewModel reservationListView, int uniquePlaneNumber, string Email)
        {
            var    flight         = flightService.GetExactFlight(uniquePlaneNumber);
            string HtmlFlightData = "";
            string ResrvData      = "";
            var    x = 0;

            string[] htmlResrvData = new string[reservationListView.Reservations.Count];

            foreach (var resrvs in reservationListView.Reservations)
            {
                ResrvData = $"<p><span>First Name: {resrvs.FirstName} || Second Name: {resrvs.SecondName} || FamilyName: {resrvs.SecondName} || PIN: {resrvs.PIN} ||Phonenumber: {resrvs.TelephoneNumber} || Nationality: {resrvs.Nationality} || TicketType: {resrvs.TicketType} </span></p>" +
                            $"<hr/>";
                htmlResrvData[x] = ResrvData;
                x++;
            }

            foreach (var flights in flight)
            {
                HtmlFlightData = $"<h1>Hi, Your reservation has been successful</h1>" +
                                 $"<p><b> Flight Details </b></p>" +
                                 $"<p>From: {flights.From}</p>" +
                                 $"<p>To: {flights.To}</p>" +
                                 $"<p>Plane Type: {flights.PlaneType}</p>" +
                                 $"<p>Departur on: {flights.DateTimeTakeOff}</p>" +
                                 $"<h4> Reservation Details </h4>"
                ;
            }

            var sb = new StringBuilder();

            for (int i = 0; i < htmlResrvData.Length; i++)
            {
                sb.Append(htmlResrvData[i]);
            }

            foreach (var emails in reservationListView.Reservations)
            {
                emails.Email = Email;
            }

            if (ModelState.IsValid)
            {
                reservationService.Create(reservationListView, uniquePlaneNumber);
                await mailService.SendEmailAsync(Email, "FlightManager", HtmlFlightData + sb);
            }

            return(Redirect("/Home/Index"));
        }
Beispiel #6
0
        public IActionResult Index(string c, string t)
        {
            var vm = new ReservationListViewModel
            {
                Filters = new ReservationFiltersViewModel
                {
                    ClientNameSearchQuery      = c,
                    ReservationTypeSearchQuery = t,
                    // You would normally get the list from your database
                    AvailableReservationTypes = GetFakeReservationStatusesFromDb()
                                                .ToDictionary(x => x.StatusId, x => x.Status)
                },
                Reservations = Enumerable.Empty <ReservationViewModel>()
            };

            // You would normally get the list of reservations from your database
            var reservationsFromDb = GetFakeReservationsFromDb();

            // Filters
            if (!String.IsNullOrWhiteSpace(c))
            {
                reservationsFromDb = reservationsFromDb
                                     .Where(x => x.ClientName.Contains(c, StringComparison.InvariantCultureIgnoreCase));
            }
            if (!String.IsNullOrWhiteSpace(t))
            {
                reservationsFromDb = reservationsFromDb
                                     .Where(x => x.ReservationStatus.StatusId.Contains(t, StringComparison.InvariantCultureIgnoreCase));
            }

            vm.Reservations = reservationsFromDb
                              .Select(x => new ReservationViewModel
            {
                ReservationId   = x.ReservationId,
                ClientName      = x.ClientName,
                ReservationType = x.ReservationStatus.Status,
                StartTime       = x.StartTimeUtc.ToLocalTime()
            });

            return(View(vm));
        }
Beispiel #7
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            var org = GetMyOrganisation();

            var reservationList = Db.Activities.OfType <Reservation>().Where(r => r.Organiser.Id == org.Id).ToList();

            var courseService = new CourseService(Db);

            var model = new ReservationListViewModel();

            model.Organiser = org;

            foreach (var res in reservationList)
            {
                var rm =
                    new ReservationViewModel
                {
                    Reservation = res,
                    Owner       = UserManager.FindById(res.UserId)
                };

                rm.FirstDate = res.Dates.OrderBy(x => x.Begin).FirstOrDefault();
                rm.LastDate  = res.Dates.OrderByDescending(x => x.Begin).FirstOrDefault();

                var lectures =
                    Db.Members.Where(l => l.Dates.Any(occ => occ.Activity.Id == res.Id)).ToList();

                var rooms =
                    Db.Rooms.Where(l => l.Dates.Any(occ => occ.Activity.Id == res.Id)).ToList();

                rm.Hosts = lectures;
                rm.Rooms = rooms;


                model.Reservations.Add(rm);
            }

            ViewBag.UserRight = GetUserRight();

            return(View(model));
        }
Beispiel #8
0
        /// <summary>
        /// Създава резервация
        /// </summary>
        /// <param name="reservationView"></param>
        /// <param name="uniquePlaneNumber"></param>

        public void Create(ReservationListViewModel reservationView, int uniquePlaneNumber)
        {
            var flight = dbContext.Flights.FirstOrDefault(x => x.UniquePlaneNumber == uniquePlaneNumber);

            foreach (var Reservations in reservationView.Reservations)
            {
                if (Reservations.TicketType == GlobalConstants.TicketTypeRegular)
                {
                    if (flight.PassengersCapacity > 0)
                    {
                        var reservation = AddReservation(Reservations, uniquePlaneNumber, flight);
                        flight.PassengersCapacity -= 1;
                        this.dbContext.Reservations.Add(reservation);
                    }
                    else
                    {
                        throw new ArgumentException(ExceptionMessages.NotEnoughAmountOfRegularTickets);
                    }
                }
                else if (Reservations.TicketType == GlobalConstants.TicketTypeBusinessClass)
                {
                    if (flight.BusinessClassCapacity > 0)
                    {
                        var reservation = AddReservation(Reservations, uniquePlaneNumber, flight);
                        flight.BusinessClassCapacity -= 1;
                        this.dbContext.Reservations.Add(reservation);
                    }
                    else
                    {
                        throw new ArgumentException(ExceptionMessages.NotEnoughAmountOfBusinessClassTickets);
                    }
                }
                else
                {
                    throw new ArgumentException(ExceptionMessages.InvalidTicketType);
                }

                this.dbContext.SaveChanges();
            }
        }
Beispiel #9
0
        public ActionResult List(ReservationListViewModel model)
        {
            model.Pager ??= new PagerViewModel();
            model.Pager.CurrentPage = model.Pager.CurrentPage <= 0 ? 1 : model.Pager.CurrentPage;
            model.Pager.PageSize    = model.Pager.PageSize <= 0 ? 10 : model.Pager.PageSize;
            List <Flight> flights = new List <Flight>();

            if (model.FilterCriteria != null && model.Filter != null)
            {
                flights = _context.Flights.ToList();
            }
            else
            {
                flights = _context.Flights.Skip((model.Pager.CurrentPage - 1) * model.Pager.PageSize).Take(model.Pager.PageSize).ToList();
            }

            List <ReservationFlightDataViewModel> items = new List <ReservationFlightDataViewModel>();

            foreach (var flight in flights)
            {
                var viewModel = new ReservationFlightDataViewModel()
                {
                    Id                = flight.Id,
                    DepartureTime     = flight.DepartureTime,
                    FlightSource      = flight.LocationFrom,
                    FlightDestination = flight.LocationTo,
                    PlaneNum          = flight.PlaneNumber,
                    Reservations      = new List <ReservationDataViewModel>()
                };
                List <Reservation> reservations = new List <Reservation>();
                if (model.FilterCriteria != null && model.Filter != null)
                {
                    switch (model.FilterCriteria)
                    {
                    case "email":
                        reservations = _context.Reservations.Include(x => x.Passangers).Where(x => x.Email.Contains(model.Filter)).ToList();
                        break;
                    }
                }
                else
                {
                    reservations = _context.Reservations.Include(x => x.Passangers).ToList();
                }

                foreach (var reservation in reservations.Where(x => x.FlightId == flight.Id).ToList())
                {
                    var reservationModel = new ReservationDataViewModel()
                    {
                        Id              = reservation.Id,
                        Email           = reservation.Email,
                        NumberOfTickets = reservation.Passangers.Count()
                    };
                    viewModel.Reservations.Add(reservationModel);
                }
                items.Add(viewModel);
            }


            model.Items            = items;
            model.Pager.PagesCount = (int)Math.Ceiling(_context.Flights.Count() / (double)model.Pager.PageSize);

            return(View(model));
        }
 public IViewComponentResult Invoke(ReservationListViewModel rlvm)
 {
     return(View(rlvm));
 }