// 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)); } }
// GET: Category public ActionResult GetList() { using (var dc = new QLKSEntities()) { var l = dc.Categories.ToList(); return(PartialView("_PartialList", l)); } }
// 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)); } }
// GET: ManageCategory public ActionResult IndexManageCategory() { using (var dc = new QLKSEntities()) { var l = dc.Categories.ToList(); return(View(l)); } }
// GET: ManageRoom public ActionResult IndexManageRoom() { using (var dc = new QLKSEntities()) { var l = dc.Rooms.ToList(); return(View(l)); } }
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()); }