-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCustomDashboardStorage.cs
42 lines (34 loc) · 1.44 KB
/
CustomDashboardStorage.cs
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using DevExpress.DashboardCommon;
using DevExpress.DashboardWeb;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Linq;
namespace AspNetCoreDashboardBackend {
public class CustomDashboardStorage : IDashboardStorage {
private string dashboardTemplateFolder;
private NorthwindContext nwindContext;
public CustomDashboardStorage(string dashboardTemplateFolder, NorthwindContext nwindContext) {
this.dashboardTemplateFolder = dashboardTemplateFolder;
this.nwindContext = nwindContext;
}
public IEnumerable<DashboardInfo> GetAvailableDashboardsInfo() {
var dashboards = nwindContext.Products.Select(item => new DashboardInfo() {
ID = item.ProductID,
Name = item.ProductName
});
return dashboards;
}
public XDocument LoadDashboard(string dashboardID) {
var dashboard = new Dashboard();
var product = nwindContext.Products.First(product => product.ProductID == dashboardID);
dashboard.LoadFromXml(Path.Combine(dashboardTemplateFolder, "DashboardTemplate.xml"));
dashboard.Title.Text = product.ProductName;
return dashboard.SaveToXDocument();
}
public void SaveDashboard(string dashboardID, XDocument dashboard) {
throw new NotImplementedException();
}
}
}