public void AddPhoto(RestaurantPhoto restaurantPhoto)
        {
            restaurantPhoto.PhotoTypeId =
                _restaurantPhotoRepository.Find(
                    p =>
                    p.RestaurantBranchId == restaurantPhoto.RestaurantBranchId &&
                    p.PhotoTypeId == (int)PhotoType.Primary).Any()
                    ? (int)PhotoType.Secondary
                    : (int)PhotoType.Primary;

            _restaurantPhotoRepository.Insert(restaurantPhoto);
            _restaurantPhotoRepository.SaveChanges();
        }
        public async Task <RestaurantPhoto> DeleteRestaurantPhoto(int restaurantPhotoId)
        {
            RestaurantPhoto dbEntry = dbContext.RestaurantPhotos.Find(restaurantPhotoId);

            if (dbEntry == null)
            {
                throw new InvalidOperationException("Restaurant photo not found");
            }
            dbContext.RestaurantPhotos.Remove(dbEntry);

            await dbContext.SaveChangesAsync();

            return(dbEntry);
        }
        public async Task <int> SaveRestaurantPhoto(RestaurantPhoto restaurantPhoto)
        {
            if (restaurantPhoto == null)
            {
                throw new ArgumentNullException(nameof(restaurantPhoto), "Parameter is null");
            }
            if (restaurantPhoto.Id == 0)
            {
                dbContext.RestaurantPhotos.Add(restaurantPhoto);
            }
            else
            {
                RestaurantPhoto dbEntry = dbContext.RestaurantPhotos.Find(restaurantPhoto.Id);
                if (dbEntry == null)
                {
                    throw new InvalidOperationException("Restaurant photo not found");
                }
                dbEntry.Photo = restaurantPhoto.Photo;
            }

            await dbContext.SaveChangesAsync();

            return(restaurantPhoto.Id);
        }