/// <summary> /// Creates a new dashboard based on the user. /// /// NOTE /// THIS METHOD USES UNIT OF WORK /// </summary> public Dashboard AddDashboard(string userId = "-1", DashboardType dashType = DashboardType.Private) { uowManager = new UnitOfWorkManager(); InitRepo(); //Create dashboard Dashboard dashboard = new Dashboard() { DashboardType = dashType, Widgets = new List <UserWidget>(), }; //Get user if (!userId.Equals("-1")) { UserManager userManager = new UserManager(uowManager); User user = userManager.GetUser(userId); if (user == null) { return(null); } else { dashboard.User = user; } } //Create database widgetRepo.CreateDashboard(dashboard); uowManager.Save(); uowManager = null; return(dashboard); }