public ActionResult UpdateCartItem(string ProductPricingId, string CartItemQuantity)
        {
            if (isValidUser())
            {
                StringBuilder ErrorMessages   = new StringBuilder();
                StringBuilder SuccessMessages = new StringBuilder();
                try
                {
                    bool     UpdateResult = false;
                    CartData cartData     = new CartData();
                    cartData.ProductPricingId = ProductPricingId;
                    cartData.Quantity         = int.Parse(CartItemQuantity);
                    cartData.UserId           = User.Identity.GetUserId();
                    UpdateResult = CartDetailsProxy.CUDCartValue(cartData, "Insert/Update");
                    if (UpdateResult)
                    {
                        SuccessMessages.Append(CUDConstants.UpdateCartSuccess);
                    }
                    else
                    {
                        ErrorMessages.Append(CUDConstants.UpdateCartError);
                    }
                    managePricing_IndexViewModel = new ManagePricing_IndexViewModel();
                    DataSet   PricingDataSet   = new DataSet();
                    DataTable PricingDataTable = new DataTable();
                    PricingDataSet   = PricingDetailsProxy.FetchPricingDetails();
                    PricingDataTable = PricingDataSet.Tables[0];
                    if (PricingDataTable != null)
                    {
                        managePricing_IndexViewModel.PricingDataTable = PricingDataTable;
                    }
                    managePricing_IndexViewModel.UserId = User.Identity.GetUserId();
                }
                catch (Exception e)
                {
                    ErrorMessages.Append(CUDConstants.UpdateCartError);
                }
                if (!String.IsNullOrEmpty(SuccessMessages.ToString()))
                {
                    managePricing_IndexViewModel.SuccessMessage = SuccessMessages.ToString();
                }
                if (!String.IsNullOrEmpty(ErrorMessages.ToString()))
                {
                    managePricing_IndexViewModel.ErrorMessage = ErrorMessages.ToString();
                }

                return(PartialView("ChampionsPricingGrid", managePricing_IndexViewModel));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
Beispiel #2
0
        public ActionResult UpdateCartItem(string ProductPricingId, string CartItemQuantity)
        {
            if (isValidUser())
            {
                StringBuilder ErrorMessages   = new StringBuilder();
                StringBuilder SuccessMessages = new StringBuilder();
                try
                {
                    bool     UpdateResult = false;
                    CartData cartData     = new CartData();
                    cartData.ProductPricingId = ProductPricingId;
                    cartData.Quantity         = int.Parse(CartItemQuantity);
                    cartData.UserId           = User.Identity.GetUserId();
                    UpdateResult = CartDetailsProxy.CUDCartValue(cartData, "Insert/Update");
                    if (UpdateResult)
                    {
                        SuccessMessages.Append(CUDConstants.UpdateCartSuccess);
                    }
                    else
                    {
                        ErrorMessages.Append(CUDConstants.UpdateCartError);
                    }
                    managePricing_IndexViewModel = new ManagePricing_IndexViewModel();
                    DataSet   PricingDataSet   = new DataSet();
                    DataTable PricingDataTable = new DataTable();
                    string    UserId           = User.Identity.GetUserId();
                    PricingDataSet   = PricingDetailsProxy.FetchPricingDetails(UserId);
                    PricingDataTable = PricingDataSet.Tables[0];

                    #region CumulativeCartData
                    DataSet   CumulativeCartDataSet   = new DataSet();
                    DataTable CumulativeCartDataTable = new DataTable();
                    CumulativeCartDataSet   = PricingDetailsProxy.FetchCumulativeCartDetails(UserId);
                    CumulativeCartDataTable = CumulativeCartDataSet.Tables[0];
                    foreach (DataRow row in CumulativeCartDataTable.Rows)
                    {
                        managePricing_IndexViewModel.TotalItems    = row["TotalItems"].ToString();
                        managePricing_IndexViewModel.TotalBuyValue = row["TotalSellValue"].ToString();
                    }
                    #endregion

                    PricingDataTable = DataTablePhotoMapping(PricingDataTable);
                    if (PricingDataTable != null)
                    {
                        managePricing_IndexViewModel.PricingDataTable = PricingDataTable;
                    }
                    managePricing_IndexViewModel.UserId = User.Identity.GetUserId();
                }
                catch (Exception e)
                {
                    ErrorMessages.Append(CUDConstants.UpdateCartError);
                }
                if (!String.IsNullOrEmpty(SuccessMessages.ToString()))
                {
                    managePricing_IndexViewModel.SuccessMessage = SuccessMessages.ToString();
                }
                if (!String.IsNullOrEmpty(ErrorMessages.ToString()))
                {
                    managePricing_IndexViewModel.ErrorMessage = ErrorMessages.ToString();
                }

                return(PartialView("CustomerPricingGrid", managePricing_IndexViewModel));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
Beispiel #3
0
 public ActionResult DeleteCartItem(string ProductPricingId)
 {
     if (isValidUser())
     {
         StringBuilder ErrorMessages   = new StringBuilder();
         StringBuilder SuccessMessages = new StringBuilder();
         try
         {
             bool     UpdateResult = false;
             CartData cartData     = new CartData();
             cartData.ProductPricingId = ProductPricingId;
             cartData.UserId           = User.Identity.GetUserId();
             UpdateResult = CartDetailsProxy.CUDCartValue(cartData, "Delete");
             if (UpdateResult)
             {
                 SuccessMessages.Append(CUDConstants.UpdateCartSuccess);
             }
             else
             {
                 ErrorMessages.Append(CUDConstants.UpdateCartError);
             }
             managePricing_IndexViewModel            = new ManagePricing_IndexViewModel();
             managePricing_IndexViewModel.IsChampion = true;
             DataSet   PricingDataSet          = new DataSet();
             DataTable PricingDataTable        = new DataTable();
             DataSet   CumulativeCartDataSet   = new DataSet();
             DataTable CumulativeCartDataTable = new DataTable();
             string    UserId = User.Identity.GetUserId();
             PricingDataSet   = PricingDetailsProxy.FetchUserPricingDetails(UserId);
             PricingDataTable = PricingDataSet.Tables[0];
             PricingDataTable = DataTablePhotoMapping(PricingDataTable);
             foreach (DataRow row in CumulativeCartDataTable.Rows)
             {
                 managePricing_IndexViewModel.TotalItems = row["TotalItems"].ToString();
                 string Role = GetRolesByUserId(UserId);
                 if (Role.Equals("Champion", StringComparison.OrdinalIgnoreCase))
                 {
                     managePricing_IndexViewModel.TotalBuyValue = row["TotalBuyValue"].ToString();
                 }
                 else if (Role.Equals("Customer", StringComparison.OrdinalIgnoreCase))
                 {
                     managePricing_IndexViewModel.TotalBuyValue = row["TotalSellValue"].ToString();
                 }
             }
             if (PricingDataTable != null)
             {
                 managePricing_IndexViewModel.PricingDataTable = PricingDataTable;
             }
             managePricing_IndexViewModel.UserId = User.Identity.GetUserId();
         }
         catch (Exception e)
         {
             ErrorMessages.Append(CUDConstants.UpdateCartError);
         }
         if (!String.IsNullOrEmpty(SuccessMessages.ToString()))
         {
             managePricing_IndexViewModel.SuccessMessage = SuccessMessages.ToString();
         }
         if (!String.IsNullOrEmpty(ErrorMessages.ToString()))
         {
             managePricing_IndexViewModel.ErrorMessage = ErrorMessages.ToString();
         }
         return(PartialView("CartView", managePricing_IndexViewModel));
     }
     else
     {
         return(RedirectToAction("Index", "Home"));
     }
 }