コード例 #1
0
        public ActionResult Search(string filter = null, int page = 1, int pageSize = 20)
        {
            IEnumerable <Photos> details = null;

            using (var client = new WebClient())
            {
                var     text = client.DownloadString("http://jsonplaceholder.typicode.com/posts/1");
                Details det  = JsonConvert.DeserializeObject <Details>(text);
                if (filter == null)
                {
                    ViewBag.filter = det.title;
                }
                else
                {
                    ViewBag.filter = filter;
                }

                var records = new PagedList <Photos>();
                var Users   = new List <Users>();
                ViewBag.filter = filter;

                Users = repo.GetUser(filter);
                records.TotalRecords = db.Photos.Count();
                records.Content      = repo.GetPhotos(filter);
                records.CurrentPage  = page;
                records.PageSize     = pageSize;

                if (Users != null)
                {
                    Session["Name"]    = Users.Select(x => x.Name);
                    Session["Address"] = Users.Select(x => x.Address);
                    Session["Phone"]   = Users.Select(x => x.Phone);
                    Session["Email"]   = Users.Select(x => x.Email);
                    Session["Photo"]   = Users.Select(x => x.Photo);
                }

                details             = repo.GetPhotos(filter);
                records.CurrentPage = page;
                records.PageSize    = pageSize;
                return(View(records));
            }
        }
コード例 #2
0
        public JsonResult GetGallery()
        {
            string filter   = null;
            var    jsonData = new
            {
                total   = 1,
                page    = 1,
                records = galRepo.GetPhotos(filter).ToList().Count,
                rows    = (
                    from emp in  galRepo.GetPhotos(filter).ToList()
                    select new
                {
                    ImagePath = emp.ImagePath,
                    cell = new string[] {
                        emp.ImagePath.ToString()
                    }
                }).ToArray()
            };

            return(Json(jsonData, JsonRequestBehavior.AllowGet));
        }