/// <summary>Construct an instance.</summary> /// <param name="stableVersion">The latest stable SMAPI version.</param> /// <param name="betaVersion">The latest prerelease SMAPI version (if newer than <paramref name="stableVersion"/>).</param> /// <param name="betaBlurb">A short sentence shown under the beta download button, if any.</param> /// <param name="supporterList">A list of supports to credit on the main page, in Markdown format.</param> internal IndexModel(IndexVersionModel stableVersion, IndexVersionModel betaVersion, string betaBlurb, string supporterList) { this.StableVersion = stableVersion; this.BetaVersion = betaVersion; this.BetaBlurb = betaBlurb; this.SupporterList = supporterList; }
public async Task <ViewResult> Index() { // choose versions ReleaseVersion[] versions = await this.GetReleaseVersionsAsync(); ReleaseVersion stableVersion = versions.LastOrDefault(version => !version.IsForDevs); ReleaseVersion stableVersionForDevs = versions.LastOrDefault(version => version.IsForDevs); // render view IndexVersionModel stableVersionModel = stableVersion != null ? new IndexVersionModel(stableVersion.Version.ToString(), stableVersion.Release.Body, stableVersion.Asset.DownloadUrl, stableVersionForDevs?.Asset.DownloadUrl) : new IndexVersionModel("unknown", "", "https://github.com/Pathoschild/SMAPI/releases", null); // just in case something goes wrong // render view var model = new IndexModel(stableVersionModel, this.SiteConfig.OtherBlurb, this.SiteConfig.SupporterList); return(this.View(model)); }
public async Task <ViewResult> Index() { // fetch SMAPI releases IndexVersionModel stableVersion = await this.Cache.GetOrCreateAsync("stable-version", async entry => { entry.AbsoluteExpiration = DateTimeOffset.UtcNow.Add(this.CacheTime); GitRelease release = await this.GitHub.GetLatestReleaseAsync(this.RepositoryName, includePrerelease: false); return(new IndexVersionModel(release.Name, release.Body, this.GetMainDownloadUrl(release), this.GetDevDownloadUrl(release))); }); IndexVersionModel betaVersion = await this.Cache.GetOrCreateAsync("beta-version", async entry => { entry.AbsoluteExpiration = DateTimeOffset.UtcNow.Add(this.CacheTime); GitRelease release = await this.GitHub.GetLatestReleaseAsync(this.RepositoryName, includePrerelease: true); return(release.IsPrerelease ? this.GetBetaDownload(release) : null); }); // render view var model = new IndexModel(stableVersion, betaVersion); return(this.View(model)); }
/// <summary>Construct an instance.</summary> /// <param name="stableVersion">The latest stable SMAPI version.</param> /// <param name="otherBlurb">A message to show below the download button (e.g. for details on downloading a beta version), in Markdown format.</param> /// <param name="supporterList">A list of supports to credit on the main page, in Markdown format.</param> internal IndexModel(IndexVersionModel stableVersion, string otherBlurb, string supporterList) { this.StableVersion = stableVersion; this.OtherBlurb = otherBlurb; this.SupporterList = supporterList; }
/// <summary>Construct an instance.</summary> /// <param name="stableVersion">The latest stable SMAPI version.</param> /// <param name="betaVersion">The latest prerelease SMAPI version (if newer than <paramref name="stableVersion"/>).</param> internal IndexModel(IndexVersionModel stableVersion, IndexVersionModel betaVersion) { this.StableVersion = stableVersion; this.BetaVersion = betaVersion; }
/// <summary>Construct an instance.</summary> /// <param name="stableVersion">The latest stable SMAPI version.</param> /// <param name="betaVersion">The latest prerelease SMAPI version (if newer than <paramref name="stableVersion"/>).</param> /// <param name="betaBlurb">A short sentence shown under the beta download button, if any.</param> internal IndexModel(IndexVersionModel stableVersion, IndexVersionModel betaVersion, string betaBlurb) { this.StableVersion = stableVersion; this.BetaVersion = betaVersion; this.BetaBlurb = betaBlurb; }