// GET: /ProposalInfo/View/1 public ActionResult View(int?id) { if (!id.HasValue) { return(RedirectToAction("Index")); } Project _project = projservice.GetProposalInfo(id.Value); //This will happen In MenuITEM Controller orgservice.GetOrganizationGeneralOfCurrentProposal(id.Value); if (_project.ProjectInfo == null) //no ProjectInfo. { _project.ProjectInfo = new ProjectInfo(); //give some instance. } FinanceResults finres = new FinanceResults(id.Value); // ViewData["moneyLeft"] = finres.Project_TotalAmountLeftFromAwardAmount(); ViewData["CashOnHand"] = finres.Project_TotalCashOnHand(); ViewData["MoneyTransfered"] = finres.Project_TotalMoneyTransferedFromAwardAmount(); // ViewData["StaffRoleList"] = new SelectList(projservice.GetOrgStaffRoles(), "RoleID", "RoleTitle"); // ViewData["ProgramAreaList"] = new SelectList(projservice.GetProgramAreaList(), "ProgramAreaCodeID", "ProgramAreaText"); ViewData["ProposalID"] = id.Value; //Get Events with Type: Site Visit //Get All Events with Type: Narrative Reports ProjectEventService evnts = new ProjectEventService(); IEnumerable <ProjectEvent> projevnts = evnts.GetProjectEventList(id.Value); int sitevisits = 0; int narrativereport = 0; int narrativeaccepted = 0; int narrativerejected = 0; // Project Info=> Accepted Narrative Reports Rename to Current Grant Evaluation //Count Evaluation not Narrative Report. foreach (ProjectEvent projevnt in projevnts) { if (projevnt.EventType.EventTypeName == "Site Visit" || projevnt.EventType.EventTypeName == "Site visit") { sitevisits++; } //if (projevnt.EventDescription != null) //{ // if (projevnt.EventDescription.Contains("Site Visit") || projevnt.EventDescription.Contains("Site visit")) // { // sitevisits++; // } //} if (projevnt.EventType.EventTypeName == "Evaluation Report" || projevnt.EventType.EventTypeName == "Evaluation report") //|| projevnt.EventDescription.Contains("Narrative Report") || projevnt.EventDescription.Contains("Narrative report")) { narrativereport++; if (projevnt.ReportStatus.HasValue) { if (projevnt.ReportStatus.Value == 1) { narrativeaccepted++; } if (projevnt.ReportStatus.Value == 0) { narrativerejected++; } } } } ViewData["NumberOfSiteVisits"] = sitevisits; ViewData["NumberOfAcceptedNarrative"] = narrativeaccepted; ViewData["NumberOfRejectedNarrative"] = narrativerejected; // EventType evType = new EventType(); // evType.EventTypeName // evntTypeSer.GetEventTypeList(); return(View(_project)); }
public ActionResult test() { // var View = new Dictionary<ProgramAreaID, Dictionary<RegionID, numberOfItems>>(); var MView = new Dictionary <FirstVs, Dictionary <int, numberOfItems> >(); ProjectService prj = new ProjectService(); ProjectEventService evnts = new ProjectEventService(); AppDropDownsService appDropDown = new AppDropDownsService(); int?id = 1; IEnumerable <ProjectEvent> projevnts = evnts.GetProjectEventList(id.Value); int sitevisits = 0; IEnumerable <Project> projects = prj.getAllProjects().Where(p => p.CompetitionCode != null && p.ProgramArea != null); //int sitevisits = projevnts.Count(projevnt => projevnt.EventType.EventTypeID == 1 || projevnt.EventType.EventTypeID == 2); // if (projevnt.EventType.EventTypeName == "Site Visit" || projevnt.EventType.EventTypeName == "Site visit") // projevnt.EventType.EventTypeID == 1 || projevnt.EventType.EventTypeID == 2 var projSiteVisits = new Dictionary <Project, int>(); var MView2 = new Dictionary <int, List <VsContainer> >(); //==========1=========== if (projects != null) { var query = projects .GroupBy(g => new //GROUP BY GrantType, ProgramArea Field1, Field2 and SUM AmtRequested. { g.CompetitionCode.CompetCodeID, g.ProgramArea.ProgramAreaCodeID }) .Select(group => new VsContainer() //Select all Grouped into VersusContainer. { ProjId = group.Select(i => i.ProjectID).ToList(), Field1 = group.Key.CompetCodeID.Value, Field2 = group.Key.ProgramAreaCodeID.Value, iAmount = group.Sum(c => c.ProjectEvents.Count(projevnt => projevnt.EventType.EventTypeID == 1 || projevnt.EventType.EventTypeID == 2)), dAmount = group.Select(i => i.ProjectID).Count(), Field1Title = group.Select(i => i.CompetitionCode.CompetitionCodeList.CodeText).FirstOrDefault(), Field2Title = group.Select(i => i.ProgramArea.ProgramAreaList.ProgramAreaText).FirstOrDefault() }); List <VsContainer> vsc = query.ToList(); //test. MView2.Add(1, vsc); } // var View = new Dictionary<ProgramAreaID, Dictionary<CompCodeID, numberOfItems>>(); //======var MView = new Dictionary<FirstVs, Dictionary<int, numberOfItems>>();========================= //==========2=========== IEnumerable <Project> projects2 = prj.getAllProjects().Where(p => p.Organization.Addresses.FirstOrDefault().Region != null && p.ProgramArea != null); if (projects != null) { var query = projects2 .GroupBy(g => new //GROUP BY GrantType, ProgramArea Field1, Field2 and SUM AmtRequested. { g.Organization.Addresses.FirstOrDefault().DDIDRegion, g.ProgramArea.ProgramAreaCodeID }) .Select(group => new VsContainer() //Select all Grouped into VersusContainer. { ProjId = group.Select(i => i.ProjectID).ToList(), Field1 = group.Key.DDIDRegion.Value, Field2 = group.Key.ProgramAreaCodeID.Value, iAmount = group.Sum(c => c.ProjectEvents.Count(projevnt => projevnt.EventType.EventTypeID == 1 || projevnt.EventType.EventTypeID == 2)), dAmount = group.Select(i => i.ProjectID).Count(), Field1Title = group.Select(i => i.Organization.Addresses.FirstOrDefault().RegionList.DDNAME).FirstOrDefault(), Field2Title = group.Select(i => i.ProgramArea.ProgramAreaList.ProgramAreaText).FirstOrDefault() }); List <VsContainer> vsc = query.ToList(); //test. MView2.Add(2, vsc); } //=============================== //foreach (var p in projects) //{ // sitevisits += p.ProjectEvents.Count(projevnt => projevnt.EventType.EventTypeID == 1 || projevnt.EventType.EventTypeID == 2); // projSiteVisits.Add(p, sitevisits); // sitevisits = 0; //} //IEnumerable<RegionList> regions = appDropDown.GetRegionList(); //foreach (RegionList reg in regions) //{ //} //foreach (var v in View) //{ // foreach(var vl in v.Value) // { // int hello = vl.Value.numOfgrant; // } //} //AppDropDownsService ServiceDDL = new AppDropDownsService(); //var SubView = new Dictionary<int, numberOfItems>(); //var SubView2 = new Dictionary<int, numberOfItems>(); //// ============== //var number1 = new numberOfItems(); //number1.numOfgrant = 35; //number1.numOfvisits = 40; //SubView.Add(1, number1); //var number2 = new numberOfItems(); //number2.numOfgrant = 15; //number2.numOfvisits = 10; //SubView.Add(4, number2); //var number3 = new numberOfItems(); //number3.numOfgrant = 25; //number3.numOfvisits = 60; //SubView.Add(8, number3); //var number4 = new numberOfItems(); //number4.numOfgrant = 125; //number4.numOfvisits = 60; //var number5 = new numberOfItems(); //number5.numOfgrant = 125; //number5.numOfvisits = 60; //SubView2.Add(3, number4); //SubView2.Add(2, number5); //FirstVs fv = new FirstVs(); //fv.id = 1; //fv.title = "ECD"; //MView.Add(fv, SubView); //FirstVs fv2 = new FirstVs(); //fv2.id = 2; //fv2.title = "Youth"; //MView.Add(fv2, SubView2); AppDropDownsService ServiceDDL = new AppDropDownsService(); ViewData["MView"] = MView; ViewData["MView2"] = MView2; ViewData["Region"] = ServiceDDL.GetRegionList(); ViewData["CompletionCode"] = ServiceDDL.GetCompetitionCodeList(); ViewData["ProgramArea"] = ServiceDDL.GetProgramAreaList(); return(View()); }
/* * private bool DeleteMyFile(int FileID, int EventID) * { * bool result = true; * ProjectEventService pes = new ProjectEventService(); * string dir = ConfigurationManager.AppSettings["PhysicalPath"]; * string virpath = pes.GetProjectEventDocument(FileID).PhysicalVirtualPath; * System.IO.File.Delete(dir + virpath); * pes.DeleteDocument(FileID, EventID); * return result; * } * */ // // GET: /Event/ public ActionResult Index(int?id) { if (Session["ProposalID"] == null) { return(RedirectToAction("Search", "ProposalInfo")); } EventTypeService et = new EventTypeService(); ProjectEventService pes = new ProjectEventService(); SSPStaffService sss = new SSPStaffService(); ViewData["ddlEventType"] = new SelectList(et.GetEventTypeList(), "EventTypeID", "EventTypeName", 31); //Session["ProposalID"] = "1"; int ProposalID = Session["ProposalID"] != null?int.Parse(Session["ProposalID"].ToString()) : 0; ViewData["ProjectID"] = ProposalID; IEnumerable <ProjectEvent> pe = pes.GetProjectEventList(ProposalID); IEnumerable <SSPStaff> slist = sss.GetSSPStaffListForProject(ProposalID); List <SelectListItem> selects = new List <SelectListItem>(); if (slist != null) { //this gets users who is in keyassosiactions. foreach (var item in slist) { selects.Add(new SelectListItem() { Value = item.SSPStaffID.ToString(), Text = item.FirstName + " " + item.LastName + " " + item.MiddleName }); } //-----------------This chunk added in order not // =========to lose previous eventHolder. //next step we must add users who is participating in this project if they don't exist, //this will cover users who was deleted from keyassociations, but did particular event. //How to do that? we go through all Events, get event Holders and compare HolderID agains slist. if does not exist we add. foreach (ProjectEvent e in pe) { //check if staff in event inside DropDown. SelectListItem sitem = (from x in selects where x.Value.ToString() == e.EventHolderID.ToString() select x).FirstOrDefault(); if (sitem == null) //no staff. { SSPStaff staff = null; //get that user from repository if (e.EventHolderID.HasValue) { staff = sss.GetAccountByID(e.EventHolderID.Value); } //insert. if (staff != null) { selects.Add(new SelectListItem() { Value = staff.SSPStaffID.ToString(), Text = staff.FirstName + " " + staff.LastName + " " + staff.MiddleName }); } } } //---------------------- } ViewData["SSPStaffList"] = selects; ProjectService projservice = new ProjectService();; Project _project; _project = projservice.GetProposalInfo(ProposalID); List <SelectListItem> reportperiods = new List <SelectListItem>(); try { foreach (var item in _project.Budget.ReportPeriodListRs) { reportperiods.Add(new SelectListItem() { Value = item.ReportPeriodID.ToString(), Text = (item.PeriodStart.HasValue ? item.PeriodStart.Value.ToShortDateString() : "") + " - " + (item.PeriodEnd.HasValue ? item.PeriodEnd.Value.ToShortDateString() : "") }); } } catch (Exception ex) {} ViewData["ReportPeriodList"] = reportperiods; if (id.HasValue == true) { ViewData["selectedID"] = id; } return(View(pe)); }
public Dictionary <int, List <VsContainer> > SiteVisitReports(IEnumerable <Project> prj) { // var View = new Dictionary<ProgramAreaID, Dictionary<RegionID, numberOfItems>>(); var MView = new Dictionary <FirstVs, Dictionary <int, numberOfItems> >(); // ProjectService prj = new ProjectService(); ProjectEventService evnts = new ProjectEventService(); AppDropDownsService appDropDown = new AppDropDownsService(); int?id = 1; IEnumerable <ProjectEvent> projevnts = evnts.GetProjectEventList(id.Value); int sitevisits = 0; //Filter OUT NULL STUFF! IEnumerable <Project> projects = prj.Where(p => p.CompetitionCode != null && p.ProgramArea != null); var projSiteVisits = new Dictionary <Project, int>(); var MView2 = new Dictionary <int, List <VsContainer> >(); //==========1=========== if (projects != null) { var query = projects .GroupBy(g => new //GROUP BY GrantType, ProgramArea Field1, Field2 and SUM AmtRequested. { g.CompetitionCode.CompetCodeID, g.ProgramArea.ProgramAreaCodeID }) .Select(group => new VsContainer() //Select all Grouped into VersusContainer. { ProjId = group.Select(i => i.ProjectID).ToList(), Field1 = group.Key.CompetCodeID.Value, Field2 = group.Key.ProgramAreaCodeID.Value, iAmount = group.Sum(c => c.ProjectEvents.Count(projevnt => projevnt.EventType.EventTypeID == 1 || projevnt.EventType.EventTypeID == 2)), dAmount = group.Select(i => i.ProjectID).Count(), Field1Title = group.Select(i => i.CompetitionCode.CompetitionCodeList.CodeText).FirstOrDefault(), Field2Title = group.Select(i => i.ProgramArea.ProgramAreaList.ProgramAreaText).FirstOrDefault() }); List <VsContainer> vsc = query.ToList(); //test. MView2.Add(1, vsc); } // var View = new Dictionary<ProgramAreaID, Dictionary<CompCodeID, numberOfItems>>(); //======var MView = new Dictionary<FirstVs, Dictionary<int, numberOfItems>>();========================= //==========2=========== //Filter OUT NULL STUFF! IEnumerable <Project> projects2 = prj.Where(p => p.Organization != null && p.Organization.Addresses != null && p.Organization.Addresses.FirstOrDefault().Region != null && p.ProgramArea != null); if (projects != null) { var query = projects2 .GroupBy(g => new //GROUP BY GrantType, ProgramArea Field1, Field2 and SUM AmtRequested. { g.Organization.Addresses.FirstOrDefault().DDIDRegion, g.ProgramArea.ProgramAreaCodeID }) .Select(group => new VsContainer() //Select all Grouped into VersusContainer. { ProjId = group.Select(i => i.ProjectID).ToList(), Field1 = group.Key.DDIDRegion.Value, Field2 = group.Key.ProgramAreaCodeID.Value, iAmount = group.Sum(c => c.ProjectEvents.Count(projevnt => projevnt.EventType.EventTypeID == 1 || projevnt.EventType.EventTypeID == 2)), dAmount = group.Select(i => i.ProjectID).Count(), Field1Title = group.Select(i => i.Organization.Addresses.FirstOrDefault().RegionList.DDNAME).FirstOrDefault(), Field2Title = group.Select(i => i.ProgramArea.ProgramAreaList.ProgramAreaText).FirstOrDefault() }); List <VsContainer> vsc = query.ToList(); //test. MView2.Add(2, vsc); } //=============================== return(MView2); }