mercredi 26 décembre 2018

best method to if/else potentially large condition

I have an older version of an ASP.NET MVC. It is an online shopping tool with thousands of products and shoppers. We want to give some customers a negotiated discount, for example 10% off. For now this is a simple if/else statement based on the user login credentials. However, potentially we could have tens of customers and this statement can get extremely long and I was wondering if there is a better method of doing this. Perhaps through a stored procedure. Basically inside our product page we have a statement similar to this:

    <if user == so@so.com 
    {
       product *.20 
    }
   else if user == no@no.com
   {
   product *.-10
   }
    else         
     product.price >

This of course is just a generalization, the actual statements are a lot more complex and have declared decimals and math functions and some conversions. But we have to apply this to the shopping cart, checkout, search results, etc. And as you can image this can get tedious to maintain, would there be an easier way to store these if/else statements and apply them to our aspx pages as text results.

Aucun commentaire:

Enregistrer un commentaire