Each product in my e-commerce website has Arabic and English values for the title, description and excerpt. I have this method EditProduct
to update those values based on current culture (Arabic or English)
public void EditProduct(string element, string text1, string text2, bool edit1, bool edit2, string culture)
{
var product = DoSomeMagicToGetAProduct();
if (element == "title")
{
if (culture == "en")
{
if (edit1)
{
product.Title = text1;
}
if (edit2)
{
product.TitleAr = text2;
}
}
if (culture == "ar")
{
if (edit1)
{
product.TitleAr = text1;
}
if (edit2)
{
product.Title = text2;
}
}
}
if (element == "description")
{
// similar codes here
}
if (element == "excerpt")
{
// similar codes here
}
product.Save();
}
The method works well, but I think I can improve the way I write it to be more elegant. Any suggestions?