I did the following changes
Changed this line in ProductPrices.ascx.cs
lblCurrentPrice.Text = WebUtils.GetDiscountPrice(product.Price).ToString("c");
to
lblCurrentPrice.Text = custom.GetCustomDiscountPrice(product.Price, Product.ProductId, Roles.GetRolesForUser(Utils.GetUserName())).ToString("c");
The code for this new function is
public decimal GetCustomDiscountPrice(decimal price, int productID, string[] roles)
{
return Utils.Round(price * (100 - getCustomDiscountRate(productID, roles)) / 100);
}
public decimal getCustomDiscountRate(int productId, string[] roles)
{
int roleID = getRoleID(roles[0]);
decimal discountRate = 0;
DiscountsDataContext db = new DiscountsDataContext(ConfigurationController.SiteConfigurationController.GetSiteConnectionString(SiteNavigation.GetHost()));
var discount = from d in db.DSC_CustomDiscounts
where (d.productId == productId && d.roleId == roleID)
select d;
foreach (var x in discount)
{
discountRate = x.discountRate;
}
return discountRate;
}
Customer will never be assigned to more than one roles.
I also fixed the Final Price in cart page and checkout page to take my custom price. Also the stored procedure DSC_Order_Add_OrderItem.
I didnot play around with the session at all. Everything works fine until the session is left idle for sometime. What's the timeout on the session?
I don't think the site logs out the user after timeout.
Also I noticed another thing, If i login as admin and then go to users and use the switch button (to login as customer), I don't see customer's discounted prices. I see the list price. I am guessing this also has to do with session.
WHat do you think?
Thanks
-Divyanshu
|