コード例 #1
0
        // GET: Room
        public ActionResult GetListByCategory(int?id, int page = 1)
        {
            if (!id.HasValue)
            {
                return(RedirectToAction("Index", "Home"));
            }
            using (var dc = new QLKSEntities())
            {
                int totalP = dc.Rooms.Where(p => p.CatID == id).Count();
                int nPage  = totalP / nPerPage + (totalP % nPerPage > 0 ? 1 : 0);
                if (page < 1)
                {
                    page = 1;
                }
                if (page > nPage)
                {
                    page = nPage;
                }
                ViewBag.totalPage = nPage;
                ViewBag.curPage   = page;

                var l = dc.Rooms
                        .Where(p => p.CatID == id)
                        .OrderBy(p => p.RoomID)
                        .Skip((page - 1) * nPerPage)
                        .Take(nPerPage)
                        .ToList();
                return(View("ListByCategory", l));
            }
        }
コード例 #2
0
 // GET: Category
 public ActionResult GetList()
 {
     using (var dc = new QLKSEntities())
     {
         var l = dc.Categories.ToList();
         return(PartialView("_PartialList", l));
     }
 }
コード例 #3
0
ファイル: RoomController.cs プロジェクト: tuhuynhkhtn/QLKS
 // GET: Room
 public ActionResult GetListByCategory(int catId)
 {
     using (var dc = new QLKSEntities())
     {
         var l = dc.Rooms.Where(p => p.CatID == catId).ToList();
         return(View("ListByCategory", l));
     }
 }
コード例 #4
0
 // GET: ManageCategory
 public ActionResult IndexManageCategory()
 {
     using (var dc = new QLKSEntities())
     {
         var l = dc.Categories.ToList();
         return(View(l));
     }
 }
コード例 #5
0
 // GET: ManageRoom
 public ActionResult IndexManageRoom()
 {
     using (var dc = new QLKSEntities())
     {
         var l = dc.Rooms.ToList();
         return(View(l));
     }
 }
コード例 #6
0
        public ActionResult Register(UserRegisting user)
        {
            var u = new User
            {
                f_UserName = user.UserName,
                f_Password = Ulti.Md5Hash(user.Password),
                f_Name     = user.Name
            };

            using (var dc = new QLKSEntities())
            {
                dc.Users.Add(u);
                dc.SaveChanges();
            }
            return(View());
        }