示例#1
0
        public async Task <IActionResult> UpdateRestaurant([FromBody] RestaurantOnUpdateDto updatedRestaurant, Guid restaurantId)
        {
            if (!ModelState.IsValid)
            {
                return(StatusCode(420, ModelState));
            }

            await _restaurantService.UpdateAsync(updatedRestaurant, restaurantId);

            return(Ok());
        }
示例#2
0
        public async Task UpdateAsync(RestaurantOnUpdateDto restaurantDto, Guid restaurantId)
        {
            var restaurantToUpdate = await _restaurantRepository.GetAsync(restaurantId);

            if (restaurantToUpdate == null)
            {
                throw new ServiceException(ErrorCodes.RestaurantNotFound, "Restaurant doesn't exist.");
            }

            restaurantToUpdate.Name                   = restaurantDto.Name;
            restaurantToUpdate.Description            = restaurantDto.Description;
            restaurantToUpdate.Cuisine                = restaurantDto.Cuisine;
            restaurantToUpdate.Localization           = restaurantDto.Localization;
            restaurantToUpdate.RepresentativePhotoUrl = restaurantDto.RepresentativePhotoUrl;
            restaurantToUpdate.Tables                 = restaurantDto.Tables;

            await _restaurantRepository.UpdateAsync(restaurantToUpdate);
        }