示例#1
0
        public ActionResult next(string n)
        {
            var json = new WebClient().DownloadString("https://gist.githubusercontent.com/WillemLabu/34cfb50187ec334c48ee/raw/cb46400505afd82d9e354b591ad71d97f07613be/jobs.json");
                Trace.TraceError(json.ToString());
                var objects = JObject.Parse(json.ToString()); // parse as array
                var subject = JArray.Parse(objects.GetValue("jobs").ToString());
                List<Jobs> jobs = new List<Jobs>();

                foreach (var root in subject)
                {

                    var data = JObject.Parse(root.ToString());
                    Jobs job = new Jobs();
                    job.client = data.GetValue("client").ToString();
                    job.jobNumber = data.GetValue("job-number").ToString();
                    job.jobName = data.GetValue("job-name").ToString();
                    job.due = data.GetValue("due").ToString();
                    job.status = data.GetValue("status").ToString();

                    jobs.Add(job);

                }

                if (Int32.Parse(n) >= jobs.Count() || Int32.Parse(n) < 0)
                {
                ViewBag.Last = 0;
                return View("Index",jobs.GetRange(0, 10));
            }

                ViewBag.Last = Int32.Parse(n);
            return View("Index",jobs.GetRange(Int32.Parse(n), 10));
        }
示例#2
0
        // GET: Jobs
        public ActionResult Index(String SearchString)
        {
            var json = new WebClient().DownloadString("https://gist.githubusercontent.com/WillemLabu/34cfb50187ec334c48ee/raw/cb46400505afd82d9e354b591ad71d97f07613be/jobs.json");
            Trace.TraceError(json.ToString());
            var objects = JObject.Parse(json.ToString()); // parse as array
            var subject = JArray.Parse(objects.GetValue("jobs").ToString());
            List<Jobs> jobs = new List<Jobs>();

            foreach (var root in subject)
            {

                var data = JObject.Parse(root.ToString());
                Jobs job = new Jobs();
                job.client = data.GetValue("client").ToString();
                job.jobNumber = data.GetValue("job-number").ToString();
                job.jobName = data.GetValue("job-name").ToString();
                job.due = data.GetValue("due").ToString();
                job.status = data.GetValue("status").ToString();

                jobs.Add(job);

            }

            var joblist = from m in jobs
                          select m;
            if (!String.IsNullOrEmpty(SearchString))
            {
                jobs = jobs.Where(b => b.jobName.ToUpper().Contains(SearchString.ToUpper())).ToList();

                return View(jobs);

            }
            ViewBag.Last = 0;
            list = jobs;
            return View(jobs.GetRange(0,10));
        }