/*
        public static User getUser(HttpContext context, CookDBDataContext db)
        {
            return db.Users.SingleOrDefault(a => a.username.Equals(context.Request.ServerVariables["AUTH_USER"]));
        }
        */

        public void ProcessRequest(HttpContext context) {
            bool debug = false;
            if (context.Request.Url.AbsolutePath.Contains("CookbookDEV") || !isNull(context.Request.Params.Get("CookbookDEV"))) {
                debug = false; // change back if you need...
            }
            CookDBDataContext db = getDataContext(context);
            PagedData ret = null;
            context.Response.ContentType = "text/html";

            //User u = getUser(context, db);

            string msg = "Unknown failure";
            try {
                int start = intParse(context.Request.Params.Get("start"));
                int limit = intParse(context.Request.Params.Get("limit"));
                ret = ProcessRequest(context, db, start, limit);
            }
            catch (Exception e) {
                msg = e.Message;
                if (debug) throw new Exception("Error", e);
            }
            if (ret == null)
                ret = new PagedData(msg, false);

            context.Response.Write(JsonConvert.SerializeObject(ret, 
                new JsonConverter[] { new JavaScriptDateTimeConverter() }));
        }
Beispiel #2
0
        public ActionResult Index(string path)
        {
            PagedData<DealModels> deals = new PagedData<DealModels>();

            if (path == null)
            {
                _categoryId = "Wszystkie";
                _forumId = "WszystkieMiasta";
                _filter = "Hot";
                // TODO :: Nalezy zmienic podstawowe wyszukiwanie na klasyczne zapytanie, dzialaja 3 razy szybciej
                //var values = new StringBuilder();
                //var sql = string.Format(
                //    "SELECT [DealId],[Category],[Forum],[UrlDeal],[Title],[Description],[Prize],[PhotoUrl],[StartDate],[EndDate],[AddedDate],[Expired],[Rank],[Quality],[NumberOfComments],[SimilarOffer],[SimilarOffer2],[SimilarOffer3],[ExtraDescription],[Discriminator],[UserModels_UserId],[UserModels_UserId1],[User_UserId],[City_CityId]FROM [taniejrazem_razemTaniej].[dbo].[DealModels]",
                //    values);
                //var razem = new RazemTaniej.DbManger.RazemTaniejEntities();
                //deals.Data = dbHelper.DataBase.Set<DealModels>().SqlQuery(sql).ToList();
                deals = CreatePaginator(_categoryId, _forumId, _filter);
            }
            else
            {
                var url = Utils.ToolUtils.SeparateRouteAddress(path);
                deals = CreatePaginator(url[0], url[1], url[2]);

                _categoryId = url[0];
                _forumId = url[1];
                _filter = url[2];
                ToolUtils._lastUrl = "../" + _categoryId + "/" + _forumId + "/" + _filter + "/";
            }

            HttpContext.Session["city"] = _forumId;
            ViewBag.numberOfDeals = dbHelper.GetNumberOfAllDeal();
            ViewBag.numberOfAddedToday = dbHelper.GetNumberOfDealAddedToday();

            return View(deals);
        }
Beispiel #3
0
        public ActionResult Search(string word, bool statusOfRadio)
        {
            PagedData<DealModels> deals = new PagedData<DealModels>();
            IEnumerable<DealModels> query;
            if (statusOfRadio == false)
            {
                 query = from d in dbManager.DataBase.Deal
                            where d.Title.Contains(word)
                            select d;
            }
            else
            {
                 query =    from d in dbManager.DataBase.Deal
                            where d.Description.Contains(word)
                            select d;
            }

            var dealsFiltered = query;
            deals.Data = dealsFiltered;
            deals.NumberOfPages = Convert.ToInt32(Math.Ceiling((double)deals.Data.Count() / 10));
            deals.Data = deals.Data.Take(10);
            deals.CurrentPage = 1;

            return PartialView("../Home/Index", deals);
        }
		public ActionResult Index() {
			PagedData<GalleryGroup> model = new PagedData<GalleryGroup>();
			model.InitOrderBy(x => x.GalleryTitle, true);
			model.PageSize = 25;
			model.PageNumber = 1;

			return Index(model);
		}
Beispiel #5
0
        public ActionResult GetDealsFromPage(int id)
        {
            PagedData<DealModels> deals = new PagedData<DealModels>();
            deals = CreatePaginator(_categoryId, _forumId, _filter,  id);

            ActiveDealQuery = deals.Data;
            return PartialView("Index",deals);
        }
 public ActionResult pager()
 {
     var preguntas = new PagedData<Pregunta>();
     using (var ctx = new Base())
     {
         preguntas.Data = ctx.Preguntas.Take(PageSize1).ToList();
         preguntas.NumberOfPages = Convert.ToInt32(Math.Ceiling((Double)ctx.Preguntas.Count() / PageSize1));
         preguntas.CurrentPage = 1;
     }
     return View(preguntas);
 }
Beispiel #7
0
        public ActionResult FilterCity(string id)
        {
            PagedData<DealModels> deals = new PagedData<DealModels>();

            var dealsFiltered = dbHelper.GetDealsFromCity(ActiveDealQuery, id);
            deals.Data = dealsFiltered;
            deals.NumberOfPages = Convert.ToInt32(Math.Ceiling((double)deals.Data.Count() / _pageSize));
            deals.Data = deals.Data.Take(_pageSize);
            deals.CurrentPage = 1;

            return PartialView("Index", deals);
        }
		public ActionResult Suppliers(PagedData<Supplier> model) {
			model.ToggleSort();
			var srt = model.ParseSort();
			var query = ReflectionUtilities.SortByParm<Supplier>(db.Suppliers, srt.SortField, srt.SortDirection);

			model.DataSource = query.Skip(model.PageSize * (model.PageNumber - 1)).Take(model.PageSize).ToList();
			model.TotalRecords = db.Suppliers.Count();

			ModelState.Clear();

			return View(model);
		}
		public ActionResult Suppliers() {
			PagedData<Supplier> model = new PagedData<Supplier>();
			model.InitOrderBy(x => x.CompanyName);
			model.PageSize = 10;

			var srt = model.ParseSort();
			var query = ReflectionUtilities.SortByParm<Supplier>(db.Suppliers, srt.SortField, srt.SortDirection);

			model.DataSource = query.Take(model.PageSize).ToList();
			model.TotalRecords = db.Suppliers.Count();

			return View(model);
		}
 public ActionResult cuerpoPrueba(int page)
 {
     var preguntas = new PagedData<Pregunta>();
     List<Pregunta> a = new List<Pregunta>();
     using(var ctx = new Base())
     {
         a = ctx.Preguntas.ToList();
         preguntas.Data = a.Skip(PageSize1 * (page - 1)).Take(PageSize1);
         preguntas.NumberOfPages = Convert.ToInt32(Math.Ceiling((double)ctx.Preguntas.Count() / PageSize1));
         preguntas.CurrentPage = page;
     }
     return PartialView(preguntas);
 }
        public ActionResult Discussion(int page)
        {
            var _pagedData = new PagedData<tblQuestion>();

            using (var db = new SVDB_Entities())
            {
                _pagedData.Data = db.tblQuestions.OrderBy(x => x.questionId).Skip(PageSize * (page -1)).Take(PageSize).ToList();
                _pagedData.NumberOfPages = Convert.ToInt32(Math.Ceiling((double)db.tblQuestions.Count() / PageSize));
                _pagedData.CurrentPage = page;
            }
            ViewBag._pagedData = _pagedData;
            return PartialView(_pagedData);
        }
Beispiel #12
0
        public ActionResult GetCity(string id)
        {
            HomeController._forumId = id;

            PagedData<DealModels> deals = new PagedData<DealModels>();
            var query = dbHelper.GetDealsFromCity(dbHelper.GetNotExpiredDeals(dbHelper.GetAllDeals()),id);
            var dealsFiltered = query;
            deals.Data = dealsFiltered;
            deals.NumberOfPages = Convert.ToInt32(Math.Ceiling((double)deals.Data.Count() / 10));
            deals.Data = deals.Data.Take(10);
            deals.CurrentPage = 1;
            return PartialView("../Home/index", deals);
        }
		// GET: Admin
		public ActionResult Products() {
			PagedData<Product> model = new PagedData<Product>();
			model.InitOrderBy(x => x.ProductName);
			model.PageSize = 20;

			var srt = model.ParseSort();
			var query = ReflectionUtilities.SortByParm<Product>(db.Products, srt.SortField, srt.SortDirection);

			model.DataSource = query.Take(model.PageSize).ToList();
			model.TotalRecords = db.Products.Count();
			ViewBag.SupplierList = db.Suppliers.ToList();

			return View(model);
		}
		// GET: Test
		public ActionResult Index() {
			PagedData<tblGalleryImage> model = new PagedData<tblGalleryImage>();
			//model.PageSize = 10;
			//model.PageNumber = 1;
			model.InitOrderBy(x => x.ImageOrder, true);

			using (PhotoGalleryDataContext db = PhotoGalleryDataContext.GetDataContext()) {
				model.DataSource = (from c in db.tblGalleryImages
									orderby c.ImageOrder ascending
									select c).Skip(model.PageSize * (model.PageNumber - 1)).Take(model.PageSize).ToList();

				model.TotalRecords = (from c in db.tblGalleryImages select c).Count();
			}

			return View(model);
		}
        public ActionResult Index()
        {
                var _pagedData = new PagedData<tblQuestion>();

                List<mstSection> sectionList = SectionManagement.getSections();                 
                ViewBag.sectionList = sectionList;
                ViewBag.subSectionList = SectionManagement.getSubsections(1);
            
                using(SVDB_Entities db = new SVDB_Entities())
                {
                    _pagedData.Data = db.tblQuestions.OrderBy(x => x.questionId).Take(PageSize).ToList();
                    _pagedData.NumberOfPages = Convert.ToInt32(Math.Ceiling((double)db.tblQuestions.Count() / PageSize));
                    ViewBag._pagedData = _pagedData;  
                }           
                return View();
        }
		public ActionResult Index(PagedData<tblGalleryImage> model) {
			model.ToggleSort();
			var srt = model.ParseSort();

			using (PhotoGalleryDataContext db = PhotoGalleryDataContext.GetDataContext()) {
				IQueryable<tblGalleryImage> query = (from c in db.tblGalleryImages select c);

				query = query.SortByParm<tblGalleryImage>(srt.SortField, srt.SortDirection);

				model.DataSource = query.Skip(model.PageSize * (model.PageNumber - 1)).Take(model.PageSize).ToList();

				model.TotalRecords = (from c in db.tblGalleryImages select c).Count();
			}

			ModelState.Clear();

			return View(model);
		}
		public ActionResult Index(PagedData<GalleryGroup> model) {
			GalleryHelper gh = new GalleryHelper(this.SiteID);

			model.ToggleSort();
			var srt = model.ParseSort();

			List<GalleryGroup> lst = gh.GalleryGroupListGetBySiteID();

			IQueryable<GalleryGroup> query = lst.AsQueryable();
			query = query.SortByParm<GalleryGroup>(srt.SortField, srt.SortDirection);

			model.DataSource = query.Skip(model.PageSize * model.PageNumberZeroIndex).Take(model.PageSize).ToList();

			model.TotalRecords = lst.Count();

			ModelState.Clear();

			return View(model);
		}
Beispiel #18
0
        public ActionResult constructDataPromotionLifeStyle()
        {
            string _penawaran = Request.QueryString[Sitecore.Feature.Library.Helper.Variables._penawaran] != null ? Request.QueryString[Sitecore.Feature.Library.Helper.Variables._penawaran].ToLower() : string.Empty;
            string _category  = Request.QueryString[Sitecore.Feature.Library.Helper.Variables._category] != null ? Request.QueryString[Sitecore.Feature.Library.Helper.Variables._category].ToLower() : string.Empty;
            string _keyword   = Request.QueryString[Sitecore.Feature.Library.Helper.Variables._keyword] != null ? Request.QueryString[Sitecore.Feature.Library.Helper.Variables._keyword].ToLower() : string.Empty;

            Guid idPenawaran = new Guid();

            //bool _penawaranValid = Guid.TryParse(_penawaran, out idPenawaran);
            _penawaran = Guid.TryParse(_penawaran, out idPenawaran) == true ? _penawaran : string.Empty;

            Guid idCategory = new Guid();

            //bool _categoryValid = Guid.TryParse(_category, out idCategory);
            _category = Guid.TryParse(_category, out idCategory) == true ? _category : string.Empty;

            var PageSize = RenderingContext.Current.Rendering.GetIntegerParameter("Max Item", 8);


            //GetDataFrom Promotion Repository
            Sitecore.Data.Items.Item      dataSourceItem = RenderingContext.Current.Rendering.Item;
            IEnumerable <Data.Items.Item> items          = this.Repository.Get(Sitecore.Context.Database.GetItem(new Data.ID("{18DC3A7D-0FEF-44E0-B947-98CA942846E9}")));

            items = filterItem360(items, _penawaran, _category, _keyword, dataSourceItem);

            PagedData <Data.Items.Item> listItems = new PagedData <Data.Items.Item>();

            if (items != null && items.Count() > 0)
            {
                listItems.Data          = items.Take(PageSize);
                listItems.NumberOfPages = Convert.ToInt32(Math.Ceiling((double)items.Count() / PageSize));
                listItems.CurrentPage   = 1;
                listItems.PageSize      = PageSize;
            }
            listItems.DataSourceID = RenderingContext.Current.Rendering.Item.ID;

            return(View("Lifestyle", listItems));
        }
Beispiel #19
0
        //var q = this.DbContext.Query<WikiDocument>().FilterDeleted().WhereIfNotNullOrEmpty(keyword, a => a.Title.Contains(keyword) || a.Tag.Contains(keyword));
        /// <summary>
        /// 获取分页数据
        /// </summary>
        /// <param name="page">分页信息</param>
        /// <param name="keyword">关键词</param>
        /// <returns>返回分页数据</returns>
        public PagedData <role> GetPageData(ACEPagination page, string keyword)
        {
            //查询相关的字段,根据页面的指定的字段
            PagedData <role> pageData = new PagedData <role>();

            pageData = TakePageData(page);
            try
            {
                if (string.IsNullOrEmpty(keyword))
                {
                    pageData = TakePageData(page);
                }
                else
                {
                    pageData.DataList = pageData.DataList.Where(a => a.rolename.Contains(keyword)).ToList <role>();
                }
                return(pageData);
            }
            catch (Exception)
            {
                return(null);
            }
        }
        public UnitConsumptionGraph <DateTime> GetHistoryGraph(UnitConsumptionHistoryInput input)
        {
            PagedData <UnitConsumptionHistoryInput> inp = new PagedData <UnitConsumptionHistoryInput>();

            inp.NumberOfRecords = -1;
            inp.Data            = input;
            var fullData = this.GetHistoryforUnit(inp);
            var first    = fullData.Data.Select(us => new point <DateTime>()
            {
                X = us.date, Y = Convert.ToDecimal(us.consumptioninmcube)
            });
            var second = fullData.Data.Select(us => new point <DateTime>()
            {
                X = us.date, Y = Convert.ToDecimal(us.PulseCount)
            });
            var result = new UnitConsumptionGraph <DateTime>();

            result.Cumalative          = new Graph <DateTime>();
            result.DayConsumption      = new Graph <DateTime>();
            result.Cumalative.Data     = first.ToList();
            result.DayConsumption.Data = second.ToList();
            return(result);
        }
        public ActionResult Index(PagedData <carrot_FaqCategory> model)
        {
            model.ToggleSort();
            var srt = model.ParseSort();

            List <carrot_FaqCategory> lst = null;

            using (FaqHelper fh = new FaqHelper(this.SiteID)) {
                lst = fh.CategoryListGetBySiteID();
            }

            IQueryable <carrot_FaqCategory> query = lst.AsQueryable();

            query = query.SortByParm <carrot_FaqCategory>(srt.SortField, srt.SortDirection);

            model.DataSource = query.Skip(model.PageSize * model.PageNumberZeroIndex).Take(model.PageSize).ToList();

            model.TotalRecords = lst.Count();

            ModelState.Clear();

            return(View(model));
        }
Beispiel #22
0
        public ActionResult CorporateLatestNews()
        {
            string             _category = Request.QueryString[Sitecore.Feature.Library.Helper.Variables._categoryId] != null ? Request.QueryString[Sitecore.Feature.Library.Helper.Variables._categoryId].ToLower() : string.Empty;
            var                PageSize  = RenderingContext.Current.Rendering.GetIntegerParameter("Max Item", 4);
            IEnumerable <Item> items     = this.Repository.Get(RenderingContext.Current.Rendering.Item);
            var                listItems = new PagedData <Data.Items.Item>();

            if (_category != string.Empty)
            {
                items = this.Repository.getNewsItemByCategory(items, _category);
            }

            items = items == null ? new List <Item>() : items;
            if (items != null)
            {
                listItems.Data          = items.Take(PageSize);
                listItems.NumberOfPages = Convert.ToInt32(Math.Ceiling((double)items.Count() / PageSize));
                listItems.CurrentPage   = 1;
                listItems.PageSize      = PageSize;
                listItems.DataSourceID  = RenderingContext.Current.Rendering.Item.ID;
            }
            return(this.View("LatestNewsCorporate", listItems));
        }
Beispiel #23
0
        /// <summary>
        /// 分页查询 自己拼sql
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="sql">查询语句</param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public async Task <PagedData <T> > PagedFindAllAsync <T>(string queryStr, string columStr, int pageIndex, int pageSize, object param = null, string orderbyStr = "")
        {
            using (var db = CreateDbBase())
            {
                pageIndex = (pageIndex <= 0 ? 0 : pageIndex - 1) * pageSize;
                StringBuilder querySql = new StringBuilder();
                querySql.Append($"SELECT {columStr} FROM {queryStr} ");
                if (!string.IsNullOrEmpty(orderbyStr))
                {
                    querySql.Append($" ORDER BY {orderbyStr} ");
                }
                querySql.Append($" LIMIT {pageIndex},{pageSize};");

                var countSql = $"SELECT COUNT(1) as count FROM {queryStr}";

                var totalCount = await db.QueryFirstAsync <long>(countSql, param);

                var list = await db.QueryAsync <T>(querySql.ToString(), param);

                PagedData <T> result = new PagedData <T>(totalCount, pageSize, list);
                return(result);
            }
        }
        public async Task <PagedData <LogEntry> > GetByDeviceAsync(long hardwareDeviceId, PageCriteria criteria)
        {
            PagedData <LogEntry> returnValue = new PagedData <LogEntry>()
            {
                Criteria = criteria
            };
            IQueryable <LogEntry> query = EntityDbSet;

            query = query.Where(l => l.HardwareDeviceId == hardwareDeviceId);
            query = SortData(query, new SortCriteria()
            {
                Order    = SortCriteria.SortOrder.Descending,
                Property = RecordedOnProperty
            });

            var result = PageData(query, criteria);

            returnValue.NumberOfRecords = result.numberOfRecords;
            returnValue.NumberOfPages   = result.numberOfPages;
            returnValue.RecordsInPage   = await result.query.ToListAsync();

            return(returnValue);
        }
Beispiel #25
0
        //获取树形分页数据
        public PagedData <DataTableTree> GetTreePageData(ACEPagination page, string keyword)
        {
            //查询相关的字段,根据页面的指定的字段
            List <DataTableTree>      listtree = new List <DataTableTree>();
            PagedData <DataTableTree> pageData = new PagedData <DataTableTree>(listtree, 100, 1, 20);
            List <resource>           res      = new List <resource>();
            List <resource>           resall   = new List <resource>();

            res = this.getPageGroup(page.Page, page.PageSize);  //获取当前页资源数据
            //pageData = TakePageData(page);
            try
            {
                if (string.IsNullOrEmpty(keyword))
                {
                    resall = this.getEntityList();//获取的资源总条数
                    DataTableTree.AppendChildren(res, ref listtree, null, 0, a => a.id.ToString(), a => a.resourceowner);
                    pageData = new PagedData <DataTableTree>(listtree, resall.Count, page.Page, page.PageSize);
                }
                else
                {
                    resall = this.getEntityList().Where(a => a.resourcename.Contains(keyword)).ToList <resource>();//获取的资源总条数
                    DataTableTree.AppendChildren(resall, ref listtree, null, 0, a => a.id.ToString(), a => a.resourceowner);
                    pageData = new PagedData <DataTableTree>(listtree, resall.Count, page.Page, page.PageSize);
                }
                // pageData.DataList = listtree;
                // pageData.TotalCount = resall. Count; ////总数据条数


                //pageData.DataList = pageData.DataList.Where(a => a.resourcename.Contains(keyword)).ToList<resource>();
                return(pageData);
            }
            catch (Exception)
            {
                return(null);
            }
            //return pageData;
        }
Beispiel #26
0
        /*
         * public static User getUser(HttpContext context, CookDBDataContext db)
         * {
         *  return db.Users.SingleOrDefault(a => a.username.Equals(context.Request.ServerVariables["AUTH_USER"]));
         * }
         */

        public void ProcessRequest(HttpContext context)
        {
            bool debug = false;

            if (context.Request.Url.AbsolutePath.Contains("CookbookDEV") || !isNull(context.Request.Params.Get("CookbookDEV")))
            {
                debug = false; // change back if you need...
            }
            CookDBDataContext db  = getDataContext(context);
            PagedData         ret = null;

            context.Response.ContentType = "text/html";

            //User u = getUser(context, db);

            string msg = "Unknown failure";

            try {
                int start = intParse(context.Request.Params.Get("start"));
                int limit = intParse(context.Request.Params.Get("limit"));
                ret = ProcessRequest(context, db, start, limit);
            }
            catch (Exception e) {
                msg = e.Message;
                if (debug)
                {
                    throw new Exception("Error", e);
                }
            }
            if (ret == null)
            {
                ret = new PagedData(msg, false);
            }

            context.Response.Write(JsonConvert.SerializeObject(ret,
                                                               new JsonConverter[] { new JavaScriptDateTimeConverter() }));
        }
Beispiel #27
0
        public ActionResult ToPaiBanByShopTempletIndex(QueryInfo queryInfo, DateTime?startDate, DateTime?endDate, FormCollection form, string subAction)
        {
            //取出排班店铺表
            DateTime localStartDate;
            DateTime localEndDate;

            if (startDate == null)
            {
                localStartDate = System.DateTime.Now.Date;
            }
            else
            {
                localStartDate = Convert.ToDateTime(startDate);
            }
            if (endDate == null)
            {
                localEndDate = localStartDate.AddDays(10);
            }
            else
            {
                localEndDate = Convert.ToDateTime(endDate);
            }
            ViewData["startDate"] = localStartDate;
            ViewData["endDate"]   = localEndDate;

            //List<User> listAllUser = this.userRepository.GetData(this.Users().DepartMent.ID, Convert.ToInt32(UserEnmType.Person)).ToList();
            //this.ViewData["listAllUser"] = listAllUser;

            if (localStartDate < System.DateTime.Now.Date)
            {
                ViewBag.message = "手工排班不能排当天之前的班次,请选择当天以及之后的开始日期!";
                goto Last;
            }

            Last : PagedData <PBDateTemplet> data = this.pbDateTempletRepo.GetData(queryInfo, localStartDate, localEndDate, this.Users().DepartMent);
            return(View(data));
        }
Beispiel #28
0
        public PagedData <SysUser> GetPageData(Pagination page, string keyword)
        {
            var q = this.DbContext.Query <SysUser>();

            q = q.WhereIfNotNullOrEmpty(keyword, a => a.AccountName.Contains(keyword) || a.Name.Contains(keyword) || a.MobilePhone.Contains(keyword));
            q = q.Where(a => a.AccountName != AppConsts.AdminUserName);
            q = q.OrderByDesc(a => a.CreationTime);

            PagedData <SysUser> pagedData = q.TakePageData(page);

            List <string> userIds = pagedData.Models.Select(a => a.Id).ToList();
            List <string> postIds = pagedData.Models.SelectMany(a => a.PostIds.SplitString()).Distinct().ToList();
            List <string> roleIds = pagedData.Models.SelectMany(a => a.RoleIds.SplitString()).Distinct().ToList();

            List <SysPost> posts = this.DbContext.Query <SysPost>().Where(a => a.Id.In(postIds)).ToList();
            List <SysRole> roles = this.DbContext.Query <SysRole>().Where(a => a.Id.In(roleIds)).ToList();

            List <SysUserOrg> userOrgs = this.DbContext.Query <SysUserOrg>().InnerJoin <SysOrg>((a, b) => a.OrgId == b.Id)
                                         .Where((a, b) => userIds.Contains(a.UserId))
                                         .Select((a, b) => new SysUserOrg()
            {
                Id = a.Id, UserId = a.UserId, OrgId = a.OrgId, DisablePermission = a.DisablePermission, Org = b
            }).ToList();

            foreach (SysUser user in pagedData.Models)
            {
                user.UserOrgs.AddRange(userOrgs.Where(a => a.UserId == user.Id));

                List <string> userPostIds = user.PostIds.SplitString();
                user.Posts.AddRange(posts.Where(a => a.Id.In(userPostIds)));

                List <string> userRoleIds = user.RoleIds.SplitString();
                user.Roles.AddRange(roles.Where(a => a.Id.In(userRoleIds)));
            }

            return(pagedData);
        }
        //public async Task<List<AbilityRole>> GetAllAsync()
        //{
        //    return (await QueryAsync(q => q.QueryAsync<AbilityRole>("", new {}))).ToList();
        //}

        public PagedData <AbilityRole> GetPagedData(Dictionary <string, object> filters, string orderBy, int page, int pageSize)
        {
            // Create the list to return
            var returnValue = new PagedData <AbilityRole>();

            // Initialise templates
            SqlBuilder.Template selectTemplate;
            SqlBuilder.Template countTemplate;
            string timeElapsed;
            // Set the queries that we need to use
            var select = MySQL.AbilityRole.PagedQuery.SelectAllFrom(AliasTs.AbilityRole.Name, AliasTs.AbilityRole.Alias);
            var count  = MySQL.AbilityRole.PagedQuery.CountAllFrom(AliasTs.AbilityRole.Name, AliasTs.AbilityRole.Alias);

            // Create the builder itself
            SqlBuilderRepository.CreateBuilder(filters, orderBy, page, pageSize, select, count, out selectTemplate, out countTemplate);

            // Count the number of records that were found
            var total = Query(s => s.Query <long>(countTemplate.RawSql, countTemplate.Parameters).Single(), out timeElapsed);

            // Mysql counts with bigint (long) so convert it to a 32-bit integer here
            returnValue.TotalRecords = Convert.ToInt32(total);
            // Get the page of data to send back to the controller
            returnValue.Data = Query(q => q.Query <AbilityRole, RoleIcon, PlayerClass, AbilityRole>
                                         (selectTemplate.RawSql, (ar, ri, pc) =>
            {
                ar.Role  = ri;
                ar.Class = pc;
                return(ar);
            }, selectTemplate.Parameters), out timeElapsed);

            // Uncomment this if we really want to see how long it's taking, but by default, don't.
            //_logger.Debug(string.Format("GetSecuredPagedData: {0} records returned in {1}", returnValue.Data.Count(), timeElapsed));

            // Done!
            return(returnValue);
        }
Beispiel #30
0
 void LoadOrUnloadData(PagedData data, int index, bool toLoad)
 {
     if (toLoad)
     {
         string     fileName = data.getFullFileName(index);
         GameObject fineNode = LoadSceneFromFile(fileName);
         if (fineNode != null)
         {
             fineNode.transform.SetParent(this.transform, false);
             data._pagedNodes[index] = fineNode;
             data._pagedNodes[0].SetActive(false);  // FIXME: assume only 1 rough level
         }
         else
         {
             Debug.LogWarning("Unable to read OSGB data from " + fileName);
         }
     }
     else
     {
         Destroy(data._pagedNodes[index]);
         data._pagedNodes[index] = null;
         data._pagedNodes[0].SetActive(true);  // FIXME: assume only 1 rough level
     }
 }
        public IEnumerable <Article> Get([FromQuery] ArticleFilterData filterData, [FromQuery] bool?sortByViews, [FromQuery] int?pageNumber, [FromQuery] int?pageSize)
        {
            var raw      = _articleService.GetAll(filterData.PubDate, filterData.CategoryID, filterData.Views);
            var filtered = raw;

            if (sortByViews.HasValue)
            {
                filtered = filtered.OrderBy(a => a.Views);
            }


            PagedData <Article> page;

            if (pageNumber.HasValue && pageSize.HasValue)
            {
                page = new PagedData <Article>(filtered, pageSize.Value, pageNumber.Value);
            }
            else
            {
                page = new PagedData <Article>(filtered, 10, 0);
            }

            return(page.Current);
        }
Beispiel #32
0
        protected async Task <PagedData <DestModel> > CreateFilterableAndSortableQuery <TEntity, DestModel>(IQueryable <TEntity> query, QueryInfo searchRequestInfo, bool hasCustomSort = false) where TEntity : class
        {
            if (searchRequestInfo == null)
            {
                searchRequestInfo = new QueryInfo();
            }

            var pagedData = new PagedData <DestModel>();

            pagedData.Count = await query.CountAsync();

            Expression <Func <TEntity, bool> > searchExpression = null;

            if (searchRequestInfo.Filter != null && searchRequestInfo.Filter.Filters != null && searchRequestInfo.Filter.Filters.Length > 0)
            {
                searchExpression = CreateSearchExpression <TEntity>(searchRequestInfo.Filter);
                query            = query.AsExpandable().Where(searchExpression);
            }

            if (!hasCustomSort)
            {
                if (searchRequestInfo.Sort != null && searchRequestInfo.Sort.Length > 0)
                {
                    query = CreateOrderedQuery(query, searchRequestInfo.Sort);
                }
            }

            if (searchRequestInfo.PageSize > 0)
            {
                query = query.Skip(searchRequestInfo.Skip).Take(searchRequestInfo.PageSize);
            }
            var result = await query.ToListAsync();

            pagedData.DataSource = result.Select(a => Mapper.Map <DestModel>(a)).ToList();
            return(pagedData);
        }
        /// <summary>
        /// Finds the feed types that match the filter condition sorted as specified.
        /// </summary>
        /// <typeparam name="TSortProperty">The type of the property on the object that is the sort key.</typeparam>
        /// <param name="filter">The condition that filters the feed types that need to be included.</param>
        /// <param name="sort">The condition that defines the sorting property.</param>
        /// <param name="sortDirection">Should the list be sorted ascending or descending.</param>
        /// <param name="pagingOptions">The options for pagination.</param>
        /// <param name="cancellationToken">A token that can be used to signal operation cancellation.</param>
        /// <returns>The sorted list of feed types that match the filter.</returns>
        public virtual async Task <IPagedData <IFeedType> > FindAsync <TSortProperty>(Expression <Func <IFeedType, bool> > filter,
                                                                                      Expression <Func <IFeedType, TSortProperty> > sort,
                                                                                      ListSortDirection sortDirection,
                                                                                      IPagingOptions pagingOptions,
                                                                                      CancellationToken cancellationToken)
            where TSortProperty : IComparable
        {
            Logger.LogInformation($"Finding {pagingOptions.PageSize} feed types for page {pagingOptions.PageNumber}...");
            var data = await LivestockContext.FeedTypes
                       .ConstrainedFind(filter, sort, sortDirection, pagingOptions)
                       .Select(feedType => Mapper.Map(feedType))
                       .ToListAsync(cancellationToken)
                       .ConfigureAwait(false);

            var totalRecordCount = await LivestockContext.FeedTypes
                                   .Where(filter)
                                   .CountAsync(cancellationToken)
                                   .ConfigureAwait(false);

            var paginatedResults = new PagedData <FeedType>(data, pagingOptions.PageSize, pagingOptions.PageNumber, totalRecordCount);

            Logger.LogDebug($"Found paged feed types: {paginatedResults}");
            return(paginatedResults);
        }
        public async Task NotFoundAppTypeInfoSecondPass_RunAsync_LogsFailure()
        {
            _item.MaxApplicationReadyWaitTime = 5;
            _command.AvailableCheckDelay      = 5000;
            var appTypeInfoList1 = new PagedData <ApplicationTypeInfo>(ContinuationToken.Empty, new[]
            {
                new ApplicationTypeInfo("app", "1.0.0", null, ApplicationTypeStatus.Provisioning)
            });
            var appTypeInfoList2 = new PagedData <ApplicationTypeInfo>(
                ContinuationToken.Empty, new ApplicationTypeInfo[0]);

            _appTypeClient
            .SetupSequence(c => c.GetApplicationTypeInfoListByNameAsync(
                               _item.ApplicationTypeName, null, false, null, 0, 60, CancellationToken.None))
            .Returns(Task.FromResult(appTypeInfoList1))
            .Returns(Task.FromResult(appTypeInfoList2));

            await _command.RunAsync();

            ShouldContainsLogMessage(
                $"Failed to create application type {_item.ApplicationTypeName}: " +
                $"The application type {_item.ApplicationTypeName} failed to be available " +
                $"within {_item.MaxApplicationReadyWaitTime} seconds");
        }
        private PagedData <Employee> GetEmpData(PagedData <Employee> model)
        {
            List <Employee> lst = new List <Employee>();

            model.PageSize = 5;

            model.ToggleSort();
            var srt = model.ParseSort();

            model.DataSource = new List <Employee>();
            IQueryable <Employee> query = (from c in db.Employees select c);

            query = query.SortByParm <Employee>(srt.SortField, srt.SortDirection);

            model.DataSource = query.Skip(model.PageSize * (model.PageNumber - 1)).Take(model.PageSize).ToList();

            model.TotalRecords = (from c in db.Employees select c).Count();

            ViewBag.TerritoryList = db.Territories.ToList();

            model.SortByNew = String.Empty;

            return(model);
        }
        public PagedData <Pro_CollectionInfo> GetPageData(Pagination page, string UserID)
        {
            //var q = this.DbContext.Query<Pro_Collection>();
            //q = q.WhereIfNotNullOrEmpty(UserID, a => a.UserID.Contains(UserID));
            //PagedData<Pro_Collection> pagedData = q.TakePageData(page);
            //return pagedData;
            var q = this.DbContext.Query <Pro_Collection>()
                    .LeftJoin <Product>((col, product) => col.ProductID == product.Id);

            IQuery <Pro_CollectionInfo> db_set = q.Select <Pro_CollectionInfo>((col, product) => new Pro_CollectionInfo
            {
                Id          = col.Id,
                ProductID   = col.ProductID,
                ProductName = product.ProductName,
                ProductCode = product.ProductCode,
                Price       = product.Price,
                ImageUrl    = product.ImageUrl,
                CreateDate  = col.CreateDate,
                UserID      = col.UserID
            }).Where(a => a.UserID == UserID);
            PagedData <Pro_CollectionInfo> pagedData = db_set.TakePageData(page);

            return(pagedData);
        }
		public ActionResult SiteSkinIndex() {
			PagedData<CMSTemplate> model = new PagedData<CMSTemplate>();
			model.PageSize = 1000;
			model.InitOrderBy(x => x.Caption);

			return SiteSkinIndex(model);
		}
		public ActionResult PageTemplateUpdate() {
			CMSConfigHelper.CleanUpSerialData();
			PageTemplateUpdateModel model = new PageTemplateUpdateModel();
			model.SelectedSearch = PageTemplateUpdateModel.SearchBy.Filtered;

			PagedData<ContentPage> pagedData = new PagedData<ContentPage>();
			pagedData.PageSize = 10;
			pagedData.InitOrderBy(x => x.NavMenuText);
			model.Page = pagedData;

			return PageTemplateUpdate(model);
		}
		public ActionResult ContentEditHistory() {
			ContentHistoryModel model = new ContentHistoryModel();
			PagedData<EditHistory> history = new PagedData<EditHistory>();
			history.PageSize = 25;
			history.InitOrderBy(x => x.EditDate, false);
			model.Page = history;

			return ContentEditHistory(model);
		}
Beispiel #40
0
        public PagedResponse <BillGroup> GetBillGroupMaster(PagedData <BusinessModels.Billing.BGInput> input)
        {
            var result = Repository.GetBillGroupMaster(Mapper.Map <DataModels.PagedData <DataModels.Billing.BGInput> >(input));

            return(Mapper.Map <PagedResponse <BusinessModels.Billing.BillGroup> >(result));
        }
Beispiel #41
0
        public PagedResponse <BillDetail> GetBillsforPrint(PagedData <BillGenerateInput> pagedInput)
        {
            var result = Repository.GetBillsforPrint(Mapper.Map <DataModels.PagedData <DataModels.Billing.BillGenerateInput> >(pagedInput));

            return(Mapper.Map <PagedResponse <BusinessModels.Billing.BillDetail> >(result));
        }
		public ActionResult BlogPostTemplateUpdate() {
			CMSConfigHelper.CleanUpSerialData();
			PostTemplateUpdateModel model = new PostTemplateUpdateModel();
			model.SelectedSearch = PostTemplateUpdateModel.SearchBy.Filtered;

			PagedData<ContentPage> pagedData = new PagedData<ContentPage>();
			pagedData.PageSize = 10;
			pagedData.InitOrderBy(x => x.GoLiveDate, false);
			model.Page = pagedData;

			return BlogPostTemplateUpdate(model);
		}
        public ActionResult Index(string word, int?section, int?page)
        {
            var rd = new RouteValueDictionary();

            rd.Add("word", word ?? "");
            rd.Add("section", section ?? 0);
            var category = new StoreCategory()
            {
                LastMod = DateTime.Now, ShowBigIcons = false
            };
            var searcher = new Searcher(word ?? "", section ?? 0);



            var item = searcher.FullTextSearchQuery;

            switch (category.CatalogFilter.ProductOrder)
            {
            default:
                if (category.CatalogFilter.ProductOrder.StartsWith("Char_"))
                {
                    int cid = category.CatalogFilter.ProductOrder.Replace("Char_", "").ToInt();
                    item =
                        item.OrderBy(
                            x =>
                            (x.StoreCharacterToProducts.FirstOrDefault(
                                 z => z.StoreCharacterValue.CharacterID == cid) ??
                             new StoreCharacterToProduct()
                    {
                        StoreCharacterValue = new StoreCharacterValue()
                        {
                            Value = "ZZZZZZZZZZ"
                        }
                    })
                            .StoreCharacterValue.Value.Length).ThenBy(
                            x =>
                            (x.StoreCharacterToProducts.FirstOrDefault(
                                 z => z.StoreCharacterValue.CharacterID == cid) ??
                             new StoreCharacterToProduct()
                    {
                        StoreCharacterValue =
                            new StoreCharacterValue()
                        {
                            Value = "ZZZZZZZZZZ"
                        }
                    })
                            .StoreCharacterValue.Value);
                }
                break;

            case "OrderNum":
                item = item.OrderBy(x => x.StoreProductsToCategories.Any() ? x.StoreProductsToCategories.First().OrderNum : 100000);
                break;

            case "AlphaBet":
                item = item.OrderByDescending(x => x.ViewCount).ThenBy(x => x.Name);
                break;

            case "AlphaBetDesc":
                item = item.OrderBy(x => x.ViewCount).ThenByDescending(x => x.Name);
                break;

            case "Cheap":
                item = item.OrderBy(x => x.SitePrice);
                break;

            case "CheapDesc":
                item = item.OrderByDescending(x => x.SitePrice);
                break;

            case "Expensive":
                item =
                    item.OrderByDescending(x => x.Price);
                break;

            case "AddDate":
                item =
                    item.OrderByDescending(x => x.AddDate);
                break;

            case "VoteOverage":
                item =
                    item.OrderByDescending(x => x.VoteOverage);
                break;
            }

            if ((word ?? "").Length <= 2)
            {
                item = new List <StoreProduct>().AsQueryable();
            }


            var paged = new PagedData <StoreProduct>(item,
                                                     CatalogBrowser.PageNumber,
                                                     category.CatalogFilter.ProductCount, rd);

            category.ProductList = paged;
            return
                (PartialView(category));
        }
		public ActionResult RoleIndex(PagedData<UserRole> model) {
			model.ToggleSort();

			var srt = model.ParseSort();
			var query = ReflectionUtilities.SortByParm<UserRole>(SecurityData.GetRoleList(), srt.SortField, srt.SortDirection);

			model.TotalRecords = -1;
			model.DataSource = query.ToList();

			ModelState.Clear();

			return View(model);
		}
        //[Audit]
        public async Task <ActionResult <PagedData <AudioBookModel> > > Gets(int categoryId, int page = 1)
        {
            var result = new PagedData <AudioBookModel>(new List <AudioBookModel>(), 0);

            return(this.Ok(result));
        }
Beispiel #46
0
 public LearnWordViewModel()
 {
     Comments = new PagedData <WordComment>();
     Word     = new Word();
 }
Beispiel #47
0
        /*     [MenuItem("Структура сайта", -100, Icon = "home")]
         */
        public ActionResult Index(int?Page)
        {
            var pagedList = new PagedData <CMSPage>(db.CMSPages.OrderBy(x => x.OrderNum), Page ?? 0, 20, "MasterListPaged");

            return(View(pagedList));
        }
		public ActionResult ContentSnippetIndex() {
			PagedData<ContentSnippet> model = new PagedData<ContentSnippet>();
			model.PageSize = -1;
			model.InitOrderBy(x => x.ContentSnippetName);

			var srt = model.ParseSort();
			var query = ReflectionUtilities.SortByParm<ContentSnippet>(SiteData.CurrentSite.GetContentSnippetList(), srt.SortField, srt.SortDirection);

			model.TotalRecords = -1;
			model.DataSource = query.ToList();

			return View(model);
		}
        // GET: Employees
        public ActionResult Index(string search = "", int size = 20, int page = 0)
        {
            try
            {
                PagedData <EmployeeManager.Models.Employee> employees = null;

                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(m_ApiUrl + "/api/");

                    //Called Member default GET All records
                    //GetAsync to send a GET request
                    // PutAsync to send a PUT request

                    string l_qs = string.Empty;

                    if (!string.IsNullOrEmpty(search))
                    {
                        l_qs += (string.IsNullOrEmpty(l_qs) ? "?" : "&") + "search=" + search;
                    }

                    if (size != 20)
                    {
                        l_qs += (string.IsNullOrEmpty(l_qs) ? "?" : "&") + "size=" + size;
                    }

                    if (page != 0)
                    {
                        l_qs += (string.IsNullOrEmpty(l_qs) ? "?" : "&") + "page=" + page;
                    }

                    var responseTask = client.GetAsync("Employee/Paged" + l_qs);
                    responseTask.Wait();

                    //To store result of web api response.
                    var result = responseTask.Result;

                    //If success received
                    if (result.IsSuccessStatusCode)
                    {
                        var readTask = result.Content.ReadAsAsync <PagedData <Employee> >();
                        readTask.Wait();

                        employees = readTask.Result;
                    }
                    else
                    {
                        //Error response received
                        employees = new PagedData <Employee>();
                        ModelState.AddModelError(string.Empty, "Server error try after some time.");

                        LayoutMessageHelper.SetMessage("Error trying to get employees. Try again later.", LayoutMessageType.Alert);
                    }
                }

                return(View(employees));
            }
            catch (Exception Error)
            {
                LayoutMessageHelper.SetMessage(Error.Message, LayoutMessageType.Error);

                return(View());
            }
        }
Beispiel #50
0
        public ActionResult Models(Pagination pagination, string keyword)
        {
            PagedData <SysUser> pagedData = this.Service.GetPageData(pagination, keyword);

            return(this.SuccessData(pagedData));
        }
		public ActionResult SiteSkinIndex(PagedData<CMSTemplate> model) {
			model.ToggleSort();
			var templates = cmsHelper.Templates.Where(x => x.TemplatePath.ToLowerInvariant() != SiteData.DefaultTemplateFilename.ToLowerInvariant()).ToList();
			var srt = model.ParseSort();

			var query = ReflectionUtilities.SortByParm<CMSTemplate>(templates, srt.SortField, srt.SortDirection);

			model.TotalRecords = -1;
			model.DataSource = query.ToList();

			ModelState.Clear();

			return View(model);
		}
        //[Audit]
        public async Task <ActionResult <PagedData <AudioBookModel> > > Gets([FromQuery] GetAllAudioBookFilter filter)
        {
            var result = new PagedData <AudioBookModel>(new List <AudioBookModel>(), 0);

            return(this.Ok(result));
        }
		public ActionResult BlogPostIndex() {
			CMSConfigHelper.CleanUpSerialData();
			PostIndexModel model = new PostIndexModel();
			model.SelectedSearch = PageIndexModel.SearchBy.AllPages;

			PagedData<ContentPage> pagedData = new PagedData<ContentPage>();
			pagedData.PageSize = 10;
			pagedData.InitOrderBy(x => x.GoLiveDate, false);
			model.Page = pagedData;

			return BlogPostIndex(model);
		}
Beispiel #54
0
        //public BillGroupResult Validate(BillGenerateInput input)
        //{
        //    var result = Repository.Validate(Mapper.Map<DataModels.Billing.BillGenerateInput>(input));
        //    return Mapper.Map<BusinessModels.Billing.BillGroupResult>(result);
        //}
        public PagedResponse <BillGroupDetailVM> GetBillGroupDetails(PagedData <BillGenerateInput> input)
        {
            var result = Repository.GetBillGroupDetails(Mapper.Map <DataModels.PagedData <DataModels.Billing.BillGenerateInput> >(input));

            return(Mapper.Map <PagedResponse <BusinessModels.Billing.BillGroupDetailVM> >(result));
        }
		public ActionResult UserIndex(PagedData<ExtendedUserData> model) {
			model.ToggleSort();

			var srt = model.ParseSort();
			var query = ReflectionUtilities.SortByParm<ExtendedUserData>(ExtendedUserData.GetUserList(), srt.SortField, srt.SortDirection);

			model.TotalRecords = -1;
			model.DataSource = query.ToList();

			ModelState.Clear();

			return View(model);
		}
        //public const int PageSize = 10;

        //[OutputCache(NoStore = true, Duration = 0)]
        //public BinaryResult _GetClip(int? id)
        //{
        //    //if (String.IsNullOrEmpty(Request.UrlReferrer.AbsoluteUri))

        //    //    return RedirectToAction("Index", "Home");

        //    Dictionary<string, object> collection = new Dictionary<string, object>();

        //    ErrorCodes errorCode = ErrorCodes.UnknownError;

        //    string errorMessage = MyUtility.getErrorMessage(ErrorCodes.UnknownError);

        //    collection = MyUtility.setError(errorCode, errorMessage);

        //    var context = new IPTV2Entities();

        //    Episode ep = context.Episodes.FirstOrDefault(e => e.EpisodeId == id && e.OnlineStatusId == GlobalConfig.Visible);

        //    if (ep != null)
        //    {
        //        Asset asset = ep.PremiumAssets.FirstOrDefault().Asset;

        //        if (asset != null)
        //        {
        //            int assetId = asset == null ? 0 : asset.AssetId;

        //            ViewBag.AssetId = assetId;

        //            var clipDetails = Helpers.Akamai.GetAkamaiClipDetails(ep.EpisodeId, assetId, Request, User);

        //            if (!String.IsNullOrEmpty(clipDetails.Url))
        //            {
        //                errorCode = ErrorCodes.Success;

        //                collection = MyUtility.setError(errorCode, clipDetails.Url);

        //                collection.Add("data", clipDetails);
        //            }

        //            else
        //            {
        //                errorCode = ErrorCodes.AkamaiCdnNotFound;

        //                collection = MyUtility.setError(errorCode, "Akamai Url not found.");
        //            }
        //        }

        //        else
        //        {
        //            errorCode = ErrorCodes.VideoNotFound;

        //            collection = MyUtility.setError(errorCode, "Video not found.");
        //        }
        //    }

        //    else
        //    {
        //        errorCode = ErrorCodes.EpisodeNotFound;

        //        collection = MyUtility.setError(errorCode, "Episode not found.");
        //    }

        //    byte[] jsonToBytes = System.Text.ASCIIEncoding.ASCII.GetBytes(MyUtility.buildJson(collection));

        //    return new BinaryResult()

        //    {
        //        ContentType = "application/octet-stream",

        //        IsAttachment = false,

        //        Data = jsonToBytes
        //    };
        //}

        //[OutputCache(NoStore = true, Duration = 0)]

        //public string _GetClip2(int? id)

        //{
        //    //if (String.IsNullOrEmpty(Request.UrlReferrer.AbsoluteUri))

        //    //    return RedirectToAction("Index", "Home");

        //    Dictionary<string, object> collection = new Dictionary<string, object>();

        //    ErrorCodes errorCode = ErrorCodes.UnknownError;

        //    string errorMessage = MyUtility.getErrorMessage(ErrorCodes.UnknownError);

        //    collection = MyUtility.setError(errorCode, errorMessage);

        //    var context = new IPTV2Entities();

        //    Episode ep = context.Episodes.FirstOrDefault(e => e.EpisodeId == id && e.OnlineStatusId == GlobalConfig.Visible);

        //    string url = "";

        //    if (ep != null)

        //    {
        //        Asset asset = ep.PremiumAssets.FirstOrDefault().Asset;

        //        if (asset != null)

        //        {
        //            int assetId = asset == null ? 0 : asset.AssetId;

        //            ViewBag.AssetId = assetId;

        //            var clipDetails = Helpers.Akamai.GetAkamaiClipDetails(ep.EpisodeId, assetId, Request, User);

        //            if (!String.IsNullOrEmpty(clipDetails.Url))

        //            {
        //                errorCode = ErrorCodes.Success;

        //                collection = MyUtility.setError(errorCode, clipDetails.Url);

        //                collection.Add("data", clipDetails);

        //                url = clipDetails.Url;

        //            }

        //            else

        //            {
        //                errorCode = ErrorCodes.AkamaiCdnNotFound;

        //                collection = MyUtility.setError(errorCode, "Akamai Url not found.");

        //            }

        //        }

        //        else

        //        {
        //            errorCode = ErrorCodes.VideoNotFound;

        //            collection = MyUtility.setError(errorCode, "Video not found.");

        //        }

        //    }

        //    else

        //    {
        //        errorCode = ErrorCodes.EpisodeNotFound;

        //        collection = MyUtility.setError(errorCode, "Episode not found.");

        //    }

        //    WebClient client = new WebClient();

        //    Stream data = client.OpenRead(url);

        //    StreamReader reader = new StreamReader(data);

        //    string s = reader.ReadToEnd();

        //    data.Close();

        //    reader.Close();

        //    return s;

        //}

        //public ActionResult List()
        //{
        //    return View();
        //}

        /// <summary>

        /// Description: Get Episodes List

        /// </summary>

        /// <param name="page"></param>

        /// <returns></returns>

        public ActionResult GetEpisodes(int page, int pagesize)
        {
            var episode_data = new PagedData<JsonFeatureItem>();

            List<JsonFeatureItem> episode_list = new List<JsonFeatureItem>();

            var context = new IPTV2Entities();

            //List<ShowLookUpObject> sluo = (List<ShowLookUpObject>)HttpContext.Cache["ShowList"];

            List<Show> showslist = new List<Show>();

            List<int> dummy = new List<int>();

            int[] showIds;

            var service = context.Offerings.Find(GlobalConfig.offeringId).Services

                .Where(p => p.PackageId == GlobalConfig.serviceId

                    && p.StatusId == GlobalConfig.Visible).Single();

            foreach (var category in service.Categories.Select(p => p.Category))
            {
                //get shows

                foreach (int i in service.GetAllOnlineShowIds("--", category).ToArray())
                {
                    dummy.Add(i);
                }
            }

            showIds = dummy.ToArray();

            int records = context.EpisodeCategories1

                                  .Where(

                                    e => showIds.Contains(e.CategoryId)

                                    && e.Episode.OnlineStatusId == GlobalConfig.Visible

                                  )

                                  .Select(n => n.Episode).Count();

            foreach (var item in context.EpisodeCategories1

                                  .Where(

                                    e => showIds.Contains(e.CategoryId)

                                  )

                                  .Select(n => n.Episode).OrderBy(n => n.EpisodeName).Skip(pagesize * (page - 1))

                                  .Take(pagesize).ToList())
            {
                JsonFeatureItem EpisodeItem = new JsonFeatureItem();

                EpisodeItem.EpisodeName = item.EpisodeName;

                EpisodeItem.EpisodeAirDate = (item.DateAired != null) ? item.DateAired.Value.ToString("MMMM d, yyyy") : "";

                EpisodeItem.EpisodeDescription = item.Description;

                EpisodeItem.EpisodeImageUrl = item.ImageAssets.ImageMedium;

                EpisodeItem.ShowId = item.EpisodeCategories.Single().Show.CategoryId;

                EpisodeItem.ShowName = item.EpisodeCategories.Single().Show.CategoryName;

                EpisodeItem.ShowImageUrl = item.EpisodeCategories.Single().Show.ImageTitle;

                EpisodeItem.EpisodeId = item.EpisodeId;

                episode_list.Add(EpisodeItem);
            }

            episode_data.Data = episode_list;

            episode_data.NumberOfPages = Convert.ToInt32(Math.Ceiling((double)records / pagesize));

            episode_data.CurrentPage = page;

            ViewBag.EpisodeList = episode_data;

            return Json(episode_data, JsonRequestBehavior.AllowGet);
        }
		public ActionResult SiteIndex() {
			PagedData<SiteData> model = new PagedData<SiteData>();
			model.PageSize = -1;
			model.InitOrderBy(x => x.SiteName);

			var srt = model.ParseSort();
			var query = ReflectionUtilities.SortByParm<SiteData>(SiteData.GetSiteList(), srt.SortField, srt.SortDirection);

			model.TotalRecords = -1;
			model.DataSource = query.ToList();

			return View(model);
		}
        public ActionResult GetModels(Pagination pagination, string keyword)
        {
            PagedData <Sys_User> pagedData = CreateService <IAccountAppService>().GetSys_UserPageData(pagination, keyword);

            return(this.SuccessData(pagedData));
        }
		public ActionResult ContentSnippetIndex(PagedData<ContentSnippet> model) {
			model.ToggleSort();

			var srt = model.ParseSort();
			var query = ReflectionUtilities.SortByParm<ContentSnippet>(SiteData.CurrentSite.GetContentSnippetList(), srt.SortField, srt.SortDirection);

			model.TotalRecords = -1;
			model.DataSource = query.ToList();

			ModelState.Clear();

			return View(model);
		}
Beispiel #60
0
        private PagedData<DealModels> CreatePaginator(string category, string forum, string filter, int currentPage = 1)
        {
            PagedData<DealModels> deals = new PagedData<DealModels>();
            deals.Data = dbHelper.GetDealsFromCategory(category, forum, filter);
            ActiveDealQuery = deals.Data;
            deals.NumberOfPages = Convert.ToInt32(Math.Ceiling((double)deals.Data.Count() / _pageSize));
            deals.Data = deals.Data.Skip((currentPage - 1) * _pageSize).Take(_pageSize);
            deals.CurrentPage = currentPage;

            return deals;
        }