public ActionResult Index() { var dao = new NewDao(); var model = dao.ListAllPaging(); return(View(model)); }
public ActionResult NewDetail(int id) { var dao = new NewDao(); ViewBag.news = dao.ViewDetail(id); ViewBag.NewsNew = dao.ListNewsNew(5); ViewBag.NewsTop = dao.ListNewsTop(6); ViewBag.ListMovieNew1 = new MovieDao().ListMovieNew1(12); News upview = db.News.Find(id); if (upview.Viewed == null) { upview.Viewed = 1; upview.Name = upview.Name; upview.Image = upview.Image; upview.Description = upview.Description; upview.CreatedDate = upview.CreatedDate; upview.Status = upview.Status; db.Entry(upview).State = EntityState.Modified; db.SaveChanges(); return(View(upview)); } else { upview.Viewed = upview.Viewed + 1; upview.Name = upview.Name; upview.Image = upview.Image; upview.Description = upview.Description; upview.CreatedDate = upview.CreatedDate; upview.Status = upview.Status; db.Entry(upview).State = EntityState.Modified; db.SaveChanges(); return(View(upview)); } }
public ActionResult TopNews() { var topNews = new NewDao().GetListTopNews(1).Take(5); ViewBag.TopNews = topNews; return(PartialView()); }
public ActionResult Index(int page = 1, int pageSize = 10) { var dao = new NewDao(); var model = dao.ListPg(page, pageSize); return(View(model)); }
// GET: Admin/Content public ActionResult Index(string searchString, int page = 1, int pageSize = 10) { var dao = new NewDao(); var model = dao.ListAllPaging(searchString, page, pageSize); ViewBag.SearchString = searchString; return(View(model)); }
// GET: New public ActionResult Index() { var dao = new NewDao(); ViewBag.news = dao.ListNews(9); ViewBag.NewsNew = dao.ListNewsNew(5); ViewBag.NewsTop = dao.ListNewsTop(6); return(View()); }
public ActionResult Edit(int id) { var dao = new NewDao(); var content = dao.GetByID(id); SetViewBag(content.CategoryID); return(View(content)); }
public JsonResult ChangeStatus(int id) { var result = new NewDao().ChangeStatus(id); return(Json(new { status = result })); }
public JsonResult ListName(string q) { var data = new NewDao().ListName(q); return(Json(new { data = data, status = true }, JsonRequestBehavior.AllowGet)); }
public ActionResult SeasonPage(int idc, int page = 1) { var newDao = new NewDao(); var season = new SeasonDao().ViewDetail(idc); ViewBag.season = season; ViewBag.ListNewsNew = newDao.ListNewsNew(12); ViewBag.NewsNew = newDao.ListNewsNew(5); ViewBag.NewsTop = newDao.ListNewsTop(6); var model = newDao.ListBySeasonID(idc); return(View(model.ToPagedList(page, 12))); }
// GET: Home public ActionResult Index() { var MovieDao = new MovieDao(); var NewDao = new NewDao(); ViewBag.ListMovieNew = MovieDao.ListMovieNew(12); ViewBag.ListMovieTop = MovieDao.ListMovieTop(12); ViewBag.ListMoviePo = MovieDao.ListMoviePo(6); ViewBag.ListNewsNew = NewDao.ListNewsNew(6); ViewBag.ListNewsTop = NewDao.ListNewsTop(6); ViewBag.Slides = new SlideDao().ListAllSlide(5); var model = new AdDao().GetContentAd(); return(View(model)); }
public ActionResult Edit(News model) { if (ModelState.IsValid) { var dao = new NewDao(); var session = (UserLogin)Session[CommonConstants.USER_SESSION]; model.ModifiedBy = session.UserName; var id = dao.Edit(model); if (id != 0) { return(RedirectToAction("Index")); } } SetViewBag(model.CategoryID); return(View()); }
public ActionResult AddItem(int productId, int quantity) { var product = new NewDao().ViewDetail(productId); var cart = Session[CartSession]; if (cart != null) { var list = (List <CartItem>)cart; if (list.Exists(x => x.sanpham.MaSP == productId)) { foreach (var item in list) { if (item.sanpham.MaSP == productId) { item.Quantity += quantity; } } } else { //tạo mới đối tượng cart item var item = new CartItem(); item.sanpham = product.SanPham; item.Quantity = quantity; item.check = false; item.MaKV = product.MaKV; list.Add(item); } //Gán vào session Session[CartSession] = list; } else { //tạo mới đối tượng cart item var item = new CartItem(); item.sanpham = product.SanPham; item.Quantity = quantity; item.check = false; item.MaKV = product.MaKV; var list = new List <CartItem>(); list.Add(item); //Gán vào session Session[CartSession] = list; } return(RedirectToAction("Index")); }
public ActionResult Edit(New news) { if (ModelState.IsValid) { var dao = new NewDao(); var result = dao.Update(news); if (result) { SetAlert("Cập nhật thành công", "success"); return(RedirectToAction("Index", "New")); } else { ModelState.AddModelError("", "Cập nhật không thành công"); } } return(View("Index")); }
public ActionResult Recruitment(int page = 1, int pageSize = 5) { int totalRecord = 0; var model = new NewDao().ListRecruitmentPaging(ref totalRecord, page, pageSize); ViewBag.Total = totalRecord; ViewBag.Page = page; int maxPage = 5; int totalPage = 0; totalPage = (int)Math.Ceiling((double)(totalRecord / pageSize)); ViewBag.TotalPage = totalPage; ViewBag.MaxPage = maxPage; ViewBag.First = 1; ViewBag.Last = totalPage; ViewBag.Next = page + 1; ViewBag.Prev = page - 1; return(View(model)); }
public ActionResult Sanpham_ALL(int page = 1, int pageSize = 9) { var newdao = new NewDao(); int totalRecord_hang = 0; var ListALL = newdao.sanPH_sp_hang(null, null, ref totalRecord_hang, page, pageSize); ViewBag.Total = totalRecord_hang; ViewBag.Page = page; int maxPage = 5; int totalPage = 0; totalPage = (int)Math.Ceiling((double)(totalRecord_hang / pageSize)); ViewBag.TotalPage = totalPage; ViewBag.MaxPage = maxPage; ViewBag.First = 1; ViewBag.Last = totalPage; ViewBag.Next = page + 1; ViewBag.Prev = page - 1; return(View(ListALL)); }
public ActionResult timkiem(string keyword, int page = 1, int pageSize = 10) { int totalRecord = 0; var model = new NewDao().Search(keyword, ref totalRecord, page, pageSize); ViewBag.Total = totalRecord; ViewBag.Page = page; ViewBag.Keyword = keyword; int maxPage = 5; int totalPage = 0; totalPage = (int)Math.Ceiling((double)(totalRecord / pageSize)); ViewBag.TotalPage = totalPage; ViewBag.MaxPage = maxPage; ViewBag.First = 1; ViewBag.Last = totalPage; ViewBag.Next = page + 1; ViewBag.Prev = page - 1; return(View(model)); }
public ActionResult SanphamHot_New(string metatitle, int page = 1, int pageSize = 10) { var newdao = new NewDao(); ViewBag.header = metatitle; int totalRecord = 0; var ListALL = newdao.sanPhamHot(metatitle, ref totalRecord, page, pageSize); ViewBag.Total = totalRecord; ViewBag.Page = page; int maxPage = 5; int totalPage = 0; totalPage = (int)Math.Ceiling((double)(totalRecord / pageSize)); ViewBag.TotalPage = totalPage; ViewBag.MaxPage = maxPage; ViewBag.First = 1; ViewBag.Last = totalPage; ViewBag.Next = page + 1; ViewBag.Prev = page - 1; return(View(ListALL)); }
// GET: SanPham public ActionResult Index(int cateId, int page = 1, int pageSize = 9) { var newdao = new NewDao(); var menu = new MenuDao(); ViewBag.header = menu.header(cateId); int totalRecord3 = 0; var ListALL = newdao.sanP_sp(cateId, ref totalRecord3, page, pageSize); ViewBag.Total = totalRecord3; ViewBag.Page = page; int maxPage = 5; int totalPage = 0; totalPage = (int)Math.Ceiling((double)(totalRecord3 / pageSize)); ViewBag.TotalPage = totalPage; ViewBag.MaxPage = maxPage; ViewBag.First = 1; ViewBag.Last = totalPage; ViewBag.Next = page + 1; ViewBag.Prev = page - 1; return(View(ListALL)); }
public ActionResult Sanpham_hang(string metatitle, string hang, int page = 1, int pageSize = 9) { var newdao = new NewDao(); var menu = new MenuDao(); ViewBag.header = menu.header_hang(metatitle, hang); int totalRecord_hang = 0; var ListALL = newdao.sanPH_sp_hang(metatitle, hang, ref totalRecord_hang, page, pageSize); ViewBag.Total = totalRecord_hang; ViewBag.Page = page; int maxPage = 5; int totalPage = 0; totalPage = (int)Math.Ceiling((double)(totalRecord_hang / pageSize)); ViewBag.TotalPage = totalPage; ViewBag.MaxPage = maxPage; ViewBag.First = 1; ViewBag.Last = totalPage; ViewBag.Next = page + 1; ViewBag.Prev = page - 1; return(View(ListALL)); }
public ActionResult Dangtin(NewModel dangtin_m) { if (ModelState.IsValid) { var session = (UserLogin)Session[Web_ban_hang.Common.CommonConstants.USER_SESSION]; var image = (List <NewImage>)Session[Web_ban_hang.Common.CommonConstants.IMAGE_SESSION]; if (session != null) { var newdao = new NewDao(); var dangBT = new DangBT(); var sanpham = new SanPham(); dangBT.UserID = session.UserID; dangBT.MaKV = dangtin_m.MaKV; dangBT.Status = false; dangBT.Xem = 0; var hinh212x212 = new Link().resizeImage(212, 212, Server.MapPath("~" + image[0].image)); hinh212x212.Save(Server.MapPath("~/Upload/Data/212x212/" + image[0].link)); sanpham.Date = DateTime.Now; sanpham.TieuDe = dangtin_m.TieuDe; sanpham.TenSP = dangtin_m.TieuDe; sanpham.Mota = dangtin_m.Mota; sanpham.AnhTDe = "/Upload/Data/212x212/" + image[0].link; sanpham.GiaBan = dangtin_m.GiaBan; sanpham.MaLSP = dangtin_m.MaLSP; sanpham.IDHang = dangtin_m.IDHang; sanpham.ID_BN = dangtin_m.ID_BN; sanpham.ID_BXL = dangtin_m.ID_BXL; sanpham.ID_Camera = dangtin_m.ID_Camera; sanpham.ID_Card = dangtin_m.ID_Card; sanpham.ID_Case = dangtin_m.ID_Case; sanpham.ID_CL = dangtin_m.ID_CL; sanpham.ID_CN = dangtin_m.ID_CN; sanpham.ID_Doi = dangtin_m.ID_Doi; sanpham.ID_DPG = dangtin_m.ID_DPG; sanpham.ID_HDH = dangtin_m.ID_HDH; sanpham.ID_HS = dangtin_m.ID_HS; sanpham.ID_KD = dangtin_m.ID_KD; sanpham.ID_KT = dangtin_m.ID_KT; sanpham.ID_LTR = dangtin_m.ID_LTR; sanpham.ID_M = dangtin_m.ID_M; sanpham.ID_Model = dangtin_m.ID_Model; sanpham.ID_MS = dangtin_m.ID_MS; sanpham.ID_PB = dangtin_m.ID_PB; sanpham.ID_Pin = dangtin_m.ID_Pin; sanpham.ID_PK = dangtin_m.ID_PK; sanpham.ID_QD = dangtin_m.ID_QD; sanpham.ID_R = dangtin_m.ID_R; dangBT.SanPham = sanpham; int so = newdao.Them(dangBT); if (so > 0) { if (image != null) { int i = 1; foreach (var item in image) { var hinh480_360 = new Link().resizeImage(480, 360, Server.MapPath("~" + item.image)); hinh480_360.Save(Server.MapPath("~/Upload/Data/480x360/" + item.link)); var listhinh = new HinhAnh(); listhinh.MASP = so; listhinh.Link = "/Upload/Data/480x360/" + item.link; listhinh.AnhFull = true; listhinh.STTANH = i; var hinh55x41 = new Link().resizeImage(55, 41, Server.MapPath("~" + item.image)); hinh55x41.Save(Server.MapPath("~/Upload/Data/55x41/" + item.link)); var listhinh_1 = new HinhAnh(); listhinh_1.MASP = so; listhinh_1.Link = "/Upload/Data/55x41/" + item.link; listhinh_1.AnhThumbnail = true; listhinh_1.STTANH = i; newdao.Themhinh(listhinh); newdao.Themhinh(listhinh_1); i++; } Session[Web_ban_hang.Common.CommonConstants.IMAGE_SESSION] = null; string link = Server.MapPath("~/Upload/Temp/") + session.UserName; DeleteDirectory(link); } } else { ModelState.AddModelError("", "đăng tin không đúng."); Session[Web_ban_hang.Common.CommonConstants.IMAGE_SESSION] = null; string link = Server.MapPath("~/Upload/Temp/") + session.UserName; DeleteDirectory(link); string link1 = Server.MapPath("~/Upload/Data/212x212/" + image[0].link); DeleteDirectory(link1); } return(Redirect("/")); } } else { var session = (UserLogin)Session[Web_ban_hang.Common.CommonConstants.USER_SESSION]; ViewBag.user = new UserDao().GetById(session.UserName); ViewBag.tinh = new KhuvucDao().ListKV(); } return(View(dangtin_m)); }
public ActionResult Detail(long id) { var model = new NewDao().GetByID(id); return(View(model)); }
public ActionResult ALLSP() { var data = new NewDao().listAll(); return(View(data)); }
public ActionResult Details(int ID) { var user = new NewDao().ViewDetail(ID); return(View(user)); }
public PartialViewResult New() { var model = new NewDao().ListAll(); return PartialView(model); }
public ActionResult Detail(long id) { var news = new NewDao().ViewDeatil(id); return PartialView(news); }
public ActionResult Edit(int id) { var news = new NewDao().ViewDeatil(id); return(View(news)); }