Beispiel #1
0
 public void Handle(ShoppingCartAddedProduct e)
 {
     using (var db = new CoreEcommerceDbContext())
     {
         var temp = db.ShoppingCartItems.SingleOrDefault(i => i.ProductId == e.ProductId && i.ShoppingCartId == e.Id);
         if (temp != null)
         {
             temp.Quantity   = e.Quantity;
             temp.UnitPrice  = e.UnitPrice;
             temp.TotalPrice = e.TotalPrice;
         }
         else
         {
             db.ShoppingCartItems.Add(new ShoppingCartItem()
             {
                 ShoppingCartId = e.Id,
                 CreatedDate    = e.CreatedDate,
                 Quantity       = e.Quantity,
                 ProductId      = e.ProductId,
                 UnitPrice      = e.UnitPrice,
                 TotalPrice     = e.TotalPrice,
             });
         }
         db.SaveChanges();
     }
 }
Beispiel #2
0
 public void Handle(PaymentTransactionFailed e)
 {
     using (var db = new CoreEcommerceDbContext())
     {
         var temp = db.PaymentTransactions.SingleOrDefault(i => i.Id == e.Id);
         temp.Status = (short)Enums.ShoppingCartPayStatus.PaymentFail;
         db.SaveChanges();
     }
 }
Beispiel #3
0
 public void Handle(ShoppingCartRemovedAllProduct e)
 {
     using (var db = new CoreEcommerceDbContext())
     {
         var temp = db.ShoppingCartItems.Where(i => i.ShoppingCartId == e.Id);
         db.ShoppingCartItems.RemoveRange(temp);
         db.SaveChanges();
     }
 }
Beispiel #4
0
        public void Delete(Guid id)
        {
            using (var db = new CoreEcommerceDbContext())
            {
                var temp = db.Suppliers.SingleOrDefault(i => i.Id == id);
                db.Suppliers.Remove(temp);

                db.SaveChanges();
            }
        }
Beispiel #5
0
 public void Handle(ShoppingCartUpdatedShipStatus e)
 {
     using (var db = new CoreEcommerceDbContext())
     {
         var temp = db.ShoppingCarts.SingleOrDefault(i => i.Id == e.Id);
         if (temp != null)
         {
             temp.ShippingStatus = e.ShipStatus;
             db.SaveChanges();
         }
     }
 }
Beispiel #6
0
 public void Handle(ShoppingCartClosedOrder e)
 {
     using (var db = new CoreEcommerceDbContext())
     {
         var temp = db.ShoppingCarts.SingleOrDefault(i => i.Id == e.Id);
         if (temp != null)
         {
             temp.Status = (short)Enums.ShoppingCartStatus.OrderClosed;
             db.SaveChanges();
         }
     }
 }
Beispiel #7
0
 public void Handle(VoucherCodeDeleted e)
 {
     using (var db = new CoreEcommerceDbContext())
     {
         var vc = db.VoucherCodes.SingleOrDefault(i => i.Id == e.Id);
         if (vc != null)
         {
             db.VoucherCodes.Remove(vc);
             db.SaveChanges();
         }
     }
 }
Beispiel #8
0
 public void Handle(ShoppingCartPromotionCalulatedForOrderShipping e)
 {
     using (var db = new CoreEcommerceDbContext())
     {
         var temp = db.ShoppingCarts.SingleOrDefault(i => i.Id == e.ShoppingCartId);
         if (temp != null)
         {
             temp.OrderPromotionId = e.OrderPromotionId;
             db.SaveChanges();
         }
     }
 }
Beispiel #9
0
 public void Handle(ShoppingCartReceivingTimeUpdated e)
 {
     using (var db = new CoreEcommerceDbContext())
     {
         var temp = db.ShoppingCarts.SingleOrDefault(i => i.Id == e.Id);
         if (temp != null)
         {
             temp.ReceivingTime = e.ReceivingTime;
             db.SaveChanges();
         }
     }
 }
Beispiel #10
0
 public void Handle(ShoppingCartLabelPackedAndPrinted e)
 {
     using (var db = new CoreEcommerceDbContext())
     {
         var temp = db.ShoppingCarts.SingleOrDefault(i => i.Id == e.Id);
         if (temp != null)
         {
             temp.PackingStatus = (short)Enums.ShoppingCartPackingStatus.PackingDone;
             db.SaveChanges();
         }
     }
 }
Beispiel #11
0
 public void Handle(ProductPriceChanged e)
 {
     using (var db = new CoreEcommerceDbContext())
     {
         var temp = db.Products.SingleOrDefault(i => i.Id == e.Id);
         if (temp != null)
         {
             temp.Price = e.Price;
         }
         db.SaveChanges();
     }
 }
Beispiel #12
0
 public void Handle(ProductBoughtByCustomer e)
 {
     using (var db = new CoreEcommerceDbContext())
     {
         var temp = db.Products.SingleOrDefault(i => i.Id == e.ProductId);
         if (temp != null)
         {
             temp.Quantity = e.Quantity;
         }
         db.SaveChanges();
     }
 }
Beispiel #13
0
        public void Handle(OrderPromotionDeleted e)
        {
            using (var db = new CoreEcommerceDbContext())
            {
                var temp = db.OrderPromotions.SingleOrDefault(i => i.Id == e.Id);
                if (temp != null)
                {
                    db.OrderPromotions.Remove(temp);

                    db.SaveChanges();
                }
            }
        }
Beispiel #14
0
 public void Handle(ShoppingCartCalculatedVoucherCode e)
 {
     using (var db = new CoreEcommerceDbContext())
     {
         var temp = db.ShoppingCarts.SingleOrDefault(i => i.Id == e.Id);
         if (temp != null)
         {
             temp.VoucherValue = e.VoucherValue;
             temp.VoucherCode  = e.VoucherCode;
             db.SaveChanges();
         }
     }
 }
Beispiel #15
0
 public void Handle(ShoppingCartCreatedOrderCode e)
 {
     using (var db = new CoreEcommerceDbContext())
     {
         var temp = db.ShoppingCarts.SingleOrDefault(i => i.Id == e.Id);
         if (temp != null)
         {
             temp.OrderCode       = e.OrderCode;
             temp.PaymentMethodId = e.PaymentMethodId;
             db.SaveChanges();
         }
     }
 }
Beispiel #16
0
 public void Handle(ShoppingCartCalculatedShipping e)
 {
     using (var db = new CoreEcommerceDbContext())
     {
         var temp = db.ShoppingCarts.SingleOrDefault(i => i.Id == e.Id);
         if (temp != null)
         {
             temp.ShippingFee      = e.ShippingFee;
             temp.ShippingMethodId = e.ShippingMethodId;
             db.SaveChanges();
         }
     }
 }
Beispiel #17
0
        public void Handle(OrderPromotionInactived e)
        {
            using (var db = new CoreEcommerceDbContext())
            {
                var temp = db.OrderPromotions.SingleOrDefault(i => i.Id == e.Id);
                if (temp != null)
                {
                    temp.Actived = false;

                    db.SaveChanges();
                }
            }
        }
        public void Handle(UpdateShippingMethod c)
        {
            using (var db = new CoreEcommerceDbContext())
            {
                var temp = db.ShippingMethods.SingleOrDefault(i => i.Id == c.Id);
                if (temp != null)
                {
                    temp.UnitCost = c.UnitCost;
                    db.SaveChanges();
                }
            }

            _eventPublisher.Publish(new ContentLanguageUpdated(c.Id, c.LanguageId, "Description", c.Description, "ShippingMethod"));
        }
Beispiel #19
0
 public void Handle(OrderPromotionUpdated e)
 {
     using (var db = new CoreEcommerceDbContext())
     {
         var temp = db.OrderPromotions.SingleOrDefault(i => i.Id == e.Id);
         if (temp != null)
         {
             temp.AmountToDiscount = e.AmountToDiscount;
             temp.DiscountAmount   = e.DiscountAmount;
             temp.FreeShip         = e.FreeShip;
             db.SaveChanges();
         }
     }
 }
Beispiel #20
0
 public void Handle(VoucherCodeApplied e)
 {
     using (var db = new CoreEcommerceDbContext())
     {
         var vc = db.VoucherCodes.SingleOrDefault(i => i.Code.Equals(e.Code));
         if (vc != null)
         {
             vc.AppliedForUserId    = e.UserId;
             vc.AppliedForOrderCode = e.OrderCode;
             vc.Applied             = true;
             db.SaveChanges();
         }
     }
 }
Beispiel #21
0
 public void Handle(ShoppingCartItemAppliedProductPromotion e)
 {
     using (var db = new CoreEcommerceDbContext())
     {
         var temp = db.ShoppingCartItems
                    .SingleOrDefault(i => i.ProductId == e.ProductId && i.ShoppingCartId == e.Id);
         if (temp != null)
         {
             temp.ProductDiscount    = e.ProductDiscount;
             temp.ProductPromotionId = e.ProductPromotionId;
             db.SaveChanges();
         }
     }
 }
 public void Handle(ProductPromotionUpdated e)
 {
     using (var db = new CoreEcommerceDbContext())
     {
         var temp = db.ProductPromotions.SingleOrDefault(i => i.Id == e.Id);
         if (temp != null)
         {
             temp.ProductQuantity = e.ProductQuantity;
             temp.DiscountValue   = e.DiscountValue;
             temp.FromDate        = e.FromDate;
             temp.ToDate          = e.ToDate;
             db.SaveChanges();
         }
     }
 }
Beispiel #23
0
 public void Handle(ShoppingCartPreCalculated e)
 {
     using (var db = new CoreEcommerceDbContext())
     {
         var temp = db.ShoppingCarts.SingleOrDefault(i => i.Id == e.Id);
         if (temp != null)
         {
             temp.CartTotal    = e.CartTotal;
             temp.CartDiscount = e.CartDiscount;
             temp.CartSubTotal = e.CartSubTotal;
             temp.CartTax      = e.CartTax;
             db.SaveChanges();
         }
     }
 }
Beispiel #24
0
 public void Handle(ProductUpdated e)
 {
     using (var db = new CoreEcommerceDbContext())
     {
         var temp = db.Products.SingleOrDefault(i => i.Id == e.Id);
         if (temp != null)
         {
             temp.Quantity     = e.Quantity;
             temp.ProductCode  = e.ProductCode;
             temp.AllowComment = e.AllowComment;
             temp.Gram         = e.Gram;
             temp.Calorie      = e.Calorie;
         }
         db.SaveChanges();
     }
 }
 public void Handle(ProductPromotionCreated e)
 {
     using (var db = new CoreEcommerceDbContext())
     {
         db.ProductPromotions.Add(new ProductPromotion()
         {
             Id              = e.Id,
             CreatedDate     = DateTime.Now,
             ProductQuantity = e.Quantity,
             DiscountValue   = e.DiscountValue,
             ToDate          = e.ToDate,
             FromDate        = e.FromDate
         });
         db.SaveChanges();
     }
 }
Beispiel #26
0
 public void Handle(OrderPromotionCreated e)
 {
     using (var db = new CoreEcommerceDbContext())
     {
         db.OrderPromotions.Add(new OrderPromotion()
         {
             Id               = e.Id,
             FreeShip         = e.FreeShip,
             Actived          = false,
             AmountToDiscount = e.AmountToDiscount,
             DiscountAmount   = e.DiscountAmount,
             CreatedDate      = DateTime.Now
         });
         db.SaveChanges();
     }
 }
Beispiel #27
0
        public void Handle(ProductRemovedImages e)
        {
            using (var db = new CoreEcommerceDbContext())
            {
                foreach (var imgurl in e.UrlImages)
                {
                    var temp = db.PhotoGalleries.FirstOrDefault(i => i.Id == e.Id &&
                                                                i.UrlImage.Equals(imgurl, StringComparison.OrdinalIgnoreCase));
                    if (temp != null)
                    {
                        db.PhotoGalleries.Remove(temp);
                    }
                }

                db.SaveChanges();
            }
        }
Beispiel #28
0
 public void Handle(ShoppingCartRemovedProduct e)
 {
     using (var db = new CoreEcommerceDbContext())
     {
         var temp = db.ShoppingCartItems.SingleOrDefault(i => i.ProductId == e.ProductId && i.ShoppingCartId == e.Id);
         if (temp != null)
         {
             temp.Quantity   = e.Quantity;
             temp.TotalPrice = e.TotalPrice;
             if (temp.Quantity <= 0)
             {
                 db.ShoppingCartItems.Remove(temp);
             }
             db.SaveChanges();
         }
     }
 }
Beispiel #29
0
 public void Handle(PaymentTransactionCreated e)
 {
     using (var db = new CoreEcommerceDbContext())
     {
         db.PaymentTransactions.Add(new PaymentTransaction()
         {
             Id = e.Id,
             PaymentMethodId = e.PaymentMethodId,
             Amount          = e.Amount,
             CreatedDate     = e.CreatedDate,
             OrderCode       = e.OrderCode,
             UrlRedirect     = e.UrlRedirect,
             Status          = (short)Enums.ShoppingCartPayStatus.PaymentCreated,
             IpAddress       = e.IpAddress
         });
         db.SaveChanges();
     }
 }
Beispiel #30
0
 public void Handle(ShoppingCartCheckedout e)
 {
     using (var db = new CoreEcommerceDbContext())
     {
         var temp = db.ShoppingCarts.SingleOrDefault(i => i.Id == e.Id);
         if (temp != null)
         {
             temp.Status       = (short)Enums.ShoppingCartStatus.Checkedout;
             temp.VoucherValue = e.VoucherValue;
             temp.VoucherCode  = e.VoucherCode;
             temp.CartTotal    = e.CartTotal;
             temp.CartDiscount = e.CartDiscount;
             temp.CartSubTotal = e.CartSubTotal;
             temp.CartTax      = e.CartTax;
             db.SaveChanges();
         }
     }
 }