Example #1
0
        public ActionResult Indicator2()
        {
            AppDropDownsService              ServiceDDL     = new AppDropDownsService();
            IEnumerable <ProgramAreaList>    ProgramArea    = ServiceDDL.GetProgramAreaList();
            IEnumerable <ProposalStatusList> ProposalStatus = ServiceDDL.GetProposalStatusList();
            IEnumerable <GrantTypeList>      GrantType      = ServiceDDL.GetGrantTypeList();

            IEnumerable <CompetitionCodeList> CompletionCode = ServiceDDL.GetCompetitionCodeList();

            IEnumerable <ProposalStatusList>            Status = ServiceDDL.GetProposalStatusList();
            IEnumerable <RegionList>                    Region = ServiceDDL.GetRegionList();
            IEnumerable <IndicatorLabelContentCategory> IndicatorCategoryList =
                ServiceDDL.IndicatorLabelContentCategoryList();

            ViewData["ProgramArea"]    = ProgramArea;
            ViewData["ProposalStatus"] = ProposalStatus;
            ViewData["GrantType"]      = GrantType;

            ViewData["CompletionCode"] = CompletionCode;

            ViewData["Status"] = Status;
            ViewData["Region"] = Region;

            ViewData["IndicatorCategoryList"] = IndicatorCategoryList;

            ViewData["results"] = null;
            return(View());
        }
 public SSSPStaffController()
 {
     appddservice = new AppDropDownsService();
     staffservice = new SSPStaffService();
     session      = new UserSession();
     ulog         = new UserActionLogService();
 }
Example #3
0
        public ActionResult Organization()
        {
            AppDropDownsService           ServiceDDL = new AppDropDownsService();
            IEnumerable <LegalStatusList> ls         = ServiceDDL.GetLegalStatusList();

            ViewData["ls"] = ls;
            return(View());
        }
Example #4
0
        public ActionResult Index()
        {
            AppDropDownsService              ServiceDDL     = new AppDropDownsService();
            IEnumerable <ProgramAreaList>    ProgramArea    = ServiceDDL.GetProgramAreaList();
            IEnumerable <ProposalStatusList> ProposalStatus = ServiceDDL.GetProposalStatusList();

            ViewData["ProgramArea"]    = ProgramArea;
            ViewData["ProposalStatus"] = ProposalStatus;
            return(View());
        }
        public ActionResult BudgetAnalysis()
        {
            AppDropDownsService ServiceDDL = new AppDropDownsService();

            ViewData["CompletionCode"] = ServiceDDL.GetCompetitionCodeList();
            ViewData["ProgramArea"]    = ServiceDDL.GetProgramAreaList();
            ViewData["GrantType"]      = ServiceDDL.GetGrantTypeList();
            ViewData["Status"]         = ServiceDDL.GetProposalStatusList();
            ViewData["results"]        = null;
            ViewData["Region"]         = ServiceDDL.GetRegionList();
            return(View());
        }
        public EventType GetPaymentEventType()
        {
            AppDropDownsService     appdrop    = new AppDropDownsService();
            IEnumerable <EventType> eventsList = appdrop.GetEventTypeList();


            foreach (EventType evtp in eventsList)
            {
                if (evtp.EventTypeName == "Payment")
                {
                    return(evtp);
                }
            }

            return(null);
        }
        public ActionResult Indicator(FinReportFilter frepf, int?ID, List <String> Area, List <String> gtype, List <String> compete,
                                      List <String> status, List <String> oblast, List <String> period, List <String> amount,
                                      List <String> location)
        {
            AppDropDownsService               ServiceDDL     = new AppDropDownsService();
            IEnumerable <ProgramAreaList>     ProgramArea    = ServiceDDL.GetProgramAreaList();
            IEnumerable <ProposalStatusList>  ProposalStatus = ServiceDDL.GetProposalStatusList();
            IEnumerable <GrantTypeList>       GrantType      = ServiceDDL.GetGrantTypeList();
            IEnumerable <CompetitionCodeList> CompletionCode = ServiceDDL.GetCompetitionCodeList();
            IEnumerable <ProposalStatusList>  Status         = ServiceDDL.GetProposalStatusList();
            IEnumerable <RegionList>          Region         = ServiceDDL.GetRegionList();

            ViewData["ProgramArea"]    = ProgramArea;
            ViewData["ProposalStatus"] = ProposalStatus;
            ViewData["GrantType"]      = GrantType;
            ViewData["CompletionCode"] = CompletionCode;
            ViewData["Status"]         = Status;
            ViewData["Region"]         = Region;



            if (frepf != null)
            {
                LReportsRepository rep = new LReportsRepository();
                // IQueryable<Project> prj = rep.GetResults(frepf);
                IQueryable <Project> prj = rep.GetResults2(frepf, ID, Area, gtype, compete,
                                                           status, oblast, period, amount, location);
                List <Project> prjList = prj.ToList();

                if (prj != null)
                {
                    // List<LabelByCount> test =  rep.IndicatorByBaseline(prj, 2);
                    ViewData["report31"] = rep.IndicatorByBaseline(prj);
                    ViewData["report32"] = rep.IndicatorByBenchmark(prj);
                    ViewData["report33"] = rep.IndicatorByFinal(prj);
                    ViewData["prj"]      = prj;
                }

                return(View(frepf));
            }
            else
            {
                return(View());
            }
        }
        //
        // GET: /StaffReport/

        public ActionResult Index()
        {
            AppDropDownsService ServiceDDL = new AppDropDownsService();

            ViewData["GrantType"]   = ServiceDDL.GetGrantTypeList();
            ViewData["ProgramArea"] = ServiceDDL.GetProgramAreaList();
            SSPStaffRepository           ss = new SSPStaffRepository();
            List <StaffGrantTypeGrouped> staffgroupedList = new List <StaffGrantTypeGrouped>();
            StaffGrantTypeGrouped        sffg             = null;

            //ONE Staff!
            // List<ViewStaffMyProject> StaffGrant = ss.GetSSPStaffProjects(2).ToList();
            ViewData["StaffGrant"] = ss.GetSSPStaffProjects(2, 1).ToList();


            //ALL
            List <StaffGrantHolder> gf = ss.GetSSPStaffsProjects(2).ToList();

            foreach (StaffGrantHolder sf in gf)
            {
                try
                {
                    sffg = new StaffGrantTypeGrouped();
                    sffg.grantTypeCount = sf.grantType
                                          .GroupBy(o => o.GrantTypeList.GrantTypeCodeID).ToDictionary(g => g.Key, g => g.Count());
                    sffg.FirstName = sf.FirstName;
                    sffg.LastName  = sf.LastName;
                    sffg.sspid     = sf.sspid;
                }
                catch
                {
                }

                if (sffg != null)
                {
                    staffgroupedList.Add(sffg);
                    sffg = null;
                }
            }


            return(View(staffgroupedList));
        }
        public ActionResult Indicator()
        {
            AppDropDownsService           ServiceDDL  = new AppDropDownsService();
            IEnumerable <ProgramAreaList> ProgramArea = ServiceDDL.GetProgramAreaList();
            //  IEnumerable<ProposalStatusList> ProposalStatus = ServiceDDL.GetProposalStatusList();
            IEnumerable <GrantTypeList>       GrantType      = ServiceDDL.GetGrantTypeList();
            IEnumerable <CompetitionCodeList> CompletionCode = ServiceDDL.GetCompetitionCodeList();
            IEnumerable <ProposalStatusList>  Status         = ServiceDDL.GetProposalStatusList();
            IEnumerable <RegionList>          Region         = ServiceDDL.GetRegionList();

            ViewData["ProgramArea"] = ProgramArea;
            // ViewData["ProposalStatus"] = ProposalStatus;
            ViewData["GrantType"]      = GrantType;
            ViewData["CompletionCode"] = CompletionCode;
            ViewData["Status"]         = Status;
            ViewData["Region"]         = Region;

            return(View());
        }
Example #10
0
        public ActionResult Indicator2(FinReportFilter frepf, int?ID, List <String> Area, List <String> gtype,
                                       List <String> compete,
                                       List <String> status, List <String> oblast, List <String> period,
                                       List <String> amount, List <String> indicatorcategory)
        {
            LReportsRepository rep = new LReportsRepository();


            //IndRepHolder inp = new IndRepHolder();
            // inp.Column = "Akmola obl";
            // inp.Row ="ECD";
            // inp.Val = 1;



            AppDropDownsService ServiceDDL = new AppDropDownsService();

            #region drops
            IEnumerable <ProgramAreaList>               ProgramArea           = ServiceDDL.GetProgramAreaList();
            IEnumerable <ProposalStatusList>            ProposalStatus        = ServiceDDL.GetProposalStatusList();
            IEnumerable <GrantTypeList>                 GrantType             = ServiceDDL.GetGrantTypeList();
            IEnumerable <CompetitionCodeList>           CompletionCode        = ServiceDDL.GetCompetitionCodeList();
            IEnumerable <ProposalStatusList>            Status                = ServiceDDL.GetProposalStatusList();
            IEnumerable <RegionList>                    Region                = ServiceDDL.GetRegionList();
            IEnumerable <IndicatorLabelContentCategory> IndicatorCategoryList =
                ServiceDDL.IndicatorLabelContentCategoryList();


            ViewData["ProgramArea"] = ProgramArea;
            //take only ECD and Youth.
            IEnumerable <ProgramAreaList> ProgramArea2 = ProgramArea.Where(s => s.ProgramAreaText == "ECD" || s.ProgramAreaText == "Youth");
            ViewData["ProgramArea2"]          = ProgramArea2;
            ViewData["ProposalStatus"]        = ProposalStatus;
            ViewData["GrantType"]             = GrantType;
            ViewData["CompletionCode"]        = CompletionCode;
            ViewData["Status"]                = Status;
            ViewData["Region"]                = Region;
            ViewData["IndicatorCategoryList"] = IndicatorCategoryList;
            #endregion
            //if (frepf != null)
            //{


            IQueryable <Project> prj = rep.GetResults3(frepf, ID, Area, gtype, compete, status, period, oblast, amount);
            //1. gets resulting project list after filtering.


            List <Project> prjList = prj.ToList();
            ViewData["prj"] = prj;


            //  List<IndRepHolder> zz = rep.IndicatorsByRoundArea(prj);
            List <IndRepHolder> zz  = rep.IndicatorsByCompetitionContentCategory(prj);
            List <IndRepHolder> zz2 = rep.IndicatorsByRegionContentCategory(prj);


            ViewData["LIndRep"]  = zz;
            ViewData["LIndRep2"] = zz2;

            if (prjList != null)
            {
                //2. generates/calculates VS amounts.
                Dictionary <IndicatorContainerType, Dictionary <IndicatorLabelContentCategory, List <IndicatorRepContainer> > > results = IndicatorReportCore(
                    prj, frepf, Area, gtype, compete, status, oblast, period, amount, indicatorcategory);

                ViewData["results2"] = results;
            }



            //add List Filters.  //enable Report View enabled if not null.

            if (frepf.isIndicator != null && frepf.isIndicator.Value == true)
            {
                frepf.isIndicator = true;
            }
            else
            {
                frepf.isIndicator = false;
            }

            if (Area != null)
            {
                frepf.IsArea = true;
            }
            if (gtype != null)
            {
                frepf.IsGrantType = true;
            }
            if (compete != null)
            {
                frepf.IsCompetitionCode = true;
            }
            if (status != null)
            {
                frepf.IsStatus = true;
            }
            if (period != null)
            {
                frepf.IsPeriod = true;
            }
            //=====

            return(View(frepf));
        }
Example #11
0
        public Dictionary <IndicatorContainerType, Dictionary <IndicatorLabelContentCategory, List <IndicatorRepContainer> > > IndicatorReportCore(
            IQueryable <Project> prjList, FinReportFilter frepf, List <String> Area, List <String> gtype,
            List <String> compete, List <String> status, List <String> oblast, List <String> period, List <String> amount, List <String> indicatorcategory)
        {
            AppDropDownsService ServiceDDL = new AppDropDownsService();
            List <IndicatorLabelContentCategory> IndContCats = new List <IndicatorLabelContentCategory>();
            var regions     = new List <RegionList>();
            var areas       = new List <ProgramAreaList>();
            var statusList  = new List <ProposalStatusList>();
            var gtypeList   = new List <GrantTypeList>();
            var competeList = new List <CompetitionCodeList>();

            //create IndicatorContentCategory List to be passed.
            if (indicatorcategory != null)
            {
                foreach (string s in indicatorcategory)
                {
                    IndContCats.Add(ServiceDDL.GetIndicatorLabelContentCategory(Convert.ToInt32(s)));
                }
            }

            var LLVsContainer = new Dictionary <IndicatorContainerType, Dictionary <IndicatorLabelContentCategory, List <IndicatorRepContainer> > >();

            // Dictionary<ContainerType, List<VsContainer>> LLVsContainer = null;
            if (oblast != null && oblast.Count > 0 && indicatorcategory != null && indicatorcategory.Count > 0)
            {
                //create RegionsList List to be passed.
                foreach (string s in oblast)
                {
                    if (!s.Contains("All"))   //skip ALL.
                    {
                        regions.Add(ServiceDDL.GetRegionList().FirstOrDefault(w => w.DDID == Convert.ToInt32(s)));
                    }
                }
                var result = FillContainer(prjList, frepf, IndicatorContainerType.OblastVsIndicatorLabelCategory,
                                           IndContCats, regions, null, null, null);
                LLVsContainer.Add(IndicatorContainerType.OblastVsIndicatorLabelCategory, result);
            }

            if (Area != null && Area.Count > 0 && indicatorcategory != null && indicatorcategory.Count > 0)
            {
                foreach (string s in Area)
                {
                    if (!s.Contains("All"))   //skip ALL.
                    {
                        areas.Add(ServiceDDL.GetProgramAreaList().FirstOrDefault(w => w.ProgramAreaCodeID == Convert.ToInt32(s)));
                    }
                }
                var result = FillContainer(prjList, frepf, IndicatorContainerType.AreaVsIndicatorLabelCategory,
                                           IndContCats, null, areas, null, null);
                LLVsContainer.Add(IndicatorContainerType.AreaVsIndicatorLabelCategory, result);
            }

            if (gtype != null && gtype.Count > 0 && indicatorcategory != null && indicatorcategory.Count > 0)
            {
                foreach (string s in gtype)
                {
                    if (!s.Contains("All"))   //skip ALL.
                    {
                        gtypeList.Add(ServiceDDL.GetGrantTypeList().FirstOrDefault(w => w.GrantTypeCodeID == Convert.ToInt32(s)));
                    }
                }
                var result = FillContainer(prjList, frepf, IndicatorContainerType.TypeVsIndicatorLabelCategory,
                                           IndContCats, null, null, gtypeList, null);
                LLVsContainer.Add(IndicatorContainerType.TypeVsIndicatorLabelCategory, result);
            }

            if (compete != null && compete.Count > 0 && indicatorcategory != null && indicatorcategory.Count > 0)
            {
                foreach (string s in compete)
                {
                    if (!s.Contains("All"))   //skip ALL.
                    {
                        competeList.Add(ServiceDDL.GetCompetitionCodeList().FirstOrDefault(w => w.CompetitionCodeID == Convert.ToInt32(s)));
                    }
                }
                var result = FillContainer(prjList, frepf, IndicatorContainerType.RoundVsIndicatorLabelCategory,
                                           IndContCats, null, null, null, competeList);
                LLVsContainer.Add(IndicatorContainerType.RoundVsIndicatorLabelCategory, result);
            }
            bool areaVsRound = false;

            //more coming here.


            return(LLVsContainer);
        }
        public ActionResult outcome(FinReportFilter frepf, int?ID, List <String> Area, List <String> gtype,
                                    List <String> compete,
                                    List <String> status, List <String> oblast, List <String> period,
                                    List <String> amount, List <String> indicatorcategory)
        {
            AppDropDownsService ServiceDDL = new AppDropDownsService();

            #region drops
            IEnumerable <ProgramAreaList>               ProgramArea           = ServiceDDL.GetProgramAreaList();
            IEnumerable <ProposalStatusList>            ProposalStatus        = ServiceDDL.GetProposalStatusList();
            IEnumerable <GrantTypeList>                 GrantType             = ServiceDDL.GetGrantTypeList();
            IEnumerable <CompetitionCodeList>           CompletionCode        = ServiceDDL.GetCompetitionCodeList();
            IEnumerable <ProposalStatusList>            Status                = ServiceDDL.GetProposalStatusList();
            IEnumerable <RegionList>                    Region                = ServiceDDL.GetRegionList();
            IEnumerable <IndicatorLabelContentCategory> IndicatorCategoryList =
                ServiceDDL.IndicatorLabelContentCategoryList();
            ViewData["ProgramArea"]           = ProgramArea;
            ViewData["ProposalStatus"]        = ProposalStatus;
            ViewData["GrantType"]             = GrantType;
            ViewData["CompletionCode"]        = CompletionCode;
            ViewData["Status"]                = Status;
            ViewData["Region"]                = Region;
            ViewData["IndicatorCategoryList"] = IndicatorCategoryList;
            #endregion
            //if (frepf != null)
            //{
            LReportsRepository rep = new LReportsRepository();


            IQueryable <Project> prj = rep.GetResults3(frepf, ID, Area, gtype, compete, status, period, oblast, amount);
            //1. gets resulting project list after filtering.


            List <Project> prjList = prj.ToList();
            ViewData["prj"] = prj;



            //add List Filters.  //enable Report View enabled if not null.
            if (Area != null)
            {
                frepf.IsArea = true;
            }
            if (gtype != null)
            {
                frepf.IsGrantType = true;
            }
            if (compete != null)
            {
                frepf.IsCompetitionCode = true;
            }
            if (status != null)
            {
                frepf.IsStatus = true;
            }
            if (period != null)
            {
                frepf.IsPeriod = true;
            }
            //=====

            return(View(frepf));
        }
        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());
        }
        public ActionResult Index(FinReportFilter frepf, int?ID, List <String> Area, List <String> gtype, List <String> compete,
                                  List <String> status, List <String> period, List <String> amount, List <String> oblast, List <String> lfIndicators)
        {
            AppDropDownsService ServiceDDL = new AppDropDownsService();

            ViewData["CompletionCode"]  = ServiceDDL.GetCompetitionCodeList();
            ViewData["ProgramArea"]     = ServiceDDL.GetProgramAreaList();
            ViewData["GrantType"]       = ServiceDDL.GetGrantTypeList();
            ViewData["Status"]          = ServiceDDL.GetProposalStatusList();
            ViewData["Region"]          = ServiceDDL.GetRegionList();
            ViewData["BudgetCatList"]   = ServiceDDL.GetCatList();
            ViewData["LfIndicatorList"] = ServiceDDL.GetLfIndicatorList();

            LReportsRepository   rep = new LReportsRepository();
            IQueryable <Project> prj = rep.GetResults3(frepf, ID, Area, gtype, compete, status, period, oblast, amount, lfIndicators); //1. gets resulting project list after filtering.


            List <Project> prjList = prj.ToList();

            ViewData["prj"] = prj;



            if (prjList != null)
            {
                var query = prjList
                            .GroupBy(g => new //GROUP BY GrantType, ProgramArea Field1, Field2 and SUM AmtRequested.
                {
                    g.LFIndicator.LFIndicatorID,
                })
                            .Select(group => new VsContainer() //Select all Grouped into VersusContainer.
                {
                    ProjId      = group.Select(i => i.ProjectID).ToList(),
                    Field1      = group.Key.LFIndicatorID,
                    iAmount     = prjList.Count(),
                    dAmount     = group.Select(i => i.ProjectID).Count(),
                    Field1Title = "# of grants with " + group.Select(i => i.LFIndicator.LFIndicatorList.CodeText).FirstOrDefault()
                });

                List <VsContainer> vsc = query.ToList();   //test.
                ViewData["vsc"] = vsc;
            }


            //add List Filters.  //enable Report View enabled if not null.
            if (lfIndicators != null)
            {
                frepf.isLFIndicator = true;
            }
            if (Area != null)
            {
                frepf.IsArea = true;
            }
            if (gtype != null)
            {
                frepf.IsGrantType = true;
            }
            if (compete != null)
            {
                frepf.IsCompetitionCode = true;
            }
            if (status != null)
            {
                frepf.IsStatus = true;
            }
            if (period != null)
            {
                frepf.IsPeriod = true;
            }
            if (oblast != null)
            {
                frepf.isRegion = true;
            }
            //=====

            return(View(frepf));
        }
        public ActionResult allstaffgt(int?id, int?rt, int?rti, int?status)
        {
            AppDropDownsService ServiceDDL = new AppDropDownsService();

            ViewData["GrantType"]   = ServiceDDL.GetGrantTypeList();
            ViewData["ProgramArea"] = ServiceDDL.GetProgramAreaList();
            SSPStaffRepository    ss   = new SSPStaffRepository();
            StaffGrantTypeGrouped sffg = null;

            List <StaffGrantTypeGrouped> staffgroupedList = new List <StaffGrantTypeGrouped>();
            //ALL
            List <StaffGrantHolder> gf = null;

            if (status.HasValue)
            {
                gf = ss.GetSSPStaffsProjects(status.Value).ToList();  //could be active =1 or all=2.
            }
            else
            {
                gf = ss.GetSSPStaffsProjects(2).ToList();   //default get all grants!
            }

            if (rt.HasValue && rt.Value > 0)
            {
                ViewData["ReportType"] = rt.Value;
            }

            #region --- test ---
            //foreach (StaffGrantType sf in gf)
            //{
            //    try
            //    {
            //        sffg = new StaffGrantTypeGrouped();
            //        sffg.grantTypeCount = sf.grantType
            //            .GroupBy(o => o.GrantTypeList.GrantTypeCodeID).ToDictionary(g => g.Key, g => g.Count());
            //        sffg.FirstName = sf.FirstName;
            //        sffg.LastName = sf.LastName;
            //        sffg.sspid = sf.sspid;
            //    }
            //    catch
            //    {
            //    }

            //    if (sffg != null)
            //    {
            //        staffgroupedList.Add(sffg);
            //        sffg = null;
            //    }
            //}

            #endregion //All staff.
            ViewData["StaffGrantTypeList"] = gf;


            //ONE Staff!
            // List<ViewStaffMyProject> StaffGrant = ss.GetSSPStaffProjects(2).ToList();
            int reptype = 2;
            if (rti.HasValue && rti.Value > 0)
            {
                reptype = rti.Value;
                ViewData["ReportTypeInd"] = rti.Value;
            }
            //else
            //{
            //    ViewData["ReportTypeInd"] = 1;
            //}

            if (id.HasValue && id.Value > 0)
            {
                ViewData["StaffGrant"] = ss.GetSSPStaffProjects(id.Value, reptype).ToList();
            }
            //else
            //{
            //    ViewData["StaffGrant"] = ss.GetSSPStaffProjects(1, reptype).ToList();
            //}

            return(View());

            //return View(staffgroupedList);
        }
        public ActionResult BudgetAnalysis(FinReportFilter frepf, int?ID, List <String> Area, List <String> gtype, List <String> compete,
                                           List <String> status, List <String> period, List <String> amount, List <String> oblast)
        {
            AppDropDownsService ServiceDDL = new AppDropDownsService();

            ViewData["CompletionCode"] = ServiceDDL.GetCompetitionCodeList();
            ViewData["ProgramArea"]    = ServiceDDL.GetProgramAreaList();
            ViewData["GrantType"]      = ServiceDDL.GetGrantTypeList();
            ViewData["Status"]         = ServiceDDL.GetProposalStatusList();
            ViewData["Region"]         = ServiceDDL.GetRegionList();
            //if (frepf != null)
            //{
            LReportsRepository   rep = new LReportsRepository();
            IQueryable <Project> prj = rep.GetResults3(frepf, ID, Area, gtype, compete, status, period, oblast, amount); //1. gets resulting project list after filtering.


            List <Project> prjList = prj.ToList();

            ViewData["prj"] = prj;


            if (prjList != null)
            {
                //2. generates/calculates VS amounts.
                if (!frepf.isListOnly.Value)
                {
                    Dictionary <ContainerType, Dictionary <AmountTypes, List <VsContainer> > > results = FinReportCore(prj, frepf, Area, gtype, compete, status, period, oblast);
                    ViewData["results2"] = results;
                }
            }

            //add List Filters.  //enable Report View enabled if not null.
            if (Area != null)
            {
                frepf.IsArea = true;
            }
            if (gtype != null)
            {
                frepf.IsGrantType = true;
            }
            if (compete != null)
            {
                frepf.IsCompetitionCode = true;
            }
            if (status != null)
            {
                frepf.IsStatus = true;
            }
            if (period != null)
            {
                frepf.IsPeriod = true;
            }
            if (oblast != null)
            {
                frepf.isRegion = true;
            }


            //=====

            return(View(frepf));
        }
        public bool CreateFromTemplate(int TemplateDocsID, int ProjectID, int EventID, int?ReportPeriodID)
        {
            bool result = true;

            try
            {
                TemplateService ts      = new TemplateService();
                string          dir     = ConfigurationManager.AppSettings["PhysicalPath"];
                string          WordDoc = ts.GenerateDocumentFromTemplateName(TemplateDocsID, EventID, ProjectID, dir, ReportPeriodID);

                TemplateFile tfile = ts.GetTemplateDocument(TemplateDocsID).TemplateFile;

                string virtdir = "files/" + ProjectID.ToString() + "/"; // "files/A" + DateTime.Now.Year.ToString().Substring(2) + ProjectID.ToString() + "/";
                dir += virtdir.Replace("/", "\\");

                if (!(Directory.Exists(dir)))
                {
                    Directory.CreateDirectory(dir);
                }
                string fileformat = EventID.ToString() + "_" + ProjectID.ToString() + "_";
                int    i;
                for (i = 1; System.IO.File.Exists(dir + fileformat + i.ToString() + "." + tfile.fileextension); i++)
                {
                }
                System.IO.File.WriteAllText(dir + fileformat + i.ToString() + "." + tfile.fileextension, WordDoc);
                ProjectEventDocument docItem = new ProjectEventDocument();
                docItem.Author               = session.CurrentUser.FirstName + " " + session.CurrentUser.LastName + " " + session.CurrentUser.MiddleName;;
                docItem.CreatedDate          = DateTime.Now;
                docItem.fileextension        = tfile.fileextension;
                docItem.FileName             = fileformat + i.ToString() + "." + tfile.fileextension;
                docItem.PhysicalAbsolutePath = dir + fileformat + i.ToString() + "." + tfile.fileextension;
                docItem.PhysicalVirtualPath  = "\\" + virtdir.Replace("/", "\\") + fileformat + i.ToString() + "." + tfile.fileextension;
                docItem.UpdatedDate          = docItem.CreatedDate;
                docItem.WebVirtualPath       = "/" + virtdir + fileformat + i.ToString() + "." + tfile.fileextension;
                //docItem.
                ProjectEventService pes = new ProjectEventService();
                pes.InsertDocument(docItem, EventID);

                TemplateDocument tdoc = ts.GetTemplateDocument(TemplateDocsID);
                if (tdoc != null)
                {
                    ProjectService projservice = new ProjectService();

                    //acknowledgement letter - completed project
                    if (tdoc.TemplateDocName.ToLower().Contains("letter") && tdoc.TemplateDocName.ToLower().Contains("acknowledgement"))
                    {
                        AppDropDownsService apservice = new AppDropDownsService();
                        ProposalStatusList  psitem    = apservice.ProposalStatusListGetItem("Completed");

                        //if we have needed status in DB then
                        if (psitem != null)
                        {
                            Project        _project = projservice.GetProposalInfo(ProjectID);
                            ProposalStatus _prop    = _project.ProposalStatus;
                            _prop.PropStatusID = psitem.ProposalStatusID;
                            projservice.ProposalStatusUpdate(_prop);
                        }
                    }

                    //award letter - Active project
                    if (tdoc.TemplateDocName.ToLower().Contains("letter") && tdoc.TemplateDocName.ToLower().Contains("award"))
                    {
                        AppDropDownsService apservice = new AppDropDownsService();
                        ProposalStatusList  psitem    = apservice.ProposalStatusListGetItem("Active");

                        //if we have needed status in DB then
                        if (psitem != null)
                        {
                            Project        _project = projservice.GetProposalInfo(ProjectID);
                            ProposalStatus _prop    = _project.ProposalStatus;
                            _prop.PropStatusID = psitem.ProposalStatusID;
                            projservice.ProposalStatusUpdate(_prop);
                        }
                    }

                    //close out letter - Closed project
                    if (tdoc.TemplateDocName.ToLower().Contains("letter") && tdoc.TemplateDocName.ToLower().Contains("close") && tdoc.TemplateDocName.ToLower().Contains("out"))
                    {
                        AppDropDownsService apservice = new AppDropDownsService();
                        ProposalStatusList  psitem    = apservice.ProposalStatusListGetItem("Closed");

                        //if we have needed status in DB then
                        if (psitem != null)
                        {
                            Project        _project = projservice.GetProposalInfo(ProjectID);
                            ProposalStatus _prop    = _project.ProposalStatus;
                            _prop.PropStatusID = psitem.ProposalStatusID;
                            //  projservice.ProposalStatusUpdate(_prop);
                        }
                    }

                    //suspended letter - Active project
                    if (tdoc.TemplateDocName.ToLower().Contains("letter") && tdoc.TemplateDocName.ToLower().Contains("suspended"))
                    {
                        AppDropDownsService apservice = new AppDropDownsService();
                        ProposalStatusList  psitem    = apservice.ProposalStatusListGetItem("Suspended");

                        //if we have needed status in DB then
                        if (psitem != null)
                        {
                            Project        _project = projservice.GetProposalInfo(ProjectID);
                            ProposalStatus _prop    = _project.ProposalStatus;
                            _prop.PropStatusID = psitem.ProposalStatusID;
                            projservice.ProposalStatusUpdate(_prop);
                        }
                    }

                    //reject letter - Rejected project
                    if (tdoc.TemplateDocName.ToLower().Contains("letter") && tdoc.TemplateDocName.ToLower().Contains("reject"))
                    {
                        AppDropDownsService apservice = new AppDropDownsService();
                        ProposalStatusList  psitem    = apservice.ProposalStatusListGetItem("Rejected");

                        //if we have needed status in DB then
                        if (psitem != null)
                        {
                            Project        _project = projservice.GetProposalInfo(ProjectID);
                            ProposalStatus _prop    = _project.ProposalStatus;
                            _prop.PropStatusID = psitem.ProposalStatusID;
                            projservice.ProposalStatusUpdate(_prop);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                result = false;
            }
            return(result);
        }
        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);
        }