Exemplo n.º 1
0
        public async Task <bool> CreateReviewAsync(CustomerReview customerReview)
        {
            await _dbContext.AddAsync(customerReview);

            await _dbContext.SaveChangesAsync();

            return(true);
        }
Exemplo n.º 2
0
        public async Task <bool> CreateCustomerAsync(Customer customer)
        {
            await _dbContext.Customer.AddAsync(customer);

            var result = await _dbContext.SaveChangesAsync();

            return(result > 0);
        }
Exemplo n.º 3
0
        public async Task <bool> CreateAccountAsync(Account account)
        {
            await _dbContext.Account.AddAsync(account);

            var result = await _dbContext.SaveChangesAsync();

            return(result > 0);
        }
Exemplo n.º 4
0
        public async Task <bool> CreateBrandAsync(Brand brand)
        {
            await _dbContext.Brand.AddAsync(brand);

            var result = await _dbContext.SaveChangesAsync();

            return(result > 0);
        }
Exemplo n.º 5
0
        public async Task <bool> CreateStoreAsync(Store store)
        {
            await _dbContext.Store.AddAsync(store);

            await _dbContext.SaveChangesAsync();

            return(true);
        }
Exemplo n.º 6
0
        public async Task <bool> CreateCategoryAsync(Category category)
        {
            await _dbContext.Category.AddAsync(category);

            var result = await _dbContext.SaveChangesAsync();

            return(result > 0);
        }
Exemplo n.º 7
0
        public async Task <bool> CreateProductAsync(Product product)
        {
            await _dbContext.Product.AddAsync(product);

            var result = await _dbContext.SaveChangesAsync();

            return(result > 0);
        }
Exemplo n.º 8
0
        public async Task <bool> CreateOrderAsync(CustomerOrder order)
        {
            // await using var transaction = await _dbContext.Database.BeginTransactionAsync();

            try
            {
                await _dbContext.CustomerOrder.AddAsync(order);

                await _dbContext.SaveChangesAsync();

                // await transaction.CommitAsync();
            }
            catch
            {
                // await transaction.RollbackAsync();
                return(false);
            }

            return(true);
        }
Exemplo n.º 9
0
        public async Task <bool> CreateBasketItemAsync(string customerIdentifier, int productId)
        {
            int customerId = int.Parse(customerIdentifier);

            var customer = await _customerRepository.GetCustomerByIdAsync(customerId);

            if (customer == null)
            {
                return(false);
            }

            if (customer.CustomerBasket == null)
            {
                var newBasket = new CustomerBasket()
                {
                    CustomerId = customer.CustomerId,
                };

                await _dbContext.CustomerBasket.AddAsync(newBasket);

                bool status = await _dbContext.SaveChangesAsync() > 0;

                if (!status)
                {
                    return(false);
                }

                customer.CustomerBasket = newBasket;
            }

            await _dbContext.BasketItem.AddAsync(new BasketItem()
            {
                BasketId  = customer.CustomerBasket.BasketId,
                ProductId = productId,
                Amount    = 1
            });

            return(await _dbContext.SaveChangesAsync() > 0);
        }