I have the following code:
switch(equipmentAttachment.AttachmentPosition)
{
case 'AttachFront':
{
if(equipmentAttachment.ProductCategoryDesc!='')
{
attachments.frontAttachment=equipmentAttachment.ProductCategoryDesc;
}
else
{
attachments.frontAttachment=equipmentAttachment.ProductCategoryName;
}
break;
}
case 'AttachRear':
{
if(equipmentAttachment.ProductCategoryDesc!='')
{
attachments.backAttachment=equipmentAttachment.ProductCategoryDesc;
}
else
{
attachments.backAttachment=equipmentAttachment.ProductCategoryName;
}
break;
}
case 'Tertiary':
{
if(equipmentAttachment.ProductCategoryDesc!='')
{
attachments.thirdAttachment=equipmentAttachment.ProductCategoryDesc;
}
else
{
attachments.thirdAttachment=equipmentAttachment.ProductCategoryName;
}
break;
}
}
return attachments;
Notice that most of the code is kind of repetitive accept for the setting of different properties in the object attachments. Is there anyway to get rid of the repetitive code? Or is it just what it is?