public async Task <IActionResult> InsertPizza([FromBody] PizzaRequest request)
        {
            Result <PizzaDto> response =
                await _pizzaService.InsertPizzaAsync(request);

            return(OkOrError(response));
        }
예제 #2
0
        public Result <global::Entities.Pizza.Domain.Pizza> CreatePizza(PizzaRequest request)
        {
            Result <IEnumerable <global::Entities.Pizza.Domain.Ingredient> > ingredientsOrError = GetPizzaIngredients(request.Ingredients);

            if (ingredientsOrError.IsFailure)
            {
                return(Result.FromError <global::Entities.Pizza.Domain.Pizza>(ingredientsOrError));
            }

            return(global::Entities.Pizza.Domain.Pizza.Create(Guid.NewGuid(),
                                                              DateTime.UtcNow,
                                                              request.Name,
                                                              request.Size,
                                                              ingredientsOrError.Value.ToList()));
        }
예제 #3
0
        public async Task <Result <PizzaDto> > InsertPizzaAsync(PizzaRequest request)
        {
            Result <Pizza> pizzaOrError = _pizzaRepository.CreatePizza(request);

            if (pizzaOrError.IsFailure)
            {
                return(Result.FromError <PizzaDto>(pizzaOrError));
            }

            _pizzaRepository.Insert(pizzaOrError.Value);

            //fire event here
            await _unitOfWork.SaveAsync();

            return(Result.Ok(pizzaOrError.Value.ToPizzaDto()));
        }