Beispiel #1
0
        public async Task UpdateRestaurantMenuAsync(UpdateStoreItemRequestModel requestModel)
        {
            var restaurant = await GetRestaurantByIdAsync(requestModel.Id);

            var menuItem = requestModel;

            if (string.IsNullOrEmpty(menuItem.Id))
            {
                var dtoMenuItem = new StoreItem()
                {
                    Id                  = Guid.NewGuid().ToString(),
                    Name                = menuItem.Name,
                    Material            = menuItem.Material,
                    IsAnimalCrueltyFree = menuItem.IsAnimalCrueltyFree,
                    Price               = menuItem.Price,
                    ItemType            = menuItem.ItemType
                };

                restaurant.Collections.Add(dtoMenuItem);
            }
            else
            {
                for (int i = 0; i < restaurant.Collections.Count; i++)
                {
                    if (restaurant.Collections[i].Id == menuItem.Id)
                    {
                        restaurant.Collections[i].Id                  = menuItem.Id;
                        restaurant.Collections[i].Name                = menuItem.Name;
                        restaurant.Collections[i].Material            = menuItem.Material;
                        restaurant.Collections[i].Price               = menuItem.Price;
                        restaurant.Collections[i].IsAnimalCrueltyFree = menuItem.IsAnimalCrueltyFree;
                        restaurant.Collections[i].ItemType            = menuItem.ItemType;
                        break;
                    }
                }
            }

            await _restaurantRepository.UpdateRestaurantAsync(restaurant);
        }
        public async Task <IActionResult> UpdateStoreCollectionAsync([FromBody] UpdateStoreItemRequestModel requestModel)
        {
            await _storeService.UpdateRestaurantMenuAsync(requestModel);

            return(Ok());
        }