aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Stubs/ViewModelLocator.cs
blob: 5034a4d906bfb7121f5a3de0bf5a36dd29a291f4 (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
using Tango.Core.DI;
using Tango.MachineStudio.Stubs.ViewModels;

namespace Tango.MachineStudio.Stubs
{
    /// <summary>
    /// This class contains static references to all the view models in the
    /// application and provides an entry point for the bindings.
    /// </summary>
    public static class ViewModelLocator
    {
        /// <summary>
        /// Initializes a new instance of the ViewModelLocator class.
        /// </summary>
        static ViewModelLocator()
        {
            TangoIOC.Default.Register<MainViewVM>();
        }

        public static MainViewVM MainViewVM
        {
            get
            {
                return TangoIOC.Default.GetInstance<MainViewVM>();
            }
        }
    }
}
s="k">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; namespace Tango.MachineService.Controllers { public class DownloadsController : Controller { [Authorize] public ActionResult Index() { List<DownloadModel> downloads = new List<DownloadModel>(); using (ObservablesContext db = ObservablesContextHelper.CreateContext()) { foreach (var item in db.MachineStudioVersions.Where(x => x.InstallerBlobName != null).Include(x => x.User).Include(x => x.User.Contact).ToList()) { DownloadModel download = new DownloadModel(); download.App = DownloadModel.DownloadApp.MachineStudio; download.ID = item.InstallerBlobName; download.Name = $"Machine Studio v{item.Version}.exe"; download.Version = item.Version; download.User = item.User.Contact.FullName; download.Date = item.LastUpdated; download.Comments = item.Comments; downloads.Add(download); } foreach (var item in db.TangoVersions.Where(x => x.InstallerBlobName != null).Include(x => x.User).Include(x => x.User.Contact).ToList()) { DownloadModel download = new DownloadModel(); download.App = DownloadModel.DownloadApp.PPC; download.ID = item.InstallerBlobName; download.Name = $"PPC v{item.Version}.exe"; download.Version = item.Version; download.User = item.User.Contact.FullName; download.Date = item.LastUpdated; download.Comments = item.Comments; downloads.Add(download); } } downloads = downloads.OrderByDescending(x => x.Date).ToList(); IndexViewModel model = new IndexViewModel(); model.Downloads = downloads; return View(model); } [Authorize] public ActionResult Download(String blobName, DownloadModel.DownloadApp downloadApp) { CloudBlobContainer container = null; var manager = new BlobStorageManager(); if (downloadApp == DownloadModel.DownloadApp.MachineStudio) { container = manager.GetContainer(MachineServiceConfig.MACHINE_STUDIO_VERSIONS_CONTAINER); } else { container = manager.GetContainer(MachineServiceConfig.TANGO_VERSIONS_CONTAINER); } var blob = container.GetBlockBlobReference(blobName); var signature = blob.GenerateReadSignature(TimeSpan.FromMinutes(10)); return Redirect(signature); } } }