public async Task <IHttpActionResult> GetWebTrendReportData(int Month, int Year)
        {
            var response = new WebTrend();

            try
            {
                response = await new WebBL().GetWebTrendReportData(Month, Year);
            }
            catch (Exception ex)
            {
                LogManager.Logger.WriteException("WebController", "GetWebTrendReportData", ex.Message, ex);
            }
            return(Ok(response));
        }
Example #2
0
        public async Task <WebTrend> GetWebTrendReportData(int Month, int Year)
        {
            WebTrend list = new WebTrend();

            using (var ctx = new DbEntities())
            {
                var StatusList = await ctx.TaskStatus.ToListAsync();

                var WebTrendSiteList = await ctx.WebTrendSiteData.Where(x => x.IsActive == true && x.Month == Month && x.Year == Year).ToListAsync();

                var webTrendSiteData = (from a in WebTrendSiteList
                                        from b in StatusList.Where(b => a.Status == b.Id)
                                        select new
                {
                    a.Name,
                    a.Description,
                    Status = b.Description,
                    b.Icon
                });

                if (webTrendSiteData != null)
                {
                    List <WebTrendSiteDataModel> SiteDataList = new List <WebTrendSiteDataModel>();
                    foreach (var item in webTrendSiteData)
                    {
                        WebTrendSiteDataModel sitedata = new WebTrendSiteDataModel();
                        sitedata.Name        = item.Name;
                        sitedata.Description = item.Description;
                        sitedata.Status      = item.Status;
                        sitedata.Icon        = item.Icon;
                        SiteDataList.Add(sitedata);
                    }
                    list.WebTrendSiteData = SiteDataList;
                }

                var WebTrendLinkList = await ctx.WebTrendLinkData.Where(x => x.IsActive == true && x.Month == Month && x.Year == Year).ToListAsync();

                var webTrendNAEPLinkData = (from a in WebTrendLinkList
                                            from b in StatusList.Where(b => a.Status == b.Id)
                                            where a.Status == 6
                                            select new
                {
                    a.Link,
                    Status = b.Description,
                    b.Icon
                });

                if (webTrendNAEPLinkData != null)
                {
                    List <WebTrendNAEPLinkDataModel> LinkDataList = new List <WebTrendNAEPLinkDataModel>();
                    foreach (var item in webTrendNAEPLinkData)
                    {
                        WebTrendNAEPLinkDataModel linkdata = new WebTrendNAEPLinkDataModel();
                        linkdata.Link   = item.Link;
                        linkdata.Status = item.Status;
                        linkdata.Icon   = item.Icon;
                        LinkDataList.Add(linkdata);
                    }
                    list.WebTrendNAEPLinkData = LinkDataList;
                }

                var webTrendNRCLinkData = (from a in WebTrendLinkList
                                           from b in StatusList.Where(b => a.Status == b.Id)
                                           where a.Status == 9
                                           select new
                {
                    a.Link,
                    Status = b.Description,
                    b.Icon
                });

                if (webTrendNRCLinkData != null)
                {
                    List <WebTrendNRCLinkDataModel> LinkDataList = new List <WebTrendNRCLinkDataModel>();
                    foreach (var item in webTrendNAEPLinkData)
                    {
                        WebTrendNRCLinkDataModel linkdata = new WebTrendNRCLinkDataModel();
                        linkdata.Link   = item.Link;
                        linkdata.Status = item.Status;
                        linkdata.Icon   = item.Icon;
                        LinkDataList.Add(linkdata);
                    }
                    list.WebTrendNRCLinkData = LinkDataList;
                }

                var WbrTrendTermList = await ctx.WebTrendTermData.Where(x => x.IsActive == true && x.Month == Month && x.Year == Year).ToListAsync();

                var webTrendTermData = (from a in WbrTrendTermList
                                        from b in StatusList.Where(b => a.Status == b.Id)
                                        select new
                {
                    a.Term,
                    Status = b.Description,
                    b.Icon
                });

                if (webTrendTermData != null)
                {
                    List <WebTrendTermDataModel> TermDataList = new List <WebTrendTermDataModel>();
                    foreach (var item in webTrendTermData)
                    {
                        WebTrendTermDataModel termdata = new WebTrendTermDataModel();
                        termdata.Term   = item.Term;
                        termdata.Status = item.Status;
                        termdata.Icon   = item.Icon;
                        TermDataList.Add(termdata);
                    }
                    list.WebTrendTermData = TermDataList;
                }

                var WebTrendResourceList = await ctx.WebTrendResourceData.Where(x => x.IsActive == true && x.Month == Month && x.Year == Year).ToListAsync();

                var webTrendResourceData = (from a in WebTrendResourceList
                                            from b in StatusList.Where(b => a.Status == b.Id)
                                            select new
                {
                    a.Description,
                    Status = b.Description,
                    b.Icon
                });

                if (webTrendResourceData != null)
                {
                    List <WebTrendResourceDataModel> ResourceDataList = new List <WebTrendResourceDataModel>();
                    foreach (var item in webTrendResourceData)
                    {
                        WebTrendResourceDataModel resourcedata = new WebTrendResourceDataModel();
                        resourcedata.Description = item.Description;
                        resourcedata.Status      = item.Status;
                        resourcedata.Icon        = item.Icon;
                        ResourceDataList.Add(resourcedata);
                    }
                    list.WebTrendResourceData = ResourceDataList;
                }

                return(list);
            }
        }