public async Task <IActionResult> OnPostDelete(int customerId, int tripId, int carId)
        {
            await _carController.DeleteCar(carId);

            await _tripController.DeleteTrip(tripId);

            await _customerController.DeleteCustomer(customerId);

            Message = "Rezerwacja została pomyślnie usunięta.";
            return(RedirectToPage("AllTrips"));
        }
Example #2
0
        public void CallTripsServiceMethodDeleteTripOnce()
        {
            //Arrange
            var tripsServiceMock = new Mock <ITripsService>();
            var controller       = new TripController(
                this.usersServiceMock.Object,
                tripsServiceMock.Object,
                this.cacheServiceMock.Object,
                this.mapperMock.Object);

            //Act
            controller.DeleteTrip(It.IsAny <int>());

            //Assert
            tripsServiceMock.Verify(s => s.DeleteTrip(It.IsAny <Trip>()), Times.Once);
        }
Example #3
0
        public async Task DeleteTrip()
        {
            // Inject
            CreateIdentity(Users[0].Auth);

            // Arrange
            UserTrips trip;

            UserTrips[] remaining;
            using (var a = factory.CreateDbContext())
            {
                remaining = await a.UserTrips.Include(x => x.User).Where(x => x.User.Id == Users[0].Id).ToArrayAsync();

                trip = new UserTrips()
                {
                    UserId = Users[0].Id, Name = "Trip to somewhere", Transportation = "BICYCLING"
                };
                trip.Locations.Add(new Locations()
                {
                    WishlistId = null, PlaceId = "PlaceId4", TripId = trip.Id, Name = "kfg", Lang = 5, Long = 3
                });
                trip.Locations.Add(new Locations()
                {
                    WishlistId = null, PlaceId = "PlaceId5", TripId = trip.Id, Name = "aweawe", Lang = 15, Long = 33
                });

                await a.AddAsync(trip);

                await a.SaveChangesAsync();
            }


            var expected = mapper.Map <UserTripsViewModel[]>(remaining);

            // Act
            var result = await controller.DeleteTrip(trip.Id);

            // Assert
            Assert.Equal(Serialize(expected), Serialize(((OkObjectResult)result).Value));
        }