aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Web/Tango.MachineService/Controllers/FSEDownloadsController.cs
blob: 52eb2bbb5e77e542f4343d46efcb527f07b664fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { colo
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Tango.BL;
using Tango.MachineService.Filters;
using Tango.MachineService.Models;
using Tango.Web.Helpers;
using System.Data.Entity;
using Tango.Web.Storage;
using System.IO;
using Microsoft.WindowsAzure.Storage.Blob;
using System.Net.Http;
using System.Net;
using System.Net.Http.Headers;
using System.Net.Mime;
using Tango.MachineService.Views.FSEDownloads;

namespace Tango.MachineService.Controllers
{
    public class FSEDownloadsController : Controller
    {
        public ActionResult Index()
        {
            IndexViewModel model = new IndexViewModel();

            using (var db = ObservablesContextHelper.CreateContext())
            {
                var versions = db.FseVersions.ToList().OrderByDescending(x => Version.Parse(x.Version)).Take(6).ToList();

                var manager = new BlobStorageManager();
                var container = manager.GetContainer(MachineServiceConfig.FSE_VERSIONS_CONTAINER);

                foreach (var item in versions)
                {
                    var installerBlob = container.GetBlockBlobReference(item.InstallerBlobName);

                    model.Downloads.Add(new FSEDownload()
                    {
                        Name = $"Tango FSE v{Version.Parse(item.Version).ToString(3)}",
                        Version = Version.Parse(item.Version).ToString(3),
                        Comments = item.Comments,
                        Date = item.LastUpdated.ToString("dddd, dd MMMM yyyy"),
                        Address = MachineServiceConfig.CDN_ENDPOINT + installerBlob.Uri.AbsolutePath
                    });
                }

                if (model.Downloads.Count > 0)
                {
                    var latest = model.Downloads.First();
                    model.Downloads.Remove(latest);
                    model.LatestDownload = latest;
                }
            }

            return View(model);
        }
    }
}