Пример #1
0
        public async Task <ILivro> IncluirLivroNoCarrinho(ICarrinhoLivro CarrinhoLivro, Carrinho Carrinho, Livro Livro)
        {
            if (CarrinhoLivro is null)
            {
                throw new ArgumentNullException(nameof(CarrinhoLivro));
            }


            if (Carrinho is null)
            {
                throw new ArgumentNullException(nameof(Carrinho));
            }


            if (Livro is null)
            {
                throw new ArgumentNullException(nameof(Livro));
            }


            ILivro    livro    = CarrinhoLivro.IncluirLivroCarrinho(this._CarrinhoFactory, Carrinho, Livro);
            ICarrinho carrinho = (ICarrinho)Carrinho;

            await this._CarrinhoRepository.AddLivro(CarrinhoLivro, carrinho, livro).ConfigureAwait(false);

            return(livro);
        }
Пример #2
0
        public async Task <ICarrinho> ExcluirCarrinho(ICarrinhoLivro CarrinhoLivro, Carrinho Carrinho)
        {
            if (CarrinhoLivro is null)
            {
                throw new ArgumentNullException(nameof(CarrinhoLivro));
            }

            if (Carrinho is null)
            {
                throw new ArgumentNullException(nameof(Carrinho));
            }

            bool result = false;

            result = CarrinhoLivro.ExcluirCarrinho(this._CarrinhoFactory, Carrinho);

            ICarrinho carrinho = (ICarrinho)Carrinho;

            if (result)
            {
                await this._CarrinhoRepository.Delete(CarrinhoLivro, carrinho).ConfigureAwait(false);
            }
            else
            {
                carrinho = null;
            }

            return(carrinho);
        }
Пример #3
0
        static void Main(string[] args)
        {
            ICarrinho combi = new ICarrinho();
            produto   p1    = new produto();

            p1.codigo = 102;
            p1.nome   = "GTA 5";
            p1.preco  = 200;
            produto p2 = new produto();

            p2.codigo = 103;
            p2.nome   = "Bully";
            p2.preco  = 200;
            produto p3 = new produto();

            p3.codigo = 104;
            p3.nome   = "Red Dead Redemption 2";
            p3.preco  = 200;
            combi.cadastra(p1);

            combi.cadastra(p2);

            combi.cadastra(p3);

            combi.listar();

            Console.WriteLine("\n adicionando.......\n");
            combi.cadastra(p1);
            combi.listar();
            Console.WriteLine("\n Removendo.......\n");
            combi.remover(102, p1);
            combi.remover(102, p1);
            combi.listar();
        }
 public PedidoService(ICarrinho carrinho, IPagamento pagamento, IEstoque estoqueService, IMail mailService,
                      ISms smsService)
 {
     _carrinhoService  = carrinho;
     _pagamentoService = pagamento;
     _estoqueService   = estoqueService;
     _mailService      = mailService;
     _smsService       = smsService;
 }
Пример #5
0
        public async Task <ICarrinho> CriarCarrinho(ICarrinhoLivro CarrinhoLivro, Carrinho Carrinho)
        {
            if (CarrinhoLivro is null)
            {
                throw new ArgumentNullException(nameof(CarrinhoLivro));
            }

            ICarrinho carrinho = CarrinhoLivro.IncluirCarrinho(this._CarrinhoFactory, Carrinho);

            await this._CarrinhoRepository.Add(CarrinhoLivro, carrinho).ConfigureAwait(false);

            return(carrinho);
        }
Пример #6
0
        public async Task <ILivro> RemoverLivroDoCarrinho(ICarrinhoLivro CarrinhoLivro, Carrinho Carrinho, Livro Livro)
        {
            if (CarrinhoLivro is null)
            {
                throw new ArgumentNullException(nameof(CarrinhoLivro));
            }


            if (Carrinho is null)
            {
                throw new ArgumentNullException(nameof(Carrinho));
            }


            if (Livro is null)
            {
                throw new ArgumentNullException(nameof(Livro));
            }


            bool result = CarrinhoLivro.ExcluirLivroCarrinho(this._CarrinhoFactory, Carrinho, Livro);

            ICarrinho carrinho = (ICarrinho)Carrinho;
            ILivro    livro    = (ILivro)Livro;

            if (result)
            {
                await this._CarrinhoRepository.DeleteLivro(CarrinhoLivro, carrinho, livro).ConfigureAwait(false);
            }
            else
            {
                livro = null;
            }

            return(livro);
        }