예제 #1
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            switch (SelectedDashboardType)
            {
            case DisplayType.ShowAll:
            {
                azureHelper.GetVirtualMashinesList().UpdateActiveVMs((int)id, new int[0]);
                break;
            }

            case DisplayType.ExcludeType:
            {
                azureHelper.GetVirtualMashinesList().UpdateActiveVMs((int)id, ExcludedVMs);
                break;
            }

            case DisplayType.SelectType:
            {
                azureHelper.GetVirtualMashinesList().UpdateActiveVMs((int)id, SelectedVMs);
                break;
            }
            }

            using (var ctx = new CADContext())
            {
                if (Dashboard.DashboardAnonAccessCode == null)
                {
                    Dashboard.DashboardAnonAccessCode = DashboardHelper.CalculateHash(Dashboard.DashboardName);
                }

                var dash = await ctx.Dashboards.Include(d => d.DashboardApplications).Include(l => l.Links).FirstOrDefaultAsync(d => d.DashboardId == Dashboard.DashboardId);

                dash.DashboardApplications.Clear();
                foreach (var sa in SelectedApplications)
                {
                    DashboardApplication app = new DashboardApplication();
                    app.Dashboard   = Dashboard;
                    app.Application = ctx.Applications.First(a => a.AppId == sa);
                    dash.DashboardApplications.Add(app);
                }
                dash.Links.Clear();
                dash.Links = Dashboard.Links;
                dash.DashboardAnonAccessCode = Dashboard.DashboardAnonAccessCode;
                dash.DashboardName           = Dashboard.DashboardName;
                dash.DashboardLogoUrl        = Dashboard.DashboardLogoUrl;
                dash.DisplayType             = SelectedDashboardType;
                ctx.SaveChanges();
            }
            return(RedirectToPage("./Index"));
        }
예제 #2
0
        public IActionResult OnPost()
        {
            if (Dashboard.DashboardAnonAccessCode == null)
            {
                Dashboard.DashboardAnonAccessCode = DashboardHelper.CalculateHash(Dashboard.DashboardName);
            }
            _context.Dashboards.Add(Dashboard);
            _context.SaveChanges();

            using (var ctx = new CADContext())
            {
                var dash = ctx.Dashboards.Include(d => d.DashboardApplications).First(d => d.DashboardId == Dashboard.DashboardId);
                foreach (var sa in SelectedApplications)
                {
                    DashboardApplication app = new DashboardApplication();
                    app.Dashboard   = Dashboard;
                    app.Application = ctx.Applications.First(a => a.AppId == sa);
                    dash.DashboardApplications.Add(app);
                }
                ctx.SaveChanges();
            }
            return(RedirectToPage("./Index"));
        }