Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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);
        }