Ejemplo n.º 1
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                viewM = this.Main.DataContext as ReservationsViewModel;
                viewM.SelectedData = new Reservations();
                InsertData view = new InsertData("AJOUT", viewM.SelectedData, viewM);
                view.ShowDialog();

                if (view.Msg == "OK")
                {
                    MessageBox.Show("Opération effectuée avec succès", "Reservations", MessageBoxButton.OK, MessageBoxImage.Information);
                    viewM.Refresh();
                }
                else if (view.Msg == "Error")
                {
                    MessageBox.Show("   Echec Opération    ", "Reservations ", MessageBoxButton.OK, MessageBoxImage.Warning);
                    viewM.Refresh();
                }
                else
                {
                    viewM.Refresh();
                }
                //}
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Reservations", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
Ejemplo n.º 2
0
        public InsertData(string etat, Reservations ele, ReservationsViewModel view)
        {
            InitializeComponent();

            this.DataContext = viewVM = view;

            Etat = etat;

            if (etat == "AJOUT")
            {
                this.Title = "Enregistrement d'un Quartier";
            }
            else
            {
                this.Title = "Modification d'un Quartier";

                //if (ele.Sexe != null)
                //{
                //    if (ele.Sexe == "M")
                //    {
                //        rdMasc.IsChecked = true;
                //    }
                //    else if (ele.Sexe == "F")
                //    {
                //        rdFem.IsChecked = true;
                //    }
                //}
            }
        }
Ejemplo n.º 3
0
        private void btnClient_Click(object sender, RoutedEventArgs e)
        {
            if (dataGrid.SelectedItem != null)
            {
                viewM = this.Main.DataContext as ReservationsViewModel;
                ClientsViewModel cli = new ClientsViewModel(viewM.model);
                cli.SelectedData = (dataGrid.SelectedItem as Reservations).Clients;

                ClientInsertData view = new ClientInsertData("MOD", cli.SelectedData, cli);
                view.ShowDialog();

                if (view.Msg == "OK")
                {
                    MessageBox.Show("Opération effectuée avec succès", "Clients", MessageBoxButton.OK, MessageBoxImage.Information);
                    viewM.Refresh();
                }
                else if (view.Msg == "Error")
                {
                    MessageBox.Show("    Echec Opération    ", "Clients", MessageBoxButton.OK, MessageBoxImage.Warning);
                    viewM.Refresh();
                }
                else
                {
                    viewM.Refresh();
                }
            }
        }
        public void TestCancelReservationCommand()
        {
            Mock <IServiceFactory> mockServiceFactory = new Mock <IServiceFactory>();

            mockServiceFactory.Setup(mock => mock.CreateClient <IRentalService>().CancelReservation(1));

            ReservationsViewModel viewModel = new ReservationsViewModel(mockServiceFactory.Object);

            viewModel.Reservations = new ObservableCollection <CustomerReservationData>()
            {
                new CustomerReservationData()
                {
                    ReservationId = 1
                },
                new CustomerReservationData()
                {
                    ReservationId = 2
                }
            };

            bool reservationCanceled = false;
            bool errorOccured        = false;

            viewModel.ReservationCanceled += (s, e) => reservationCanceled = true;
            viewModel.ErrorOccured        += (s, e) => errorOccured = true;

            viewModel.CancelReservationCommand.Execute(1);

            Assert.IsTrue(reservationCanceled && !errorOccured);
            Assert.IsTrue(viewModel.Reservations.Count == 1 && viewModel.Reservations[0].ReservationId == 2);
        }
        public IActionResult AllReservations()
        {
            var allReservations = staysService.AllReservations();
            if (allReservations == null || allReservations.Count <= 0)
            {
                return PartialView("_NoDataPartial");
            }
            var reservationsViewModel = new List<ReservationsViewModel>();

            foreach (var stay in allReservations)
            {
                var viewModel = new ReservationsViewModel
                {
                    RoomType = stay.RoomType,
                    MoneySpend = stay.MoneySpend.ToString(),
                    ArrivalDate = stay.ArrivalDate.ToString("MM/dd/yyyy"),
                    DepartureDate = stay.DepartureDate.ToString("MM/dd/yyyy"),
                    PricePerNight = stay.Price.ToString(),
                    TotalPrice = stay.TotalPrice.ToString(),
                    PointsEarned = stay.PointsEarned.ToString(),
                    HotelName = hotelService.FindSingleHotelById(stay.HotelId).Result.Name,
                    UserName = userService.GetUser(stay.ApplicationUserId).UserName,
                    Adults = stay.Adults.ToString(),
                    Children = stay.Children.ToString(),
                    ConfirmationNumber = stay.ConfirmationNumber,
                    BookedOn = stay.BookedOn
                };
                reservationsViewModel.Add(viewModel);
            }
            return View(reservationsViewModel);
        }
        public void TestExecuteRentalCommandWithError()
        {
            Mock <IServiceFactory> mockServiceFactory = new Mock <IServiceFactory>();

            mockServiceFactory.Setup(mock => mock.CreateClient <IRentalService>().ExecuteRentalFromReservation(1)).Throws(new Exception());

            ReservationsViewModel viewModel = new ReservationsViewModel(mockServiceFactory.Object);

            viewModel.Reservations = new ObservableCollection <CustomerReservationData>()
            {
                new CustomerReservationData()
                {
                    ReservationId = 1
                },
                new CustomerReservationData()
                {
                    ReservationId = 2
                }
            };

            bool rentalExecuted = false;
            bool errorOccured   = false;

            viewModel.RentalExecuted += (s, e) => rentalExecuted = true;
            viewModel.ErrorOccured   += (s, e) => errorOccured = true;

            viewModel.ExecuteRentalCommand.Execute(1);

            Assert.IsTrue(!rentalExecuted && errorOccured);
        }
Ejemplo n.º 7
0
        // GET: Reservations
        public ActionResult Index()
        {
            var reservations = db.GetAll();

            var viewModel = new ReservationsViewModel();

            List <ReservationsViewModel> list = new List <ReservationsViewModel>();

            foreach (var item in reservations)
            {
                viewModel.Reservations.Id = item.Id;
                viewModel.Reservations.ReservationName   = item.ReservationName;
                viewModel.Reservations.ReservationNumber = item.ReservationNumber;
                viewModel.Reservations.ReservationTime   = item.ReservationTime;
                viewModel.TableId        = item.TableId;
                viewModel.RestaurantName = item.Table.Restaurant.Name;

                list.Add(viewModel);
            }


            IEnumerable <ReservationsViewModel> viewEnumerable = list;

            return(View(viewEnumerable));
        }
        public ActionResult Book(int?id)
        {
            var currentUserId = User.Identity.GetUserId();

            //var passinfo = db.Reservations.FirstOrDefault(d => d.IUser.Id == currentUserId);

            if (id == null || currentUserId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var ReservationsViewModel = new ReservationsViewModel();

            {
                ReservationsViewModel.House = db.Houses.First(i => i.Id == id);
                ReservationsViewModel.User  = db.Users.First(i => i.Id == currentUserId);
            }

            if (ReservationsViewModel.House == null)
            {
                return(HttpNotFound());
            }



            return(View(ReservationsViewModel));
        }
Ejemplo n.º 9
0
        private void btnChambre_Click(object sender, RoutedEventArgs e)
        {
            if (dataGrid.SelectedItem != null)
            {
                viewM = this.Main.DataContext as ReservationsViewModel;

                AssigneChambre view = new AssigneChambre(dataGrid.SelectedItem as Reservations, viewM.model, "Autre");
                view.ShowDialog();

                if (view.Msg == "OK")
                {
                    MessageBox.Show("Opération effectuée avec succès", "Clients", MessageBoxButton.OK, MessageBoxImage.Information);
                    viewM.Refresh();
                }
                else if (view.Msg == "Error")
                {
                    MessageBox.Show("    Echec Opération    ", "Clients", MessageBoxButton.OK, MessageBoxImage.Warning);
                    viewM.Refresh();
                }
                else
                {
                    viewM.Refresh();
                }
            }
        }
Ejemplo n.º 10
0
        public IActionResult Index(string email)
        {
            var reservations          = this.reservationsProvider.GetReservationsFor(email);
            var reservationsViewModel = new ReservationsViewModel(email, reservations);

            return(View(reservationsViewModel));
        }
Ejemplo n.º 11
0
        private void btnAnnuler_Click(object sender, RoutedEventArgs e)
        {
            ReservationsViewModel vehi = this.DataContext as ReservationsViewModel;

            vehi.SelectedData = null;

            this.Close();
        }
Ejemplo n.º 12
0
        public IActionResult Index(QueryReservationsViewModel queryReservationsViewModel)
        {
            var reservations = this.reservationsProvider.GetReservationsFor(queryReservationsViewModel.ClientMail);

            var reservationsViewModel = new ReservationsViewModel(queryReservationsViewModel.ClientMail, reservations);

            return(View(reservationsViewModel));
        }
Ejemplo n.º 13
0
 public async Task <IActionResult> RemoveReservationPersonItem([Bind("Email,ReservationPersons")] ReservationsViewModel model)
 {
     ModelState.Clear();
     if (model.ReservationPersons.Count > 1)
     {
         model.ReservationPersons.RemoveAt(model.ReservationPersons.Count - 1);
     }
     return(PartialView("ReservationPersonItems", model));
 }
Ejemplo n.º 14
0
        public async Task <IActionResult> Index(ReservationsViewModel model, string flight)
        {
            ViewData["flight"] = flight;

            model.Flight    = _context.Flight.First(x => x.ID == new Guid(flight));
            model.FreeSeats = model.Flight.CustomerCapacity - _context.ReservationPersons.Where(x => !x.IsBussinesClass && x.Reservation.Flight.ID == model.Flight.ID).Count();
            model.FreeSeatsBusinessClass = model.Flight.CustomerCapacityBussinessClass - _context.ReservationPersons.Where(x => x.IsBussinesClass && x.Reservation.Flight.ID == model.Flight.ID).Count();

            if (ModelState.IsValid)
            {
                if (model.FreeSeatsBusinessClass >= model.ReservationPersons.Where(x => x.IsBussinesClass).Count() &&
                    model.FreeSeats >= model.ReservationPersons.Where(x => !x.IsBussinesClass).Count())
                {
                    Reservations reservation = new Reservations();
                    reservation.Email              = model.Email;
                    reservation.Flight             = model.Flight;
                    reservation.ReservationPersons = new List <ReservationPersons>();
                    foreach (var person in model.ReservationPersons)
                    {
                        reservation.ReservationPersons.Add(new ReservationPersons
                        {
                            FirstName       = person.FirstName,
                            FatherName      = person.FatherName,
                            LastName        = person.LastName,
                            SSN             = person.SSN,
                            PhoneNumber     = person.PhoneNumber,
                            Nationality     = person.Nationality,
                            IsBussinesClass = person.IsBussinesClass
                        });
                    }
                    _context.Reservations.Add(reservation);
                    await _context.SaveChangesAsync();

                    SmtpClient client = new SmtpClient("smtp.mailtrap.io");
                    client.UseDefaultCredentials = false;
                    client.Credentials           = new NetworkCredential("62fc31ef4c5f5e", "45944e2ba3e7f3");

                    MailMessage mailMessage = new MailMessage();
                    mailMessage.From = new MailAddress("*****@*****.**");
                    mailMessage.To.Add(reservation.Email);
                    mailMessage.IsBodyHtml = false;
                    mailMessage.Body       = "Your reservation for flight number " + reservation.Flight.FlightNumber + " was successful." + "\n";
                    mailMessage.Subject    = "Reservation confirmation.";
                    client.Send(mailMessage);

                    return(new RedirectToActionResult("Success", "Reservations", null));
                }
                else
                {
                    ModelState.AddModelError("", "There is not enough free seats.");
                }
            }

            return(View(model));
        }
Ejemplo n.º 15
0
        protected override void OnWireViewModelEvents(ViewModelBase viewModel)
        {
            ReservationsViewModel vm = viewModel as ReservationsViewModel;

            if (vm != null)
            {
                vm.RentalExecuted      += OnRentalExecuted;
                vm.ReservationCanceled += OnReservationCanceled;
                vm.ErrorOccured        += OnErrorOccured;
            }
        }
        public IActionResult Reservations(ReservationsViewModel ReservationsViewModel)
        {
            if (HttpContext.Session.GetString("UserId") != null)
            {
                Queries GetReservationOverview = new Queries();
                ReservationsViewModel.ReservationList = GetReservationOverview.RetrieveReservations();
                return(View(ReservationsViewModel));
            }

            return(RedirectToAction("Login", "Home"));
        }
Ejemplo n.º 17
0
        public UCReservation()
        {
            InitializeComponent();
            ReservationsViewModel resaVM = new ReservationsViewModel();

            reservationCalendar.SelectedDate = DateTime.Now;
            //reservationCalendar.SelectionMode = CalendarSelectionMode.MultipleRange;
            //foreach (ReservationViewModel rvm in resaVM.ListReservations)
            //{
            //    reservationCalendar.SelectedDates.AddRange(rvm.Reservation.DateStart, rvm.Reservation.DateEnd);
            //}
        }
Ejemplo n.º 18
0
        public async Task <IActionResult> Index(string flight)
        {
            ViewData["flight"] = flight;

            ReservationsViewModel model = new ReservationsViewModel();

            model.Flight    = _context.Flight.First(x => x.ID == new Guid(flight));
            model.FreeSeats = model.Flight.CustomerCapacity - _context.ReservationPersons.Where(x => !x.IsBussinesClass && x.Reservation.Flight.ID == model.Flight.ID).Count();
            model.FreeSeatsBusinessClass = model.Flight.CustomerCapacityBussinessClass - _context.ReservationPersons.Where(x => x.IsBussinesClass && x.Reservation.Flight.ID == model.Flight.ID).Count();

            return(View(model));
        }
Ejemplo n.º 19
0
        public async Task <IActionResult> Details(string id)
        {
            Client client = await this._context.Clients
                            .Include(client => client.Reservations)
                            .ThenInclude(reservation => reservation.Reservation)
                            .SingleOrDefaultAsync(client => client.Id == id);

            List <ClientReservation>     rese               = _context.ClientReservations.Where(res => res.Client.Id == client.Id).ToList();
            List <string>                reseIds            = new List <string>();
            List <Reservation>           reser              = new List <Reservation>();
            List <ReservationsViewModel> clientReservations = new List <ReservationsViewModel>();

            foreach (var r in rese)
            {
                reseIds.Add(r.Reservation.Id);
            }

            foreach (var r in reseIds)
            {
                Reservation reservation = new Reservation();
                reservation = _context.Reservations.Include(user => user.User).Include(room => room.Room).FirstOrDefault(res => res.Id == r);
                reser.Add(reservation);
            }

            foreach (var r in reser)
            {
                ReservationsViewModel clientReservationsA = new ReservationsViewModel()
                {
                    Id                = r.Id,
                    RoomNumber        = r.Room.number,
                    UserName          = r.User.UserName,
                    AccommodationDate = r.AccommodationDate,
                    ReleaseDate       = r.ReleaseDate,
                    HaveBreakFast     = r.HaveBreakFast ? "Yes" : "No",
                    IsAllInclusive    = r.IsAllInclusive ? "Yes" : "No",
                    DueAmount         = r.DueAmount
                };
                clientReservations.Add(clientReservationsA);
            }

            ClientsDetailsViewModel clientsDetailsViewModel = new ClientsDetailsViewModel
            {
                FullName     = $"{client.FirstName} {client.LastName}",
                Email        = client.Email,
                Number       = client.Number,
                IsAdult      = client.IsAdult ? "Yes" : "No",
                Reservations = clientReservations
            };

            return(this.View(clientsDetailsViewModel));
        }
Ejemplo n.º 20
0
        public ReservationsViewModel GetAll()
        {
            var query        = _context.Reservation.AsNoTracking();
            var reservations = query.Select(reservation => new ReservationViewModel
            {
                Reservation_ID  = reservation.Id,
                User            = reservation.User,
                Book            = reservation.Book,
                ReservationDate = reservation.ReservationDate
            }).ToList();
            var model = new ReservationsViewModel {
                Reservations = reservations
            };

            return(model);
        }
Ejemplo n.º 21
0
        public ActionResult Book(ReservationsViewModel reservationsViewModel, int id)
        {
            if (ModelState.IsValid)
            {
                var reservationToAdd = reservationsViewModel;

                var house  = db.Houses.FirstOrDefault(i => i.Id == id);
                var userId = User.Identity.GetUserId();
                var user   = db.Users.FirstOrDefault(i => i.Id == userId);

                DateTime houseStartDate = house.StartDate;
                DateTime houseEndDate   = house.EndDate;
                DateTime givenStartDate = reservationToAdd.Reservation.StartDate;
                DateTime givenEndDate   = reservationToAdd.Reservation.EndDate;


                if ((givenStartDate < houseStartDate) || (givenEndDate > houseEndDate))
                //if ((givenStartDate.Date> houseStartDate.Date) || (givenEndDate.Date < houseEndDate.Date))
                {
                    return(RedirectToAction("Search", new { message = "Error" }));
                }
                //else
                //{

                foreach (Reservation reservations in db.Reservations.Where(n => n.House.Id == id))
                {
                    if (((givenStartDate == reservations.StartDate) && (givenEndDate == reservations.StartDate)) || ((givenStartDate < reservations.StartDate) && (givenEndDate < reservations.StartDate)) || ((givenStartDate < reservations.StartDate) && (givenEndDate > reservations.StartDate)) || ((givenStartDate > reservations.StartDate) && (givenEndDate < reservations.StartDate)) || ((givenStartDate > reservations.StartDate) && (givenStartDate < reservations.EndDate)))
                    //if ((givenStartDate > reservations.StartDate) || (givenEndDate < reservations.EndDate))
                    {
                        return(RedirectToAction("Search", new { message = "Error" }));
                    }
                }
                //}

                reservationsViewModel.Reservation.House = house;
                reservationsViewModel.Reservation.User  = user;
                db.Reservations.Add(reservationToAdd.Reservation);
                db.SaveChanges();

                return(RedirectToAction("MyReservations", new { message = "Success" }));
            }
            else
            {
                return(View(reservationsViewModel));
            }
        }
        // GET: Reservations/Create
        public ActionResult Create(Nullable <int> id)
        {
            var reservation = new ReservationsViewModel();
            var couchId     = id;

            if (id != null)
            {
                ViewBag.CoachId   = couchId;
                ViewBag.CoachName = db.Coach.Find(couchId).CoachName;
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            //ViewBag.CoachId = new SelectList(db.Coach, "Id", "CoachName");
            return(View(reservation));
        }
Ejemplo n.º 23
0
        public async Task <IActionResult> Add(ReservationsViewModel model)
        {
            if (ModelState.IsValid)
            {
                Flight flight = _flightRepository.Items.SingleOrDefault(item => item.Id == model.Id);
                model.FlightId = flight.Id;
                model.Flight   = flight;
                if (model.Flight.CapacityEconomyPassengers >= model.PassengersEconomyCount && model.Flight.CapacityBusinessPassengers >= model.PassengersBusinessCount)
                {
                    Reservation reservation = new Reservation()
                    {
                        FlightId = model.FlightId,
                        Flight   = flight,
                        Email    = model.Email,
                        PassengersEconomyCount  = model.PassengersEconomyCount,
                        PassengersBusinessCount = model.PassengersBusinessCount,
                        Passengers = null
                    };

                    await _reservationRepository.Add(reservation);

                    await _flightRepository.Update(flight);

                    return(RedirectToAction("AddPassengers", reservation));
                }
                else
                {
                    if (model.Flight.CapacityEconomyPassengers < model.PassengersEconomyCount &&
                        model.Flight.CapacityBusinessPassengers < model.PassengersBusinessCount)
                    {
                        ViewData["Message"] = "This flight does not have this much free economy and business seats";
                    }
                    else if (model.Flight.CapacityBusinessPassengers < model.PassengersBusinessCount)
                    {
                        ViewData["Message"] = "This flight does not have this much free business seats";
                    }
                    else if (model.Flight.CapacityEconomyPassengers < model.PassengersEconomyCount)
                    {
                        ViewData["Message"] = "This flight does not have this much free economy seats";
                    }
                    return(View(model));
                }
            }
            return(View(model));
        }
Ejemplo n.º 24
0
        //Evenement double clic du RadGridview
        void OnGridMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            FrameworkElement originalSender = e.OriginalSource as FrameworkElement;

            if (originalSender != null)
            {
                //var cell = originalSender.ParentOfType<GridViewCell>();
                //if (cell != null)
                //{
                //    MessageBox.Show("The double-clicked cell is " + cell.Value);
                //}

                var row = originalSender.ParentOfType <GridViewRow>();
                if (row != null)
                {
                    try
                    {
                        //if (GlobalData.VerificationDroit("CanEditReservations"))
                        //{
                        viewM = this.Main.DataContext as ReservationsViewModel;

                        RadDocumentPane rad = new RadDocumentPane();
                        rad.Content = new GESHOTEL.ReservationsModules.TransactionEdit(viewM.SelectedData.ID, "Modification de Sejour " + viewM.SelectedData.ID.ToString());
                        rad.Header  = "Modification de Sejour " + viewM.SelectedData.ID.ToString();
                        GlobalData.rrvMain.Title = "Modification de Sejour " + viewM.SelectedData.ID.ToString();
                        rad.FontFamily           = new FontFamily("Perpetua Titling MT");
                        rad.HorizontalAlignment  = System.Windows.HorizontalAlignment.Stretch;
                        rad.VerticalAlignment    = System.Windows.VerticalAlignment.Stretch;

                        if (!GlobalData.VerifyDock("Modification de Sejour " + viewM.SelectedData.ID.ToString()))
                        {
                            GlobalData.PaneGroup.AddItem(rad, Telerik.Windows.Controls.Docking.DockPosition.Center);
                        }
                        else
                        {
                        }
                        //}
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message + "Veuillez fermer le formulaire puis recommencer.", "CATEGORIE", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                }
            }
        }
        public ActionResult Create(ReservationsViewModel userReservation)
        {
            if (this.User.Identity.IsAuthenticated)
            {
                var newReservation = new Reservation
                {
                    PersonId     = this.User.Identity.GetUserId(),
                    Table        = userReservation.Table,
                    ReservedFor  = userReservation.ReservedFor,
                    AskSomething = userReservation.AskSomething
                };

                this.reservations.Add(newReservation);
                this.reservations.SaveChanges();
                this.TempData["Notification"] = "Your reservation has been Approved";
            }
            return(Redirect("/"));
        }
Ejemplo n.º 26
0
        public ViewResult DisplayList(ReservationsViewModel model)
        {
            IEnumerable <TennisReservation> filtered = repository.Reservations;

            if (!String.IsNullOrEmpty(model.PageInfo.FilterField))
            {
                filtered = filtered.Where(r => r.Court.Name == model.PageInfo.FilterField);
            }
            if (model.PageInfo.FilterDate != null && model.PageInfo.FilterDate.Year != 1)
            {
                filtered = filtered.Where(r => r.ReservationTime.ToShortDateString() == model.PageInfo.FilterDate.ToShortDateString());
            }
            var courtNameList = new SelectList(repository.Courts.Select(c => c.Name), repository.Courts.First().Name);
            var courtTypeList = new SelectList(repository.Courts.Select(c => c.Type).Distinct(), repository.Courts.First().Type);

            ReservationsViewModel newModel = new ReservationsViewModel(filtered, courtNameList, courtTypeList);

            return(View(newModel));
        }
 //[Bind(Include = "Id,StartTime,EndTime,UserId,CoachId,ReservationDesc")]
 public ActionResult Create(ReservationsViewModel model)
 {
     if (ModelState.IsValid)
     {
         var reservation = new Reservation
         {
             Id              = model.Id,
             StartTime       = model.StartTime,
             EndTime         = model.EndTime,
             UserId          = User.Identity.GetUserId(),
             CoachId         = model.CoachId,
             ReservationDesc = model.ReservationDesc
         };
         db.Reservation.Add(reservation);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
        public ActionResult Create(ReservationsViewModel vm)
        {
            if (ModelState.IsValid)
            {
                if (vm.Confirm == true)
                {
                    vm.GetTotalPrice();
                    vm.Create();
                    return(RedirectToAction("Success"));
                }
                else
                {
                    vm.GetTotalPrice();
                    vm.Confirm = true;
                    return(View(vm));
                }
            }

            return(View(vm));
        }
        public ReservationList()
        {
            InitializeComponent();
            viewModel = new ReservationsViewModel(this);
            listViewReservations.Items.Clear();
            LoadReservationsList();
            var count = GetReservationListCount();

            for (var i = 0; i < count; i++)
            {
                ReadReservationOnIndex(i);
                var obj = new ListViewItem(GetReservationUser());
                obj.SubItems.Add(GetMovieTitle());
                obj.SubItems.Add(GetSeatNumber().ToString());
                obj.SubItems.Add(GetHallName());
                obj.SubItems.Add(GetDate().ToString());
                obj.SubItems.Add(GetConfirmation().ToString());
                listViewReservations.Items.Add(obj);
            }
        }
        public void TestViewLoaded()
        {
            CustomerReservationData[] data = new List <CustomerReservationData>()
            {
                new CustomerReservationData(),
                new CustomerReservationData()
            }.ToArray();

            Mock <IServiceFactory> mockServiceFactory = new Mock <IServiceFactory>();

            mockServiceFactory.Setup(mock => mock.CreateClient <IRentalService>().GetCurrentReservations()).Returns(data);

            ReservationsViewModel viewModel = new ReservationsViewModel(mockServiceFactory.Object);

            Assert.IsTrue(viewModel.Reservations == null);

            object loaded = viewModel.ViewLoaded; // fires off the OnViewLoaded protected method

            Assert.IsTrue(viewModel.Reservations != null && viewModel.Reservations.Count == data.Length && viewModel.Reservations[0] == data[0]);
        }