public ReservationDetails(ReservationListItem listItem) { InitializeComponent(); _DetailVieWModel = new ReservationDetailsViewModel(); _listItem = listItem; BindingContext = listItem; }
public IActionResult Details(int id) //details about reservations { Flight flight = _flightRepository.Items.SingleOrDefault(item => item.Id == id); if (flight == null) { return(NotFound()); } ReservationDetailsViewModel model = new ReservationDetailsViewModel(); model.Pager = model.Pager ?? new Models.PagerViewModel(); model.Pager.CurrentPage = model.Pager.CurrentPage <= 0 ? 1 : model.Pager.CurrentPage; model.Pager.ItemsPerPage = model.Pager.ItemsPerPage <= 0 ? 10 : model.Pager.ItemsPerPage; model.Filter = model.Filter ?? new Models.Filters.ReservationsFilterViewModel(); bool emptyEmail = string.IsNullOrWhiteSpace(model.Filter.Email); IQueryable <Reservation> reservations = flight.Reservations.Where( item => (emptyEmail || item.Email.Contains(model.Filter.Email)) && (item.FlightId == id)).AsQueryable(); model.Pager.Pages = (int)Math.Ceiling((double)reservations.Count() / model.Pager.ItemsPerPage); reservations = reservations.OrderBy(item => item.Id) .Skip((model.Pager.CurrentPage - 1) * model.Pager.ItemsPerPage) .Take(model.Pager.ItemsPerPage); model.DetailsAboutReservations = flight.Reservations.Select(item => new ReservationsViewModel() { Id = item.Id, FlightId = item.FlightId, Email = item.Email, PassengersEconomyCount = item.PassengersEconomyCount, PassengersBusinessCount = item.PassengersBusinessCount }); return(View(model)); }
public ReservationDetailPage() { InitializeComponent(); viewModel = new ReservationDetailsViewModel(new Reservation()); BindingContext = viewModel; }
private async Task <string> GenerateEmailContent(ReservationDetailsViewModel reservationDetailsViewModel) { var reservationInfoHtml = string.Format( ServicesDataConstants.ReservationHtmlInfo, reservationDetailsViewModel.Id, reservationDetailsViewModel.RestaurantName, reservationDetailsViewModel.PeopleCount, reservationDetailsViewModel.ReservationDayString + " " + reservationDetailsViewModel.ReservationHourString); var restaurant = await this.restaurantsRepository.All() .FirstOrDefaultAsync(r => r.Id == reservationDetailsViewModel.RestaurantId); var restaurantInfoHtml = string.Format( ServicesDataConstants.RestaurantHtmlInfo, restaurant.Address, restaurant.Destination.Name, restaurant.Destination.Country.Name); var receiptPath = ServicesDataConstants.ReservationReceiptEmailHtmlPath; var doc = new HtmlDocument(); doc.Load(receiptPath); var content = doc.Text; content = content.Replace(ServicesDataConstants.ReservationInfoPlaceholder, reservationInfoHtml) .Replace(ServicesDataConstants.RestaurantInfoPlaceholder, restaurantInfoHtml); return(content); }
public IActionResult Index(ReservationDetailsViewModel model) { model.Pager = model.Pager ?? new Models.PagerViewModel(); model.Pager.CurrentPage = model.Pager.CurrentPage <= 0 ? 1 : model.Pager.CurrentPage; model.Pager.ItemsPerPage = model.Pager.ItemsPerPage <= 0 ? 10 : model.Pager.ItemsPerPage; model.Filter = model.Filter ?? new Models.Filters.ReservationsFilterViewModel(); bool emptyEmail = string.IsNullOrWhiteSpace(model.Filter.Email); IQueryable <Reservation> reservations = _reservationRepository.Items.Where( item => (emptyEmail || item.Email.Contains(model.Filter.Email))); model.Pager.Pages = (int)Math.Ceiling((double)reservations.Count() / model.Pager.ItemsPerPage); reservations = reservations.OrderBy(item => item.Id) .Skip((model.Pager.CurrentPage - 1) * model.Pager.ItemsPerPage) .Take(model.Pager.ItemsPerPage); model.DetailsAboutReservations = reservations.Select(item => new ReservationsViewModel() { Id = item.Id, FlightId = item.FlightId, Email = item.Email, PassengersEconomyCount = item.PassengersEconomyCount, PassengersBusinessCount = item.PassengersBusinessCount }); return(View(model)); }
public ActionResult Modify(ReservationDetailsViewModel model) { if (!(model.AvailabilityDateFrom < model.DateTo && model.DateTo <= model.AvailabilityDateTo && model.DateFrom < model.AvailabilityDateTo && model.DateFrom >= model.AvailabilityDateFrom)) { ModelState.AddModelError("", "Reservation is not in availability range"); } if (ModelState.IsValid) { model.UserId = User.Identity.GetUserId(); var dbModel = Mapper.Map <ReservationDetailsViewModel, ReservationModel>(model); var isAdded = _reservationBusiness.Add(dbModel); if (!isAdded) { ModelState.AddModelError("", "Reservation exists."); return(View("Modify", model)); } return(RedirectToAction("Index", "Reservation", new { area = "UserPanel" })); //return RedirectToAction("Index", "ReservationEquipment", new { area = "UserPanel" }); } return(View("Modify", model)); }
public IActionResult Details(string id) { Reservation reservation = context.Reservations.Find(id); RoomViewModel room = new RoomViewModel(reservation.Room.Id, reservation.Room.Capacity, reservation.Room.Type, reservation.Room.IsFree, reservation.Room.Number); UserViewModel creator = new UserViewModel(reservation.Creator.Id, reservation.Creator.UserName, reservation.Creator.Email, reservation.Creator.FirstName, reservation.Creator.MiddleName, reservation.Creator.LastName, reservation.Creator.IsActive); List <ClientViewModel> clients = reservation.ClientReservations .Select(cr => new ClientViewModel(cr.Client.Id, cr.Client.FirstName, cr.Client.LastName, cr.Client.IsAdult)) .OrderBy(c => c.FirstName) .ThenBy(c => c.LastName) .ToList(); ReservationDetailsViewModel model = new ReservationDetailsViewModel(id, room, creator, clients, reservation.CheckInDate, reservation.CheckOutDate, reservation.IsBreakfastIncluded, reservation.IsAllInclusive, reservation.Price); return(View(model)); }
public async Task <IActionResult> Edit(int id, ReservationDetailsViewModel ojbDetailsViewModel) { if (ModelState.IsValid) { ojbDetailsViewModel.Reservation.ReservationDate = ojbDetailsViewModel.Reservation.ReservationDate .AddHours(ojbDetailsViewModel.Reservation.ReservationTime.Hour) .AddHours(ojbDetailsViewModel.Reservation.ReservationTime.Minute); var reservationFromDB = _db.Reservation.Where(a => a.Id == ojbDetailsViewModel.Reservation.Id) .FirstOrDefault(); reservationFromDB.CustomerName = ojbDetailsViewModel.Reservation.CustomerName; reservationFromDB.CustomerEmail = ojbDetailsViewModel.Reservation.CustomerEmail; reservationFromDB.CustomerPhoneNumber = ojbDetailsViewModel.Reservation.CustomerPhoneNumber; reservationFromDB.ReservationDate = ojbDetailsViewModel.Reservation.ReservationDate; reservationFromDB.isConfirmed = ojbDetailsViewModel.Reservation.isConfirmed; if (User.IsInRole(SD.SuperAdminEndUser)) { reservationFromDB.StoreId = ojbDetailsViewModel.Reservation.StoreId; } _db.SaveChanges(); } return(View(ojbDetailsViewModel)); }
public IActionResult ReservationDetails(int?id) { var model = new ReservationDetailsViewModel(); model.Email = _context.Reservations.Find(id).Email; var passengers = new List <SinglePassengerViewModel>(); foreach (var item in _context.Passengers.Where(p => p.ReservationId == id)) { var passenger = new SinglePassengerViewModel { Id = item.Id, FirstName = item.FirstName, Surname = item.Surname, LastName = item.Lastname, USN = item.USN, PhoneNumber = item.PhoneNumber, Nationality = item.Nationality, TicketType = item.TicketType, ReservationId = item.ReservationId }; passengers.Add(passenger); } model.Passengers = passengers; return(View(model)); }
public ReservationDetails(Reservation reservation) { InitializeComponent(); BindingContext = new ReservationDetailsViewModel(reservation) { Navigation = this.Navigation }; }
// Methods #region Methods private void OpenReservationDetails(object arg) { if (SelectedReservation != null) { ReservationDetails = new ReservationDetailsViewModel(SelectedReservation.Id, _reservationService, _patientService); ReservationDetails.DetailsClosed += ReservationDetails_DetailsClosed; ReservationDetails.ReservationSubmitted += ReservationDetails_ReservationSubmitted; } }
public ViewResult ReservationDetails(int id) { ReservationDetailsViewModel reservationDetailsViewModel = new ReservationDetailsViewModel() { UserID = userManager.GetUserId(User), Reservation = _reservationRepository.GetReservation(id), Room = _roomRepository.GetRoom(id), }; return(View(reservationDetailsViewModel)); }
public ActionResult ReservationDetails(int reservationId) { var reservation = reservationRepository.Get(reservationId); var tenant = tenantRepository.Get(reservation.TenantId); var model = new ReservationDetailsViewModel { startTime = reservation.StartTime, endTime = reservation.EndTime, TenantName = tenant.Name, TenantSurname = tenant.Surname }; return(View(model)); }
// GET: Reservations/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var result = db.Reservations .Join(db.ChargingPoints, reser => reser.ChargingPoint, charg => charg, (reser, charg) => new { Reser = reser, Charg = charg } ) .Join(db.Stations, joined => joined.Charg.Station, stat => stat, (joined, stat) => new { Joined = joined, Stat = stat } ) .Where(e => e.Joined.Reser.Id == id) .Select(e => new { Reservation = e.Joined.Reser, StationName = e.Stat.Name }).First(); ReservationDetailsViewModel reservation = new ReservationDetailsViewModel(result.Reservation, result.StationName); if (reservation == null) { return(HttpNotFound()); } return(PartialView(reservation)); }
//Get Edit public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } var productList = (IEnumerable <Products>)(from p in _db.Products join a in _db.ProductReserved on p.Id equals a.ProductId where a.ReservationId == id select p).Include("ProductTypes"); ReservationDetailsViewModel objReservationViewModel = new ReservationDetailsViewModel() { Reservation = _db.Reservation.Include(a => a.StoreUser).Where(a => a.Id == id).FirstOrDefault(), StoreUser = _db.ApplicationUser.ToList(), Products = productList.ToList() }; return(View(objReservationViewModel)); }
public ActionResult Create(ReservationDetailsViewModel model) // int availabilityId, string locationName, DateTime? availabilityDateFrom, DateTime? availabilityDateTo, DateTime? dateFrom, DateTime? dateTo { return(View("Modify", model)); }
public async Task GetAllAsyncReturnsAllReservationForTheUser() { await this.AddTestingUserToDb(); await this.AddTestingCountryToDb(); await this.AddTestingDestinationToDb(); await this.AddTestingRestaurantToDb(); this.DbContext.Reservations.Add(new Reservation { Id = 1, UserId = testUserId, RestaurantId = TestRestaurantId, Date = testReservationDateTime, PeopleCount = TestPeopleCount, }); this.DbContext.Reservations.Add(new Reservation { Id = 2, UserId = testUserId, RestaurantId = TestRestaurantId, Date = testReservationDateTime.AddDays(1), PeopleCount = TestPeopleCount, }); await this.DbContext.SaveChangesAsync(); var expected = new ReservationDetailsViewModel[] { new ReservationDetailsViewModel { Id = 1, UserId = testUserId, RestaurantId = TestRestaurantId, Date = testReservationDateTime, PeopleCount = TestPeopleCount, }, new ReservationDetailsViewModel() { Id = 2, UserId = testUserId, RestaurantId = TestRestaurantId, Date = testReservationDateTime.AddDays(1), PeopleCount = TestPeopleCount, } }; var actual = await this.ReservationsServiceMock.GetAllAsync(TestUsername); Assert.Collection(actual, elem1 => { Assert.Equal(expected[0].Id, elem1.Id); Assert.Equal(expected[0].UserId, elem1.UserId); Assert.Equal(expected[0].RestaurantId, elem1.RestaurantId); Assert.Equal(expected[0].Date, elem1.Date); Assert.Equal(expected[0].PeopleCount, elem1.PeopleCount); }, elem2 => { Assert.Equal(expected[1].Id, elem2.Id); Assert.Equal(expected[1].UserId, elem2.UserId); Assert.Equal(expected[1].RestaurantId, elem2.RestaurantId); Assert.Equal(expected[1].Date, elem2.Date); Assert.Equal(expected[1].PeopleCount, elem2.PeopleCount); }); Assert.Equal(expected.Length, actual.Count()); }
public async Task GetAllAsyncDoesNotReturnAnotherUsersReservations() { await this.AddTestingUserToDb(); await this.AddTestingCountryToDb(); await this.AddTestingDestinationToDb(); await this.AddTestingRestaurantToDb(); this.DbContext.Reservations.Add(new Reservation { Id = 1, UserId = testUserId, RestaurantId = TestRestaurantId, Date = testReservationDateTime, PeopleCount = TestPeopleCount, }); this.DbContext.Reservations.Add(new Reservation { Id = 2, UserId = Guid.NewGuid().ToString(), RestaurantId = TestRestaurantId, Date = testReservationDateTime.AddDays(1), PeopleCount = TestPeopleCount, }); this.DbContext.Reservations.Add(new Reservation { Id = 3, UserId = Guid.NewGuid().ToString(), RestaurantId = TestRestaurantId, Date = testReservationDateTime.AddDays(1), PeopleCount = TestPeopleCount, }); await this.DbContext.SaveChangesAsync(); var expected = new ReservationDetailsViewModel[] { new ReservationDetailsViewModel { Id = 1, UserId = testUserId, RestaurantId = TestRestaurantId, Date = testReservationDateTime, PeopleCount = TestPeopleCount, }, }; var actual = await this.ReservationsServiceMock.GetAllAsync(TestUsername); Assert.Collection(actual, elem1 => { Assert.Equal(expected[0].Id, elem1.Id); Assert.Equal(expected[0].UserId, elem1.UserId); Assert.Equal(expected[0].RestaurantId, elem1.RestaurantId); Assert.Equal(expected[0].Date, elem1.Date); Assert.Equal(expected[0].PeopleCount, elem1.PeopleCount); }); Assert.Equal(expected.Length, actual.Count()); }
public ReservationDetailPage(ReservationDetailsViewModel viewModel) { InitializeComponent(); BindingContext = this.viewModel = viewModel; }
public ActionResult Details(int id) { ReservationDetailsViewModel model = this.reservationsService.GetById <ReservationDetailsViewModel>(id); return(this.View(model)); }
public IActionResult Details(int id) { ReservationDetailsViewModel model = reservationService.GetById <ReservationDetailsViewModel>(id); return(View(model)); }