Exemplo n.º 1
0
        public void AddRestaurant(RestaurantRequestDto requestDto)
        {
            RestaurantEntity toAdd = new RestaurantEntity
            {
                Name           = requestDto.Name,
                Address        = requestDto.Address,
                FamilyFriendly = requestDto.FamilyFriendly,
                VeganOptions   = requestDto.VeganOptions,
                Rating         = requestDto.Rating
            };

            _restaurantRepository.Add(toAdd);

            foreach (int id in requestDto.CuisineTagIds)
            {
                _restaurantRepository.AddCuisineTag(new RestaurantCuisineEntity
                {
                    CuisineId    = id,
                    RestaurantId = toAdd.Id
                });
            }

            if (!_restaurantRepository.Save())
            {
                throw new Exception("Creating a item failed on save.");
            }
        }