Exemplo n.º 1
0
        public async Task <ActionResult <ProductOption> > PostProductOption(Guid id, ProductOption productOption)
        {
            var newProductOption = await productOptionService.AddProductOption(id, productOption);

            var productSummary = new ProductSummary()
            {
                Id       = newProductOption.Id,
                Name     = newProductOption.Name,
                Location = Url.Link("RetrieveProductOptions", new { id = newProductOption.Id })
            };

            return(CreatedAtRoute("RetrieveProductOptions", new { id = newProductOption.Id }, productSummary));
        }
Exemplo n.º 2
0
        public async Task <ActionResult <CreateProductOptionItemOutputModel> > Post(Guid aProductId, CreateProductOptionItemInputModel aModel)
        {
            try
            {
                AddProductOptionOutputDto result = await _aProductOptionService.AddProductOption(new AddProductOptionInputDto()
                {
                    Description = aModel.Description,
                    Name        = aModel.Name,
                    ProductId   = aModel.ProductId
                });

                if (result.ResultSuccess)
                {
                    CreateProductOptionItemOutputModel output = _aMapper.Map <CreateProductOptionItemOutputModel>(result);
                    return(output);
                }

                return(StatusCode(StatusCodes.Status500InternalServerError, result.ResultErrors.Messages.First()));
            }
            catch (Exception e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Server Error :" + e.Message));
            }
        }