public async Task AddTable_InInvalidRestaurant_ShouldNotCreate()
        {
            var context = ReserveTableDbContextInMemoryFactory.InitializeContext();

            this.tableService = new TableService(context);
            await SeedData(context);

            AddTableBindingModel model = new AddTableBindingModel
            {
                SeatsCount = 5
            };

            RestaurantServiceModel restaurant = new RestaurantServiceModel
            {
                Id            = "3",
                Address       = "Ivan Vazov",
                AverageRating = 10,
                Name          = "Happy",
                PhoneNumber   = "08888888888",
                Photo         = "src/happy-photo.jpg",
                CityId        = "1"
            };

            await Assert.ThrowsAsync <ArgumentNullException>(() => tableService.AddTable(model, restaurant));
        }
Beispiel #2
0
        public async Task <IActionResult> Add(string city, string restaurant, AddTableBindingModel model)
        {
            RestaurantServiceModel restaurantFromDb = await restaurantService.GetRestaurantByNameAndCity(city, restaurant);

            if (ModelState.IsValid)
            {
                await tablesService.AddTable(model, restaurantFromDb);
            }

            return(this.Redirect($"/Tables/{city}/{restaurant}"));
        }