public bool EditDashboard(Dashboard dashboardDetails, int UserDetails, string[] newSource, int[] deletedSource, DashboardStatus[] newStatus, int[] deletedStatus)
 {
     try
     {
         StoredProcedureDataContext dbmlObject = new StoredProcedureDataContext();
         dbmlObject.EditDashboard(dashboardDetails.DashboardId, dashboardDetails.DashboardName, dashboardDetails.StartMonth, dashboardDetails.StartYear, dashboardDetails.EndMonth, dashboardDetails.EndYear, dashboardDetails.Description);
         int dashboardID = dashboardDetails.DashboardId;
         foreach (var source in newSource)
         {
             dbmlObject.AddDashboardSources(source, dashboardID);
         }
         foreach (int sid in deletedSource)
         {
             dbmlObject.DeleteDashboardSource(sid);
         }
         foreach (var status in newStatus)
         {
             dbmlObject.AddDashboardStatus(status.Status, status.Color, dashboardID);
         }
         foreach (int sid in deletedStatus)
         {
             dbmlObject.DeleteDashboardStatus(sid);
         }
         dbmlObject.SubmitChanges();
     }
     catch (Exception e) { throw e; }
     return(true);
 }
示例#2
0
        public bool CreateNewDashboardByExistingDashboard(int dashboardID, int userID, string dashboardName, string description)
        {
            StoredProcedureDataContext dbmlObject = new StoredProcedureDataContext();
            var result            = dbmlObject.GetDashboardByID(dashboardID).ToList();
            var dashboardDetails  = result.FirstOrDefault();
            var resNewDashboardID = dbmlObject.CreateDashboard(dashboardName, dashboardDetails.StartMonth, dashboardDetails.StartYear, dashboardDetails.EndMonth, dashboardDetails.EndYear, userID, "ADMIN", description).ToList();
            int newDashboardID    = Convert.ToInt32(resNewDashboardID.FirstOrDefault().Column1);
            //Dashboard Source
            var resDashboardSources = dbmlObject.RetreiveSource(dashboardID).ToList();

            foreach (var i in resDashboardSources)
            {
                dbmlObject.AddDashboardSources(i.Source, newDashboardID);
            }
            //dashboard Status
            var resStatus = dbmlObject.RetreiveStatus(dashboardID);

            foreach (var i in resStatus)
            {
                dbmlObject.AddDashboardStatus(i.Status, i.Color, newDashboardID);
            }
            var resultItems = dbmlObject.RetreiveExistingDashboardItems(dashboardID, "StartDate").ToList();

            foreach (var i in resultItems)
            {
                var resItemID = dbmlObject.AddDataItem(i.ItemName, i.StartDate, i.EndDate, newDashboardID, i.StatusID).ToList();
                int itemID    = Convert.ToInt32(resItemID.FirstOrDefault().Column1);
                var resTeams  = dbmlObject.RetreiveTeamsWorkingOnItem(i.ItemID).ToArray();
                for (var j = 0; j < resTeams.Length; j++)
                {
                    dbmlObject.AddTeamToDashboardItem(itemID, resTeams[j].TeamID);
                }
                var resSources = dbmlObject.GetSourcesByItemID(i.ItemID).ToArray();
                for (var j = 0; j < resSources.Length; j++)
                {
                    dbmlObject.AddDataItemSource(itemID, resSources[j].SourceID);
                }
            }
            dbmlObject.SubmitChanges();
            return(true);
        }