public void UpdateDashboard(List <DashboardItem> dashboardItems) { GraphManager graphManager = new GraphManager(); if (dashboardItems != null && dashboardItems.Count > 0) { dashboardItems.ForEach(d => d.Graph = graphManager.GetGraphbyId(d.GraphId)); Update(dashboardItems); } else { repo.ClearItems(); } }
public Alert AddAlert(string subjectName, string alertType, string subjectBName, string compare, string subjectProperty, int value) { Alert alert; SubjectManager subjectManager = new SubjectManager(unitOfWorkManager); GraphManager graphManager = new GraphManager(unitOfWorkManager); Subject subject = subjectManager.GetSubjectByName(subjectName); Alert existingAlert; if (alertType.Equals("Trend")) { alert = new TrendAlert(subject); alert.Graph = graphManager.AddAlertLineGraph(); existingAlert = repo.FindTrendAlert((TrendAlert)alert); } else if (alertType.Equals("Compare")) { Subject subjectB = subjectManager.GetSubjectByName(subjectBName); Operator @operator; if (compare.Equals("GT")) { @operator = Operator.GT; } else { @operator = Operator.LT; } alert = new CompareAlert(subject, subjectB, @operator); alert.Graph = graphManager.AddAlertBarGraph(); existingAlert = repo.FindCompareAlert((CompareAlert)alert); } else if (alertType.Equals("Check")) { SubjectProperty property; if (subjectProperty.Equals("count")) { property = SubjectProperty.count; } else { property = SubjectProperty.relativeCount; } Operator @operator; if (compare.Equals("GT")) { @operator = Operator.GT; } else { @operator = Operator.LT; } alert = new CheckAlert(property, @operator, value, subject); alert.Graph = graphManager.AddAlertLineGraph(); existingAlert = repo.FindCheckAlert((CheckAlert)alert); } else { SubjectProperty property; if (subjectProperty.Equals("pos")) { property = SubjectProperty.pos; } else { property = SubjectProperty.neg; } Operator @operator; if (compare.Equals("GT")) { @operator = Operator.GT; } else { @operator = Operator.LT; } alert = new SentimentAlert(property, @operator, value, subject); alert.Graph = graphManager.AddAlertBarGraph(); existingAlert = repo.FindSentimentAlert((SentimentAlert)alert); } if (existingAlert != null) { alert = existingAlert; } else { this.Validate(alert); repo.AddAlert(alert); } return(alert); }