Exemplo n.º 1
0
        public ActionResult TaoMoi(int id)
        {
            DaoChuongTruyen chuongtruyen = new DaoChuongTruyen();

            ViewBag.LoaiTrang = chuongtruyen.GetLoaiTrang();
            ViewBag.MaTruyen  = id;
            return(View());
        }
Exemplo n.º 2
0
        public ActionResult CapNhatChuong(int id)
        {
            DaoChuongTruyen chuongtruyen = new DaoChuongTruyen();

            ViewBag.LoaiTrang   = chuongtruyen.GetLoaiTrang();
            ViewBag.MaLoaiTrang = 0;

            ViewBag.Id = chuongtruyen.GetMaTruyen(id);
            return(PartialView(chuongtruyen.GetChuongTruyenModel(id)));
        }
Exemplo n.º 3
0
        public ActionResult CapNhatTrang(int id)
        {
            DaoChuongTruyen chuongtruyen = new DaoChuongTruyen();

            ViewBag.LoaiTrang11 = chuongtruyen.GetLoaiTrang();
            DAO.DaoTrangTruyen trangtruyens = new DAO.DaoTrangTruyen();
            ViewBag.TenChuong = data.ChuongTruyens.SingleOrDefault(m => m.MaChuongTruyen == id).TenChuongTruyen;
            ViewBag.id        = id;

            ViewBag.MaTruyen = chuongtruyen.GetMaTruyen(id);
            return(PartialView(trangtruyens.GetTrangTruyen(id, 2)));
        }
Exemplo n.º 4
0
        public ActionResult CapNhatChuong(int id, ChuongTruyenModel chuongtruyen)
        {
            DaoChuongTruyen chuongtruyen1 = new DaoChuongTruyen();

            if (chuongtruyen1.Update(id, chuongtruyen.TenChuong, chuongtruyen.ThutuChuong) > 0)
            {
                return(RedirectToAction("Index", "User"));
            }
            ViewBag.LoaiTrang = chuongtruyen1.GetLoaiTrang();

            ViewBag.id = id;
            return(View());
        }
Exemplo n.º 5
0
        public ActionResult TaoMoi(int id, ChuongTruyenModel chuongtruyen, HttpPostedFileBase[] AnhTrang)
        {
            NguoiDung       nguoi         = (NguoiDung)Session["TaiKhoan"];
            DaoChuongTruyen chuongtruyen1 = new DaoChuongTruyen();

            ViewBag.LoaiTrang = chuongtruyen1.GetLoaiTrang();
            if (ModelState.IsValid)
            {
                int             thutu     = 0;
                DaoChuongTruyen daochuong = new DaoChuongTruyen();
                ChuongTruyen    chuong    = new ChuongTruyen();
                chuong = daochuong.Add(id, chuongtruyen.TenChuong, chuongtruyen.ThutuChuong);
                var result = daochuong.Insert(chuong);
                if (result > 0)
                {
                    string   ThuTuTrangs  = Request.Form["ThuTuTrang"];
                    string   TenTrangs    = Request.Form["TenTrang"];
                    string[] DsThuTuTrang = ThuTuTrangs.Split(new char[] { ',' });

                    string[] DsTenTrangTrang = TenTrangs.Split(new char[] { ',' });
                    for (int i = 0; i < AnhTrang.Length; i++)
                    {
                        var file1 = Path.GetFileName(AnhTrang[i].FileName);
                        var path  = Path.Combine(Server.MapPath("~/Truyen"), file1);
                        AnhTrang[i].SaveAs(path);
                        TrangTruyen trang = new TrangTruyen();
                        trang.MaChuongTruyen = result;
                        trang.MaLoaiTrang    = int.Parse(Request.Form["MaLoaiTrang"]);
                        trang.MaNguoiDung    = nguoi.MaNguoiDung;
                        trang.ThuTu          = int.Parse(DsThuTuTrang[i]);
                        trang.UrlAnh         = file1;
                        trang.DaXoa          = false;
                        trang.TenTrang       = DsTenTrangTrang[i];
                        data.TrangTruyens.Add(trang);
                        data.SaveChanges();
                        thutu += 1;
                    }
                    return(RedirectToAction("Index", "User"));
                }
                else
                {
                    ModelState.AddModelError("", "Thêm chương mới thất bại");
                }
            }
            else
            {
                ModelState.AddModelError("", "Yêu cầu Nhập đủ thông tin");
            }

            return(RedirectToAction("Index", "User"));
        }