public QueryReservation[] GetReservations(string orderBy, SearchReservation r) { string plate = r.Plate; string location = r.Location; int? customerId = r.CustomerId; DateTime?startDate = r.StartDate; DateTime?endDate = r.EndDate; bool isPlateEmpty = string.IsNullOrWhiteSpace(plate); bool isLocationEmpty = string.IsNullOrWhiteSpace(location); var reservations = from reservation in reservationsList join locationTable in locationsList on reservation.LocationId equals locationTable.Id join car in carsList on reservation.CarId equals car.Id where (customerId == null || reservation.CustomerId == customerId) && (startDate == null || reservation.StartDate >= startDate) && (endDate == null || reservation.EndDate <= endDate) && (!isPlateEmpty && car.Plate == plate || isPlateEmpty) && (!isLocationEmpty && locationTable.Name == location || isLocationEmpty) select new QueryReservation { Id = reservation.Id, Plate = car.Plate, CustomerId = reservation.CustomerId, StartDate = reservation.StartDate, EndDate = reservation.EndDate, Location = locationTable.Name }; return(OrderItems(reservations.AsQueryable(), orderBy)); }
public void SearchReservationTest() { int reservationId = 1; mockRepository.Setup(x => x.SearchReservation(reservationId)) .Returns(listaReservations.Where(y => y.ReservationId == reservationId).First); var handler = new SearchReservationHandler(mockRepository.Object); SearchReservation re = new SearchReservation(reservationId); var res = handler.Handle(re, ct); Assert.IsNotNull(res.Result); }
private void ReadReservation() { string plate = reader.ReadStringOptional("Car Plate: "); int? id = reader.ReadIntOptional("Client Id: "); DateTime?startDate = reader.ReadDateOptional("Start Date: "); DateTime?endDate = reader.ReadDateOptional("End Date: "); string location = reader.ReadStringOptional("Location: "); var reservation = new SearchReservation(); reservation.Plate = plate; reservation.CustomerId = id; reservation.StartDate = startDate; reservation.EndDate = endDate; reservation.Location = location; SetProps(reservation); }
public ActionResult ReservationList(ReservationViewModel viewModel, string orderBy = "Id") { if (!ModelState.IsValid) { return(View(new ReservationViewModel() { Reservations = new List <QueryReservation>() })); } SearchReservation r = viewModel.SearchReservation ?? new SearchReservation(); QueryManager queryManager = new QueryManager(carRepo, customerRepo, reservationRepo, locationRepo, modelRepo, manufacturerRepo); QueryReservation[] reservations = queryManager.GetReservations(orderBy, r); viewModel.Reservations = reservations; viewModel.SearchReservation = new SearchReservation(); return(View(viewModel)); }
public IHttpActionResult SearchReservations(SearchReservation searchReservation) { return(Ok(reservationManagement.SearchReservations(searchReservation.MembershipId, searchReservation.Email, searchReservation.Code, searchReservation.DateReservedFrom, searchReservation.DateReservedTo, searchReservation.IsConfirmed))); }