Beispiel #1
0
        public async Task <ActionResult> Create([FromBody] CreateIngredientDTO ingredientDto)
        {
            var command = _mapper.Map <CreateIngredientCommand>(ingredientDto);

            var result = await _mediator.Send(command);

            return(CreatedAtAction(nameof(Get), new { result.Id }, result));
        }
        public async Task <ActionResult> Create([FromBody] CreateIngredientDTO dto)
        {
            using var uow = _unitOfWorkFactory.Create();

            var result = await _ingredientService.CreateIngredientAsync(
                dto.Name,
                dto.Description,
                dto.UnitPrice,
                dto.AvailableQuantity,
                dto.IsSpicy,
                dto.IsVegetarian,
                dto.IsVegan);

            uow.Commit();

            var resultDto = _mapper.Map <IngredientDTO>(result);

            return(CreatedAtAction(nameof(Get), new { resultDto.Id }, resultDto));
        }