Example #1
0
        // GET: Admin/LoaiHinhAnh/Details/5
        public ActionResult Details(int?id)
        {
            if (Session["User"] == null)
            {
                return(RedirectToAction("Logout", "Account"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            admin_loaihinhanh admin_loaihinhanh = db.admin_loaihinhanh.Find(id);

            if (admin_loaihinhanh == null)
            {
                return(HttpNotFound());
            }

            var imagesModel = new admin_hinhanh();
            //var imageFiles = Directory.GetFiles(Server.MapPath("~/UserUpload/images/HinhAnh/"));
            var           imageFiles = db.admin_hinhanh.Where(s => s.loaihinhanh == admin_loaihinhanh.id).ToList();
            List <string> lstImg     = new List <string>();

            foreach (var item in imageFiles)
            {
                lstImg.Add(item.urlhinhanh);
            }
            ViewBag._lstImg          = lstImg;
            Session["idLoaiHinhAnh"] = admin_loaihinhanh.id;

            return(View());
        }
Example #2
0
        // GET: Admin/LoaiHinhAnh/Edit/5
        public ActionResult Edit(int?id)
        {
            if (Session["User"] == null)
            {
                return(RedirectToAction("Logout", "Account"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Session["idLoaiHinhAnh"] = id;
            admin_loaihinhanh admin_loaihinhanh = db.admin_loaihinhanh.Find(id);

            if (admin_loaihinhanh == null)
            {
                return(HttpNotFound());
            }
            VM_LoaiHinhAnh vmEdit = new VM_LoaiHinhAnh();

            vmEdit._loaihinhanh = admin_loaihinhanh;
            List <admin_hinhanh> arrHinhanh = db.admin_hinhanh.Where(s => s.loaihinhanh == admin_loaihinhanh.id).ToList();

            ViewBag.arrHinhAnh = arrHinhanh;

            ViewBag.nguoitao = new SelectList(db.admin_account, "id", "username", admin_loaihinhanh.nguoitao);
            return(View(admin_loaihinhanh));
        }
Example #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            if (Session["User"] == null)
            {
                return(RedirectToAction("Logout", "Account"));
            }
            admin_loaihinhanh admin_loaihinhanh = db.admin_loaihinhanh.Find(id);

            //db.admin_loaihinhanh.Remove(admin_loaihinhanh);
            admin_loaihinhanh.ngaycapnhat     = DateTime.Now;
            admin_loaihinhanh.daxoa           = true;
            db.Entry(admin_loaihinhanh).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #4
0
 public ActionResult Edit([Bind(Include = "id,tenloaihinhanh,tenloaihinhanh_en,ngaytao,ngaycapnhat,nguoitao,hienthi,daxoa,motahinhanh,motahinhanh_en,ghichu")] admin_loaihinhanh admin_loaihinhanh)
 {
     if (Session["User"] == null)
     {
         return(RedirectToAction("Logout", "Account"));
     }
     if (ModelState.IsValid)
     {
         admin_loaihinhanh.ngaycapnhat     = DateTime.Now;
         db.Entry(admin_loaihinhanh).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.nguoitao = new SelectList(db.admin_account, "id", "username", admin_loaihinhanh.nguoitao);
     return(View(admin_loaihinhanh));
 }
Example #5
0
        // GET: Admin/LoaiHinhAnh/Delete/5
        public ActionResult Delete(int?id)
        {
            if (Session["User"] == null)
            {
                return(RedirectToAction("Logout", "Account"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            admin_loaihinhanh admin_loaihinhanh = db.admin_loaihinhanh.Find(id);

            if (admin_loaihinhanh == null)
            {
                return(HttpNotFound());
            }
            return(View(admin_loaihinhanh));
        }