예제 #1
0
        public void Add(RestaurantDTO modelDTO, IFormFile file, List <Cuisine> cuisines)
        {
            var model = MapModel(modelDTO);

            if (file != null)
            {
                _fileOnServer.Remove(model.PathToImage);
                model.PathToImage = _fileOnServer.Add(PathToFolder, file);
            }

            if (cuisines != null)
            {
                var restaurantCuisineService = new BindRestaurantWithCuisine(model, cuisines);

                var listRestaurantCuisine = restaurantCuisineService.Add();
                Db.RestaurantCuisines.AddRange(listRestaurantCuisine);
            }

            Db.Restaurants.Update(model);
        }
예제 #2
0
        private void AddCuisinesToRestaurant(BindRestaurantWithCuisine service)
        {
            var restaurantCuisines = service.Add();

            Db.RestaurantCuisines.AddRange(restaurantCuisines);
        }