示例#1
0
 public ActionResult Index()
 {
     using (PingPong7Context db = new PingPong7Context())
     {
         return(View(db.Accounts.ToList()));
     }
 }
        // GET: Terminarzs
        //   public ActionResult Index()
        //  {
        //      var terminarzs = db.Terminarzs.Include(t => t.Zespol);
        //      return View(terminarzs.ToList());
        //  }


        public ActionResult Index(int?page, int?pageSize)
        {
            int pageIndex = 1;

            pageIndex = page.HasValue ? Convert.ToInt32(page) : 1;


            //Ddefault size is 5 otherwise take pageSize value
            int defaSize = (pageSize ?? 6);

            ViewBag.psize = defaSize;

            //Dropdownlist code for PageSize selection
            //In View Attach this
            ViewBag.PageSize = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Value = "6", Text = "6"
                },
            };

            //Create a instance of our DataContext
            PingPong7Context _dbContext = new PingPong7Context();


            IPagedList <Terminarz> involst = null;

            //Alloting nos. of records as per pagesize and page index.
            involst = _dbContext.Terminarzs.OrderBy(x => x.Id_terminarz).ToPagedList(pageIndex, defaSize);

            return(View(involst));
        }
示例#3
0
 public ActionResult Login(Account acc)
 {
     using (PingPong7Context db = new PingPong7Context())
     {
         var usr = db.Accounts.Single(u => u.Name == acc.Name && u.Password == acc.Password);
         if (usr != null)
         {
             Session["LoginId"] = usr.LoginId.ToString();
             Session["Name"]    = usr.Name.ToString();
             return(RedirectToAction("LoggedIn"));
         }
         else
         {
             ModelState.AddModelError("", "Name or Password is wrong");
         }
     }
     return(View());
 }