public JsonResult DeleteCartItem(int id, string cartType, int _productID) { if (cartType == GlobalConst.CartType.Product) { var _result = _shoppingeducationService.GetProductShoppingTempByID(id); if (_result != null) { if ((_result.ShippingPaymentID == null) && (_result.IsProcessed == null)) { _shoppingeducationService.DeleteProductShoppingCart(id); } else { if ((_result.ShippingPaymentID != null) && (_result.IsProcessed == null)) { Product _product = Mapper.Map <Product>(_productService.GetProductByID(_productID)); int deletedQty = _result.Quantity; _product.ProductCurrentBalance = _product.ProductCurrentBalance + deletedQty; _productService.UpdateProduct(Mapper.Map <HCRGUniversityApp.NEPService.ProductService.Product>(_product)); // Product Quantity ------ ProductQuantity _productQuantity = new ProductQuantity(); _productQuantity.ProdQuantity = deletedQty; _productQuantity.ProdQuantityDate = DateTime.Now; _productQuantity.ProductID = _productID; _productQuantity.UserID = HCRGUser.UID; _productQuantity.Mode = "Add-Deleted"; _productService.addProductQuantity(Mapper.Map <HCRGUniversityApp.NEPService.ProductService.ProductQuantity>(_productQuantity)); _shoppingeducationService.DeleteProductShoppingCart(id); } else { return(Json(GlobalConst.Message.CannotDeleted)); } } } else { return(Json(GlobalConst.Message.AlReadyDeletedSuccessfully)); } } else if (cartType == GlobalConst.CartType.AllAccessPass) { User _user = new User(); _user = Mapper.Map <User>(_userService.GetUserByID(HCRGUser.UID)); if (_user.IsAllAccessPricing.HasValue) { _user.IsAllAccessPricing = null; _userService.UpdateUser(Mapper.Map <HCRGUniversityApp.NEPService.UserService.User>(_user)); } } else { var _res = _shoppingeducationService.GetEducationShoppingTempByID(id); if (_res.ShippingPaymentID == null) { _shoppingeducationService.DeleteEducationFromShoppingCart(id); // online course deleted } else { return(Json(GlobalConst.Message.CannotDeleted)); } } return(Json(GlobalConst.Message.DeletedSuccessfully)); }
public ActionResult Add(Product product) { // var message = ""; int _prTotalQty = 0; Product1 pro = new Product1(); if (product.ProductImageFile != null) { product.ProductImage = UploadProductImage(product.ProductImageFile); } if (product.ProductFile_File != null) { product.ProductFile = UploadProductFile(product.ProductFile_File); } _prTotalQty = product.ProductTotalQuantity.Value; if (product.ProductID == 0) { if (_prTotalQty == 0) { product.ProductCurrentBalance = -2; } product.ClientID = HCRGCLIENT.ClientID; product.ProductID = _productservice.AddProduct(Mapper.Map <HCRGUniversityMgtApp.NEPService.ProductService.Product>(product)); ProductQuantity productQuantity = new ProductQuantity(); productQuantity.ProductID = product.ProductID; productQuantity.ProdQuantity = _prTotalQty; productQuantity.ProdQuantityDate = DateTime.Now; productQuantity.UserID = HCRGCLIENT.ClientID; productQuantity.Mode = "Add"; if (productQuantity.ProdQuantity != 0) { _productservice.addProductQuantity(Mapper.Map <HCRGUniversityMgtApp.NEPService.ProductService.ProductQuantity>(productQuantity)); } product.Message = "Successfully Saved"; } else { if (_prTotalQty == 0) { product.ProductCurrentBalance = -2; } Product _ProductDb = Mapper.Map <Product>(_productservice.GetProductByID(product.ProductID)); _productservice.UpdateProduct(Mapper.Map <HCRGUniversityMgtApp.NEPService.ProductService.Product>(product)); ProductQuantity productQuantity = new ProductQuantity(); int Qty = 0; if (product.ProductTotalQuantity.Value > _ProductDb.ProductTotalQuantity.Value) { //product.ProductTotalQuantity = product.ProductTotalQuantity.Value - _ProductDb.ProductTotalQuantity.Value; // latest product total qty Qty = product.ProductTotalQuantity.Value - _ProductDb.ProductTotalQuantity.Value; // latest product total qty //product.ProductCurrentBalance = product.ProductCurrentBalance.Value - _ProductDb.ProductCurrentBalance.Value; // latest product total qty productQuantity.Mode = "Add"; } else { //product.ProductTotalQuantity = _ProductDb.ProductTotalQuantity.Value - product.ProductTotalQuantity.Value; Qty = _ProductDb.ProductTotalQuantity.Value - product.ProductTotalQuantity.Value; //product.ProductCurrentBalance = _ProductDb.ProductCurrentBalance.Value - product.ProductCurrentBalance.Value; productQuantity.Mode = "Sub"; } productQuantity.ProductID = product.ProductID; productQuantity.ProdQuantity = Qty; productQuantity.ProdQuantityDate = DateTime.Now; productQuantity.UserID = HCRGCLIENT.ClientID; if (productQuantity.ProdQuantity != 0) { _productservice.addProductQuantity(Mapper.Map <HCRGUniversityMgtApp.NEPService.ProductService.ProductQuantity>(productQuantity)); } product.Message = "Successfully Updated"; } pro.ProductDesc = product.ProductDesc; pro.ProductFile = product.ProductFile; pro.ProductImage = product.ProductImage; pro.ProductPrice = product.ProductPrice; pro.ProductType = product.ProductType; pro.ProductID = product.ProductID; pro.Message = product.Message; pro.ProductName = product.ProductName; pro.ProductCurrentBalance = product.ProductCurrentBalance; pro.ProductTotalQuantity = product.ProductTotalQuantity; return(Json(pro)); }