public void UpdateProductQuantity(List <ProductQuantityViewModel> productQuantityVm, int productId)
        {
            var productQuantities = Mapper.Map <List <ProductQuantityViewModel>, List <ProductQuantity> >(productQuantityVm);

            // Remove quantities in Database that are removed on View
            var productQuantitiesToDelete = _productQuantityRepository.FindAll(x => x.ProductId == productId && !productQuantities.Contains(x));

            _productQuantityRepository.RemoveMultiple(productQuantitiesToDelete.ToList());

            foreach (var quantityViewModel in productQuantities)
            {
                var quantityModel = _productQuantityRepository.FindById(quantityViewModel.Id);
                quantityModel.Quantity = quantityViewModel.Quantity;
                quantityModel.SizeId   = quantityViewModel.SizeId;
                quantityModel.ColorId  = quantityViewModel.ColorId;

                _productQuantityRepository.Update(quantityModel);
            }
        }
 public int UpdateProductQuantity(ProductQuantity productQuantity)
 {
     return(_productQuantityRepository.Update(productQuantity));
 }