コード例 #1
0
        public ItemVendaDomain CriarParaSalvar(ItemVendaDto itemVendaDto)
        {
            var itemVenda = new ItemVendaBuilder()
                            .WithId(Guid.NewGuid())
                            .WithVenda(itemVendaDto.Venda)
                            .WithVendaId(itemVendaDto.VendaId)
                            .WithProduto(itemVendaDto.Produto)
                            .WithProdutoId(itemVendaDto.ProdutoId)
                            .WithQuantidade(itemVendaDto.Quantidade)
                            .WithVendaId(itemVendaDto.VendaId)
                            .Build();

            return(itemVenda);
        }
コード例 #2
0
        public ItemVendaDomain CriarParaAlterar(ItemVendaDto itemVendaDto)
        {
            var _itemVenda = Context.ItensVendas.FirstOrDefault(x => x.Id == itemVendaDto.Id);

            if (_itemVenda == null)
            {
                throw new ArgumentNullException(nameof(_itemVenda));
            }

            var itemVenda = new ItemVendaBuilder()
                            .WithId(_itemVenda.Id)
                            .WithProduto(_itemVenda.Produto)
                            .WithProdutoId(_itemVenda.ProdutoId)
                            .WithQuantidade(_itemVenda.Quantidade)
                            .WithVenda(_itemVenda.Venda)
                            .WithVendaId(_itemVenda.VendaId)
                            .Build();

            return(itemVenda);
        }