Image Tagging Logic for Summer and Winter - noi-techpark/opendatahub-docs GitHub Wiki
The ParseMyAccommodation()
function ensures that images are correctly tagged based on specific criteria.
The function sets specific tags, namely "Summer
" and "Winter
", to images within the ImageGallery
. The assignment is based on the validity dates of the images:
- Summer Tag: If the image's validity period includes the date 15th July, the tag "Summer" is added.
- Winter Tag: If the image's validity period includes the date 15th January, the tag "Winter" is added.
The Code:
var checkbegindate = ((DateTime)mainimagede.ValidFrom).Date;
var checkenddate = ((DateTime)mainimagede.ValidTo).Date;
var summer = new DateTime(mainimagede.ValidFrom.Value.Year, 7, 15).Date;
var winter = new DateTime(mainimagede.ValidTo.Value.Year, 1, 15).Date;
// Check if date is within 15th July
if (summer >= checkbegindate && summer <= checkenddate)
imagetaglist.Add("Summer");
// Check if date is within 15th January
if (winter >= checkbegindate && winter <= checkenddate)
imagetaglist.Add("Winter");