public ActionResult TaoMoi(TruyenModel truyen, HttpPostedFileBase AnhBia) { DaoTruyen truyen2 = new DaoTruyen(); ViewBag.TheLoai = truyen2.LayTheLoai(); ViewBag.TrangThai = truyen2.LayTrangThai(); if (ModelState.IsValid) { DaoCTTruyen ct = new DaoCTTruyen(); NguoiDung nguoi = (NguoiDung)Session["TaiKhoan"]; var truyen1 = new Truyen(); truyen.AnhBia = ThemAnh(AnhBia); int maproject = truyen2.ThemVao(truyen2.Tao(truyen, nguoi)); string theloais = Request.Form["DSTheLoai"]; string[] DSTheLoai = theloais.Split(new char[] { ',' }); if (ct.Get(DSTheLoai, maproject)) { return(RedirectToAction("Index", "User")); } else { ModelState.AddModelError("", "Lỗi"); } } else { ModelState.AddModelError("", "Yêu cầu nhập các trường bắt buộc"); } return(View(truyen)); }
public ActionResult TaoMoi() { if (!CheckSS()) { return(RedirectToAction("DangNhap", "User")); } else { DaoTruyen truyen = new DaoTruyen(); DAO.DaoBanDich bandich = new DAO.DaoBanDich(); ViewBag.NgonNgu = bandich.GetNgonNgu(); ViewBag.TheLoai = truyen.LayTheLoai(); ViewBag.TrangThai = truyen.LayTrangThai(); return(View()); } }
public ActionResult CapNhatTruyen(int id) { if (!CheckSS()) { return(RedirectToAction("DangNhap", "User")); } else { DaoTruyen truyen = new DaoTruyen(); DaoCTTruyen ct = new DaoCTTruyen(); ViewBag.TheLoai = truyen.LayTheLoai(); ViewBag.TrangThai = truyen.LayTrangThai(); return(View(truyen.LayTruyenModel(id, ct.GetTheLoai(id)))); } }
public ActionResult CapNhatTruyen(int id, TruyenModel model, HttpPostedFileBase fileupload) { DaoTruyen truyen2 = new DaoTruyen(); ViewBag.TheLoai = truyen2.LayTheLoai(); ViewBag.TrangThai = truyen2.LayTrangThai(); if (ModelState.IsValid) { if (fileupload != null) { model.AnhBia = ThemAnh(fileupload); } int maproject = -1; maproject = truyen2.CapNhat(id, model); if (maproject == -1) { ModelState.AddModelError("", "Chỉnh sửa thất bại"); } else { DaoCTTruyen ct = new DaoCTTruyen(); if (ct.Update(model.DStheloai, maproject)) { return(RedirectToAction("QuanLyTruyenDaTao", "Truyen")); } else { ModelState.AddModelError("", "Chỉnh sửa thể loại thất bại"); } } } else { ModelState.AddModelError("", "Nhập các thông tin bắt buộc"); } return(View(model)); }