예제 #1
0
        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);
            }
        }
예제 #3
0
 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
         });
     }
 }
예제 #4
0
 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
         });
     }
 }
예제 #5
0
 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
         });
     }
 }
예제 #6
0
        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
                });
            }
        }
예제 #7
0
 public void Add(ProductQuantity productImage)
 {
     _productQuantityRepository.Add(productImage);
 }
예제 #8
0
 public int AddProductQuantity(ProductQuantity productQuantity)
 {
     return(_productQuantityRepository.Add(productQuantity).ProductQuantityID);
 }
예제 #9
0
        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);
        }