Example #1
0
 public ActionResult Index()
 {
     managePricing_IndexViewModel = new ManagePricing_IndexViewModel();
     if (User.Identity.IsAuthenticated)
     {
         if (isValidUser())
         {
             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];
             CumulativeCartDataSet   = PricingDetailsProxy.FetchCumulativeCartDetails(UserId);
             CumulativeCartDataTable = CumulativeCartDataSet.Tables[0];
             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();
                 }
             }
             PricingDataTable = DataTablePhotoMapping(PricingDataTable);
             if (PricingDataTable != null)
             {
                 managePricing_IndexViewModel.PricingDataTable = PricingDataTable;
             }
             return(View(managePricing_IndexViewModel));
         }
         else
         {
             return(RedirectToAction("Index", "Home"));
         }
     }
     else
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
Example #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();
                    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"));
            }
        }