Example #1
0
        public async Task <NotificationResult> CreateShoplistWithIngredientsAsync(InsertShoplistWithIngredientsCommand command)
        {
            BeginTransaction();
            var result = await _handler.CreateShoplistWithIngredients(command);

            return(Commit(result));
        }
Example #2
0
        public async Task <NotificationResult> CreateShoplistWithIngredients(InsertShoplistWithIngredientsCommand command)
        {
            var result = new NotificationResult();
            var item   = new ShoplistInfo(command);

            result.Add(item.GetNotificationResult());
            if (!result.IsValid)
            {
                return(result);
            }
            result.Add(await _shoplistRepository.InsertAsync(item));
            if (result.IsValid)
            {
                result.Data = item.Id;

                /*
                 * foreach (var shoplistItem in command.ShoplistsIngredients)
                 * {
                 *  shoplistItem.SetId(item.Id.Value);
                 *  await _shoplistIngredientRepository.InsertAsync(shoplistItem);
                 * }*/

                result.AddMessage(Shared.Domain.Resources.Handler.InsertSuccess_Message);
            }
            else
            {
                result.AddErrorOnTop(Shared.Domain.Resources.Handler.InsertError_Message);
            }
            return(result);
        }
 public ShoplistInfo(InsertShoplistWithIngredientsCommand command)
 {
     Map(command);
     InitCollections();
     foreach (var shoplistIngredientCommand in command.ShoplistsIngredients)
     {
         ShoplistsIngredients.Add(new ShoplistIngredientInfo(shoplistIngredientCommand));
     }
     this.InsertOrUpdateScopeValidate();
 }
        public async Task <IActionResult> Post([FromBody] InsertShoplistWithIngredientsCommand command)
        {
            var result = await _service.CreateShoplistWithIngredientsAsync(command);

            return(Ok(result));
        }