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(); } }
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(); } }
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(); } }
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(); } }
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(); } } }
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(); } } }
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(); } } }
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(); } } }
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(); } } }
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(); } } }
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(); } }
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(); } }
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(); } } }
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(); } } }
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(); } } }
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(); } } }
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")); }
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(); } } }
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(); } } }
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(); } } }
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(); } } }
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(); } }
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(); } }
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(); } }
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(); } } }
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(); } }
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(); } } }