// for dashboard only // public List<DashboardViewModel> getDashboardViewModels(Boolean regular) { using (Youth_Center_DB_Conn db = new Youth_Center_DB_Conn()) { try { List<ProjectSet> projectList = (from p in db.ProjectSets where p.status == "Approved" && p.endDate > DateTime.Now && p.postDate != null && p.Contact != null && p.isRegular == regular //orderby p.postDate select p).ToList(); List<DashboardViewModel> modelList = new List<DashboardViewModel>(); foreach(ProjectSet p in projectList) { List<string> strList = new List<string>(); foreach (TargetGroupSet t in p.TargetGroupSets) { strList.Add(t.targetGroup); } DashboardViewModel model = new DashboardViewModel(); model.project = p; model.contact = p.Contact; model.laucher = p.ProjectLaucherSet; model.targetGroupList = strList; modelList.Add(model); } return modelList; } catch (Exception ex) { Debug.WriteLine(ex.StackTrace); } return new List<DashboardViewModel>(); } }
// // public List<DashboardViewModel> getDashboardViewModelsByEmail(string email) { using (Youth_Center_DB_Conn db = new Youth_Center_DB_Conn()) { try { List<ProjectSet> projectList = (from p in db.ProjectSets where p.Contact != null && p.ProjectLaucherSet.emailAddr.ToUpper().Equals(email.ToUpper()) //orderby p.postDate select p).ToList(); List<DashboardViewModel> modelList = new List<DashboardViewModel>(); foreach (ProjectSet p in projectList) { List<string> strList = new List<string>(); foreach (TargetGroupSet t in p.TargetGroupSets) { strList.Add(t.targetGroup); } DashboardViewModel model = new DashboardViewModel(); model.project = p; model.contact = p.Contact; model.laucher = p.ProjectLaucherSet; model.targetGroupList = strList; modelList.Add(model); } return modelList; } catch (Exception ex) { Debug.WriteLine(ex.StackTrace); } return new List<DashboardViewModel>(); } }
// for advanced search only // public List<DashboardViewModel> getDashboardViewModelList_advanced(DateTime startDate_from, DateTime startDate_to, DateTime endDate_from, DateTime endDate_to, int jobScopeId, string target, string organization, Boolean regular) { using (Youth_Center_DB_Conn db = new Youth_Center_DB_Conn()) { try { Debug.WriteLine(startDate_from + " | " + startDate_to + " | " + endDate_from + " | " + endDate_to + " | " + jobScopeId + " | " + target + " | " + organization); List<ProjectSet> projectList = new List<ProjectSet>(); if (jobScopeId != -1) { Debug.WriteLine("jobscope != null"); projectList = (from j in db.JobSets where j.JobScopeId == jobScopeId select j.ActivitySet.ProjectSet).ToList(); projectList = (from p in projectList where p.status == "Approved" && p.endDate >= DateTime.Now && p.postDate != null && p.Contact != null && p.isRegular == regular //orderby p.postDate select p).ToList(); } projectList = (from p in db.ProjectSets where p.status == "Approved" && p.endDate >= DateTime.Now && p.postDate != null && p.Contact != null && p.isRegular == regular //orderby p.postDate select p).ToList(); projectList = (from p in projectList where startDate_from <= p.startDate && p.startDate <= startDate_to && endDate_from <= p.endDate && p.endDate <= endDate_to select p).ToList(); if (organization != null) { projectList = (from p in projectList where p.Contact.organization.ToUpper().Equals(organization.ToUpper()) select p).ToList(); } if (target != null) { TargetGroupSet targetGroup = (from t in db.TargetGroupSets where t.targetGroup == target select t).First(); projectList = (from p in projectList where p.TargetGroupSets.Contains(targetGroup) select p).ToList(); } List<DashboardViewModel> modelList = new List<DashboardViewModel>(); foreach (ProjectSet p in projectList) { List<string> strList = new List<string>(); foreach (TargetGroupSet t in p.TargetGroupSets) { strList.Add(t.targetGroup); } DashboardViewModel model = new DashboardViewModel(); model.project = p; model.contact = p.Contact; model.laucher = p.ProjectLaucherSet; model.targetGroupList = strList; modelList.Add(model); } return modelList; } catch (Exception ex) { Debug.WriteLine(ex.StackTrace); } return new List<DashboardViewModel>(); } }