logo
Welcome to our new AbleCommerce forums. As a guest, you may view the information here. To post to this forum, you must have a registered account with us, either as a new user evaluating AbleCommerce or an existing user of the application. For all questions related to the older version of Gold and earlier, please go to AbleCommerce Gold forum. Please use your AbleCommerce username and password to Login. New Registrations are disabled.

Notification

Icon
Error

Options
Go to last post Go to first unread
mbartens21179672  
#1 Posted : Wednesday, March 9, 2022 8:37:16 AM(UTC)
mbartens21179672

Rank: Newbie

Groups: Authorized User, Developers, Registered
Joined: 3/9/2022(UTC)
Posts: 4

Quote:
In the admin I'd like to create a list of vendors on the dashboard (works) and clicking on the vendor will bring you to the order page (works) filtered by vendors (doesn't work).
I am able to successfully search by vendor on the order page.
The problem I am having is that when you click on the link to the orders page, the VendorId is passed but it seems that the session is cleared sometime before the page loads. I tried creating a VendorId session but that is not working. Thanks for any help!
These are the relevant modifications I made:

Dashboard link
Code:
<a href="@Url.Action("Index", "Orders", new { VendorId = item.VendorId })"> @item.OrderCount </a>


When this loads, the VendorId has a value.
Controllers\OrdersController.cs
Code:

      public ActionResult Index(int VendorId=0)
        {
            Session["VendorId"] = VendorId;
            return View();
        }      


When I debug the Session["VendorId"] is already blank.
Code:


        public ActionResult OrderSearch()
        {
            //VENDORID IS BLANK HERE
            string strVendor = Session["VendorId"] as string;
            if (!String.IsNullOrEmpty(strVendor))
            {
                filter.VendorId = Convert.ToInt32(strVendor);
            }
            if (filter != null)
            {
                model.StartDate = filter.OrderDateStart;
                model.EndDate = filter.OrderDateEnd;
                model.Keyword = filter.Keyword;
                model.KeywordField = filter.KeywordField;
                model.OrderStatus = GetOrderStatus(filter);
                model.PaymentStatus = filter.PaymentStatus;
                model.ShipmentStatus = filter.ShipmentStatus;
                model.OrderNumberRange = filter.OrderNumberRange;
                model.VendorId = filter.VendorId;
            }


Models\OrderModels.cs
Quote:
Code:

    public class OrderSearchFilter
    {
        public OrderSearchFilter()
        {
            this.OrderIdRange = string.Empty;
            this.OrderNumberRange = string.Empty;
            this.PaymentStatus = OrderPaymentStatus.Unspecified;
            this.ShipmentStatus = OrderShipmentStatus.Unspecified;
            this.OrderStatus = -2;
            this.Keyword = string.Empty;
            this.KeywordField = KeywordFieldType.All;
            this.VendorId = 0; 
        }

        public int VendorId { get; set; }
}

Wanna join the discussion?! Login to your AbleCommerce Forums forum account. New Registrations are disabled.

nadeem  
#2 Posted : Thursday, March 10, 2022 6:22:00 AM(UTC)
nadeem

Rank: Advanced Member

Groups: Administrators, Developers, Registered, HelpDesk, Authorized User, Admin, System
Joined: 10/11/2018(UTC)
Posts: 109

Thanks: 17 times
Was thanked: 18 time(s) in 18 post(s)
Hi,

Why are you converting the session value to string and then converting back to integer at first place.

The following line of code is problematic:

Code:

string strVendor = Session["VendorId"] as string;


You can directly convert this to int instead e.g.

Code:

int vendorId = Convert.ToInt32(Session["VendorId"]);
if (vendorId > 0)
{
    filter.VendorId = vendorId;
}


OR if you want it as a string update your code like this:

Code:

string strVendor = Convert.ToString(Session["VendorId"]);
if (!String.IsNullOrEmpty(strVendor))
{
   filter.VendorId = Convert.ToInt32(strVendor);
}


Hope this helps!
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.