Esempio n. 1
0
        public virtual async Task <NotificationResult> InsertAsync(InsertRecipeCommand command)
        {
            BeginTransaction();
            var result = await _handler.InsertAsync(command);

            return(Commit(result));
        }
Esempio n. 2
0
        public virtual async Task <NotificationResult> InsertAsync(InsertRecipeCommand command)
        {
            var result = new NotificationResult();
            var item   = new RecipeInfo(command);

            result.Add(item.GetNotificationResult());
            if (!result.IsValid)
            {
                return(result);
            }
            result.Add(await _recipeRepository.InsertAsync(item));

            if (result.IsValid)
            {
                if (command.RecipeIngredients != null && command.RecipeIngredients.Count > 0)
                {
                    foreach (var recipeIngredientCommand in command.RecipeIngredients)
                    {
                        var recipeIngredient = new RecipeIngredientInfo(recipeIngredientCommand);
                        recipeIngredient.SetRecipeId(item.Id.Value);
                        result.Add(await _recipeIngredientRepository.InsertAsync(recipeIngredient));
                    }
                }

                result.Data = item.Id;
                result.AddMessage(Shared.Domain.Resources.Handler.InsertSuccess_Message);
            }
            else
            {
                result.AddErrorOnTop(Shared.Domain.Resources.Handler.InsertError_Message);
            }
            return(result);
        }
        public async Task <IActionResult> Post([FromBody] InsertRecipeCommand command)
        {
            var result = await _service.InsertAsync(command);

            return(Ok(result));
        }
Esempio n. 4
0
 public RecipeInfo(InsertRecipeCommand command)
 {
     Map(command);
     InitCollections();
     this.InsertOrUpdateScopeValidate();
 }
Esempio n. 5
0
 public async Task <IActionResult> Post(InsertRecipeCommand request)
 => Ok(await _mediator.Send(request));