Esempio n. 1
0
 /// <summary>
 /// Gets the updated table view.
 /// </summary>
 /// <returns>An <see cref="ActionResult"/> containing the updated view data.</returns>
 public ActionResult UpdateSubjectTable()
 {
     PageOptions options = new PageOptions(Request.QueryString["SortBy"], Request.QueryString["PageNumber"]);
     IndexModel model = new IndexModel();
     model.Response = DataStore.GetData(options);
     model.PageOptions = options;
     return View("SubjectTable", model);
 }
Esempio n. 2
0
 public void SortByTest()
 {
     PageOptions target = new PageOptions(); // TODO: Initialize to an appropriate value
     PageOptions.Sort expected = PageOptions.Sort.LastName;
     Assert.AreEqual(expected, target.SortBy, "Default sort should be LastName.");
 }
Esempio n. 3
0
 public void PageOptionsConstructorTest()
 {
     PageOptions target = new PageOptions();
     Assert.IsNotNull(target);
 }
Esempio n. 4
0
 public void PageNumberTest()
 {
     PageOptions target = new PageOptions(); // TODO: Initialize to an appropriate value
     int expected = 0;
     Assert.AreEqual(expected, target.PageNumber, "Default page number should be 0.");
 }
Esempio n. 5
0
 /// <summary>
 /// The .ctor with sort and pagenumber.
 /// </summary>
 /// <param name="Sort">A value of <see cref="PageOptions.Sort"/>.</param>
 /// <param name="PageNumber">A value of a PageNumber.</param>
 public PageOptions(PageOptions.Sort Sort, int PageNumber)
 {
     this.sort = Sort.LastName;
     this.pageNumber = 0;
 }
Esempio n. 6
0
        /// <summary>
        /// See <see cref="IDataStore"/> for method descriptions.
        /// </summary>
        public QueryResponse GetData(PageOptions paging)
        {
            QueryResponse response = new QueryResponse();
            IEnumerable<TestSubject> results = new List<TestSubject>();
            if (paging == null)
            {
                paging = new PageOptions();
            }
            if (paging.SortBy == PageOptions.Sort.FirstName)
                results = datastore.OrderBy(e => e.FirstName);
            else if (paging.SortBy == PageOptions.Sort.LastName)
                results = datastore.OrderBy(e => e.LastName);
            else if (paging.SortBy == PageOptions.Sort.Email)
                results = datastore.OrderBy(e => e.Email);
            else if (paging.SortBy == PageOptions.Sort.Password)
                results = datastore.OrderBy(e => e.Password);

            response.Subjects = results.Skip(paging.PageNumber * 5).Take(5).ToList();
            response.Total = datastore.Count;

            return response;
        }