This project is read-only.

How can you detect the year in which a tenant was created?

Topics: Customizing Orchard
Apr 18, 2013 at 5:35 AM
I need to (in a view) determine the year (or date) in which a tenant was created.

The view is in a theme common to many tenants. The best I could think of was to get the CreatedUtc date from the first common part I could find via the content manager (see sample below), however I'm hoping there might be a simpler, more lightweight method?
@using Orchard.ContentManagement
@using Orchard.Core.Common.Models
    var firstYear = DateTime.UtcNow.Year;
    var earliestPart = WorkContext.Resolve<IContentManager>().Query().ForPart<CommonPart>().OrderBy<CommonPartRecord>(p => p.CreatedUtc).Slice(0, 1).FirstOrDefault();
    if (earliestPart != null && earliestPart.CreatedUtc.HasValue)
        firstYear = earliestPart.CreatedUtc.Value.Year;
Apr 22, 2013 at 6:33 AM
Maybe just look at the creation date of the settings file. Not sure how that would work on Azure however.