private async Task UpdateRestaurantInRepository(RestaurantAddUpdateModel restaurantAddUpdateModel) { var restaurantImage = restaurantsImagesRepository.GetRestaurantImage(restaurantAddUpdateModel.Restaurant.EntityId); restaurantAddUpdateModel.Restaurant.Image.RestaurantId = restaurantAddUpdateModel.Restaurant.RestaurantId; restaurantsImagesRepository.Remove(restaurantImage); restaurantImage = restaurantAddUpdateModel.Restaurant.Image; restaurantAddUpdateModel.Restaurant.Image = null; restaurantsRepository.Update(restaurantAddUpdateModel.Restaurant); await restaurantsImagesRepository.AddAsync(restaurantImage); }
public async Task <IActionResult> AddRestaurant([FromBody] RestaurantAddUpdateModel restaurantAddUpdateModel) { try { if (!IsRestaurantModifyingAllow(restaurantAddUpdateModel.AccountId, restaurantAddUpdateModel.Restaurant)) { return(BadRequest(noRightsForModifying)); } var addedRestaurant = await restaurantsRepository.AddAsync(restaurantAddUpdateModel.Restaurant); return(Ok()); } catch (Exception ex) { return(BadRequest(ex.Message)); } }