Ejemplo n.º 1
0
        public async Task UpdateCartItemAsync(int itemId, int quantity)
        {
            var item = _dbContext
                       .ShoppingCart
                       .First(c => c.ItemId == itemId);

            item.Quantity = quantity;
            item.AddedOn  = DateTime.Now;

            _dbContext.Entry(item).State = EntityState.Modified;
            await _dbContext.SaveChangesAsync();
        }
Ejemplo n.º 2
0
        public async Task <Customer> UpdateCustomerAsync(string email, string address1, string address2, string city, string region, string postalCode, string country, int shippingRegionId)
        {
            var customer = await _dbContext
                           .Customer
                           .FirstOrDefaultAsync(c => c.Email == email);

            customer.Address1         = address1;
            customer.Address2         = address2;
            customer.City             = city;
            customer.Region           = region;
            customer.PostalCode       = postalCode;
            customer.Country          = country;
            customer.ShippingRegionId = shippingRegionId;

            _dbContext.Entry(customer).State = EntityState.Modified;
            await _dbContext.SaveChangesAsync();

            return(customer);
        }
Ejemplo n.º 3
0
        public async Task UpdatePaidOrderAsync(string orderId)
        {
            var id    = int.Parse(orderId);
            var order = await _dbContext
                        .Orders
                        .FirstOrDefaultAsync(c => c.OrderId == id);

            // Update the Order with payment
            if (order != null)
            {
                order.AuthCode  = "PAID";
                order.Status    = OrderStatus.Paid;
                order.ShippedOn = DateTime.Now;

                _dbContext.Entry(order).State = EntityState.Modified;
                await _dbContext.SaveChangesAsync();
            }
        }