public bool SaveEntity(List <ProductQuantityModel> quantitys) { if (quantitys != null && quantitys.Count > 0) { var productId = quantitys[0].ProductId; if (productId > 0) { var oldQuantity = _productQuantityRepository.FindAll().Where(q => q.ProductId == productId).ToList(); if (oldQuantity != null && oldQuantity.Count > 0) { _productQuantityRepository.RemoveMultiple(oldQuantity); } foreach (var item in quantitys) { _productQuantityRepository.Add(item.ToProductQuantity()); } Save(); return(true); } } return(false); }
public void AddProductQuantity(List <ProductQuantityViewModel> productQuantityVm) { var productQuantities = Mapper.Map <List <ProductQuantityViewModel>, List <ProductQuantity> >(productQuantityVm); foreach (var item in productQuantities) { _productQuantityRepository.Add(item); } }
public void AddQuantity(int productId, List <ProductQuantityViewModel> quantities) { _productQuantityRepository.RemoveMultiple(_productQuantityRepository.FindAll(x => x.ProductId == productId).ToList()); foreach (var quantity in quantities) { _productQuantityRepository.Add(new ProductQuantity() { ProductId = productId, ProductConditionId = quantity.ProductConditionId, Quantity = quantity.Quantity }); } }
public void CreateQuantities(int productId, List <ProductQuantityViewModel> quantities) { _productQuantityRepository.RemoveMultiple(_productQuantityRepository.FindAll(m => m.ProductId == productId).ToList()); foreach (var quantity in quantities) { _productQuantityRepository.Add(new ProductQuantity() { ProductId = productId, ColorId = quantity.ColorId, SizeId = quantity.SizeId, Quantity = quantity.Quantity }); } }
public void AddQuantity(int productId, List <ProductQuantityViewModel> quantities) { _productQuantityRepository.RemoveMultiple(_productQuantityRepository.FindAll(x => x.ProductId == productId).ToList()); foreach (var quantity in quantities) { _productQuantityRepository.Add(new ProductQuantity() { ProductId = productId, ColorId = quantity.ColorId, PerfumeId = quantity.PerfumeId, SizeId = quantity.SizeId, Quantity = quantity.Quantity, MoreImages = quantity.MoreImages }); } }
public async Task AddQuantity(int productId, List <ProductQuantityViewModel> quantities) { var dataNeedDelete = await _productQuantityRepository.FindAll(x => x.ProductId == productId); await _productQuantityRepository.RemoveMultiple(dataNeedDelete.AsNoTracking().ToList()); foreach (var quantity in quantities) { await _productQuantityRepository.Add(new ProductQuantity() { ProductId = productId, ColorId = quantity.ColorId, SizeId = quantity.SizeId, Quantity = quantity.Quantity }); } }
public void Add(ProductQuantity productImage) { _productQuantityRepository.Add(productImage); }
public int AddProductQuantity(ProductQuantity productQuantity) { return(_productQuantityRepository.Add(productQuantity).ProductQuantityID); }
public void AddEducationShoppingOrder(IEnumerable <DLModel.EducationShoppingCart> shoppingcart) { DLModel.Order order = new DLModel.Order(); order.UserID = shoppingcart.FirstOrDefault().UserID; order.OrderDate = DateTime.Now; order.OrderNumber = System.DateTime.Now.ToShortDateString().Replace("/", "").ToString(); int orderID = AddShoppingOrder(order); foreach (var item in shoppingcart) { if (item.CartType == "Course") { DLModel.EducationShopping educationShopping = new DLModel.EducationShopping(); educationShopping.OrderID = orderID; educationShopping.CoupanID = item.CoupanID; educationShopping.Date = DateTime.Now; educationShopping.EducationID = item.EduorProID; educationShopping.EducationTypeID = item.EducationTypeID; educationShopping.Quantity = item.Quantity; educationShopping.Grandtotal = item.Price * item.Quantity; educationShopping.UserID = item.UserID; educationShopping.ShippingPaymentID = item.ShippingPaymentID.Value; _educationShoppingRepository.Add((DLModel.EducationShopping) new DLModel.EducationShopping().InjectFrom(educationShopping)); DLModel.MyEducation myEducation = new DLModel.MyEducation(); myEducation.UserID = item.UserID; myEducation.EducationTypeID = item.EducationTypeID; myEducation.EducationID = item.EduorProID; myEducation.PurchaseDate = System.DateTime.Now.Date; myEducation.CredentialID = item.CredentialID; int MEID = _myEducatoinBL.AddMyEducation(myEducation); _myEducatoinBL.AddEducationModuleToMyEducationByEducationID(MEID, item.EduorProID); } else { DLModel.ProductShopping productShopping = new DLModel.ProductShopping(); productShopping.OrderID = orderID; productShopping.CoupanID = item.CoupanID; productShopping.Date = DateTime.Now; productShopping.ProductID = item.EduorProID; productShopping.Quantity = item.Quantity; productShopping.Grandtotal = item.Price * item.Quantity; productShopping.UserID = item.UserID; productShopping.ShippingPaymentID = item.ShippingPaymentID.Value; // _productShoppingRepository.Add((DLModel.ProductShopping)new DLModel.ProductShopping().InjectFrom(productShopping)); _productShoppingRepository.Add(productShopping); HCRGUniversity.Core.Data.Model.ProductQuantity _productQuantity = new DLModel.ProductQuantity(); _productQuantity.ProdQuantity = productShopping.Quantity; _productQuantity.ProdQuantityDate = DateTime.Now; _productQuantity.ProductID = productShopping.ProductID; _productQuantity.UserID = productShopping.UserID; _productQuantity.Mode = "Sold"; _productQuantityRepository.Add(_productQuantity); //// //HCRGUniversity.Core.Data.Model.Product _product = _productRepository.GetById(_productQuantity.ProductID); //_product.ProductCurrentBalance = _product.ProductCurrentBalance.Value - _productQuantity.ProdQuantity; //_productRepository.Update((DLModel.Product)new DLModel.Product().InjectFrom(_product)); } } //_educationShoppingTempBL.DeleteEducationShoppingCartByUserID(shoppingcart.FirstOrDefault().UserID); //_educationShoppingTempBL.DeleteProductShoppingCartByUserID(shoppingcart.FirstOrDefault().UserID); }