public ListaCompra AdicionarItem(int id, ItemCompra item)
        {
            try
            {
                item.ListaCompra = new ListaCompra {
                    Id = id
                };

                var entity = _listaCompraServico.AdicionaItem(id, item);
                foreach (var itemCompra in entity.Itens)
                {
                    itemCompra.Produto.Informacoes = itemCompra.Produto.Informacoes.Where(x => x.Tipo == (int)TipoInfoProduto.Imagem).ToList();
                }

                return(FitListaCompra(entity));
            }
            catch (NotFoundException)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
        }
Exemple #2
0
        public ListaCompra AdicionarItem(int id, ItemCompra item)
        {
            try
            {
                item.ListaCompra = new ListaCompra {
                    Id = id
                };

                var entity = _listaCompraServico.AdicionaItem(id, item);

                return(FitListaCompra(entity));
            }
            catch (NotFoundException)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            catch (Exception ex)
            {
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message));
            }
        }