public decimal Insert(TinTucModel x) { try { TINTUC dao = new TINTUC(); dao.IS_DELETE = false; dao.IDTAIKHOAN = x.IDTAIKHOAN; dao.TIEUDE_TINTUC = x.TIEUDE_TINTUC; dao.GHICHU_TINTUC = x.GHICHU_TINTUC; dao.HINHANH_TINTUC = x.HINHANH_TINTUC; dao.MOTA_TINTUC = x.MOTA_TINTUC; dao.NOIDUNG = x.NOIDUNG; dao.CREATEDATE = x.CREATEDATE; dao.CREATEBY = x.CREATEBY; db.TINTUCs.Add(dao); db.SaveChanges(); return(dao.TINTUC_ID); } catch { return(-1); } }
public ActionResult Createtintuc(FormCollection frmCreate, TINTUC mn) { mn.NoiDung = frmCreate["NoiDung"]; db.TINTUCs.Add(mn); db.SaveChanges(); return(RedirectToAction("Createtintuc", "AdminCRUD")); }
public ActionResult ThemTinTuc(FormCollection f, TINTUC TinTuc) { try { int MAAD = int.Parse(f["MAAD"].ToString()); string TIEUDE = f["TIEUDE"].ToString(); string ANH = f["ANH"].ToString(); //DateTime NGAYDANG = DateTime.Parse(f["NGAYDANG"].ToString()); string MOTA = f["MOTA"].ToString(); string NOIDUNG = f["NOIDUNG"].ToString(); int NOIBAT = int.Parse(f["NOIBAT"].ToString()); int LUOTXEM = int.Parse(f["LUOTXEM"].ToString()); TinTuc.MAAD = MAAD; TinTuc.TIEUDE = TIEUDE; TinTuc.ANH = ANH; TinTuc.NGAYDANG = DateTime.Parse(DateTime.Now.Date.ToString("yyyy/MM/dd")); TinTuc.MOTA = MOTA; TinTuc.NOIDUNG = NOIDUNG; TinTuc.NOIBAT = NOIBAT; TinTuc.LUOTXEM = LUOTXEM; db.TINTUCs.Add(TinTuc); db.SaveChanges(); } catch (Exception) { } return(RedirectToAction("TinTuc", "QLTinTuc")); }
public async Task <ActionResult> TINTUCEDIT([Bind(Include = "ID,IDTHELOAI,TIEUDE,NOIDUNGPHU,HINHANH,NOIDUNGCHINH,NGAYTHANG, HINHANHFile")] TINTUC tINTUC) { var dulieucuatintuc = new BAULEPROFOLIOEntities2(); var modeltintuc = dulieucuatintuc.TINTUCs.Single(t => t.ID == tINTUC.ID); if (tINTUC.HINHANHFile == null) { tINTUC.HINHANH = modeltintuc.HINHANH; } else { string fileName = Path.GetFileNameWithoutExtension(tINTUC.HINHANHFile.FileName); string extension = Path.GetExtension(tINTUC.HINHANHFile.FileName); fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension; tINTUC.HINHANH = fileName; fileName = Path.Combine(Server.MapPath("~/ContentWebmaster/img/"), fileName); tINTUC.HINHANHFile.SaveAs(fileName); } if (ModelState.IsValid) { db.Entry(tINTUC).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("TINTUCVIEW")); } ViewBag.IDTHELOAI = new SelectList(db.THELOAITINTUCs, "IDTHELOAI", "TENTHELOAI", tINTUC.IDTHELOAI); return(View(tINTUC)); }
public ActionResult Edit([Bind(Include = "ID_TT,TITLE,DETAIL,DATEBEGIN,META,ORDER,LINK,HIDE,IMG,MOTA")] TINTUC tINTUC, HttpPostedFileBase img) { var path = ""; var filename = ""; TINTUC temp = getbyID(tINTUC.ID_TT); if (ModelState.IsValid) { if (img != null) { filename = DateTime.Now.ToString("dd-MM-yy-hh-mm-ss") + img.FileName; path = Path.Combine(Server.MapPath("~/Content/img/upload/tintuc"), filename); img.SaveAs(path); temp.IMG = filename; } temp.DATEBEGIN = tINTUC.DATEBEGIN; temp.DETAIL = tINTUC.DETAIL; temp.HIDE = tINTUC.HIDE; temp.LINK = tINTUC.LINK; temp.META = tINTUC.META; temp.MOTA = tINTUC.MOTA; temp.ORDER = tINTUC.ORDER; temp.TITLE = tINTUC.TITLE; db.Entry(temp).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tINTUC)); }
public ActionResult KiemDuyet(TINTUC tINTUC) { if (tINTUC.TRANGTHAI == false) { ModelState.AddModelError("", "Bạn chưa xác nhận đăng tin, vui lòng xem lại"); ViewBag.HoTen = tINTUC.NGUOIDUNG.SDT1; ViewBag.SDT = tINTUC.NGUOIDUNG.SDT1; ViewBag.Email = tINTUC.NGUOIDUNG.EMAIL; ViewBag.MAHUYEN = new SelectList(db.HUYENQUAN, "MAHUYEN", "MATINH", tINTUC.MAHUYEN); ViewBag.MALOAITT = new SelectList(db.LOAITT, "MALOAITT", "TENLOAITT", tINTUC.MALOAITT); return(View(tINTUC)); } if (ModelState.IsValid) { db.Entry(tINTUC).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } db.Entry(tINTUC).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); ViewBag.HoTen = tINTUC.NGUOIDUNG.HOTENND; ViewBag.SDT = tINTUC.NGUOIDUNG.SDT1; ViewBag.Email = tINTUC.NGUOIDUNG.EMAIL; ViewBag.MAHUYEN = new SelectList(db.HUYENQUAN, "MAHUYEN", "MATINH", tINTUC.MAHUYEN); ViewBag.MALOAITT = new SelectList(db.LOAITT, "MALOAITT", "TENLOAITT", tINTUC.MALOAITT); return(View(tINTUC)); }
public ActionResult Create(TINTUC tintuc, HttpPostedFileBase fileUpload) { ViewBag.MaCD = new SelectList(data.CHUDETINTUCs.ToList().GroupBy(n => n.TenChuDe), "MaCD", "TenChude"); if (fileUpload == null) { ViewBag.Thongbao = "Vui lòng chọn ảnh bìa"; return(View()); } else { if (ModelState.IsValid) { var fileName = Path.GetFileName(fileUpload.FileName); var path = Path.Combine(Server.MapPath("~/Content/News_images"), fileName); if (System.IO.File.Exists(path)) { ViewBag.Thongbao = "Hình đã tồn tại!"; } else { fileUpload.SaveAs(path); } tintuc.Anhbia = fileName; data.TINTUCs.InsertOnSubmit(tintuc); data.SubmitChanges(); } return(RedirectToAction("Tintuc")); } }
public ActionResult Deletetintuc(int id) { TINTUC mn = db.TINTUCs.Find(id); db.TINTUCs.Remove(mn); db.SaveChanges(); return(RedirectToAction("Createtintuc")); }
public ActionResult DeleteConfirmed(int id) { TINTUC tINTUC = db.TINTUC.Find(id); db.TINTUC.Remove(tINTUC); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int id) { TINTUC tINTUC = db.TINTUCs.Find(id); db.TINTUCs.Remove(tINTUC); db.SaveChanges(); return(RedirectToAction("tintuc", "Quanly")); }
public async Task <ActionResult> DeleteConfirmed2(string id) { TINTUC tINTUC = await db.TINTUCs.FindAsync(id); db.TINTUCs.Remove(tINTUC); await db.SaveChangesAsync(); return(RedirectToAction("TINTUCVIEW")); }
public ActionResult AddToCart(int id) { Cart cart = getCart(); TINTUC p = db.TINTUC.Find(id); cart.AddItem(p); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "STT,TenTT,TomTat,HinhMinhHoa,href,date")] TINTUC tINTUC) { if (ModelState.IsValid) { db.Entry(tINTUC).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("tintuc", "Quanly")); } return(View(tINTUC)); }
public void updateView(string matintuc) { TINTUC item = db.TINTUCs.Where(a => a.MaTinTuc == int.Parse(matintuc)).FirstOrDefault(); if (item != null) { item.SoLuongLuotXem++; db.SubmitChanges(); } }
public ActionResult UpdateCart(int[] ID_TinTuc) { Cart cart = getCart(); for (int i = 0; i < ID_TinTuc.Length; i++) { TINTUC p = db.TINTUC.Find(ID_TinTuc[i]); cart.UpdateItem(p); } return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "STT,TenTT,TomTat,HinhMinhHoa,href,date")] TINTUC tINTUC) { if (ModelState.IsValid) { db.TINTUCs.Add(tINTUC); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tINTUC)); }
public ActionResult Edit([Bind(Include = "ID_TIN,ID_NHOM,tentin,ImgTin,mota")] TINTUC tINTUC) { if (ModelState.IsValid) { db.Entry(tINTUC).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ID_NHOM = new SelectList(db.NHOMTINs, "ID_NHOM", "tennhomtin", tINTUC.ID_NHOM); return(View(tINTUC)); }
public ActionResult Create([Bind(Include = "ID_TT,TITLE,DETAIL,DATEBEGIN,META,ORDER,LINK,HIDE,IMG,MOTA")] TINTUC tINTUC) { if (ModelState.IsValid) { db.TINTUCs.Add(tINTUC); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tINTUC)); }
public int Delete(TINTUC model) { TINTUC dbEntry = context.TINTUCs.Find(model.ID_TIN); if (dbEntry == null) { return(0); } context.TINTUCs.Remove(dbEntry); context.SaveChanges(); return(1); }
public int Insert(TINTUC model) { TINTUC dbEntry = context.TINTUCs.Find(model.ID_TIN); if (dbEntry != null) { return(0); } context.TINTUCs.Add(model); context.SaveChanges(); return(1); }
//public bool themTinTuc(string maloaitintuc, string tieude, string motangan, string noidung, string manhanvien, bool hienthitrangchu, string logo) //{ //} public bool xoaTinTuc(string matintuc) { TINTUC tt = db.TINTUCs.Where(a => a.MaTinTuc == int.Parse(matintuc)).FirstOrDefault(); if (tt != null) { tt.TinhTrangXoa = true; db.SubmitChanges(); return(true); } return(false); }
public ActionResult Createtintuc(FormCollection frmTao, TINTUC SP) { SP.TenTT = frmTao["TenTT"]; SP.TomTat = frmTao["TT"]; SP.href = frmTao["href"]; SP.date = DateTime.Now; SP.HinhMinhHoa = frmTao["fileUpload"]; db.TINTUCs.Add(SP); db.SaveChanges(); return(RedirectToAction("tintuc", "Quanly")); }
public ActionResult deleteTintuc(int id) { TINTUC tintuc = data.TINTUCs.SingleOrDefault(n => n.Matintuc == id); ViewBag.Matintuc = tintuc.Matintuc; if (tintuc == null) { Response.StatusCode = 404; return(null); } return(View(tintuc)); }
public ActionResult editTintuc(int id) { TINTUC tintuc = data.TINTUCs.SingleOrDefault(n => n.Matintuc == id); ViewBag.Matintuc = tintuc.Matintuc; if (tintuc == null) { Response.StatusCode = 404; return(null); } ViewBag.Matintuc = new SelectList(data.CHUDETINTUCs.ToList().OrderBy(n => n.TenChuDe), "MaCD", "TenChude", tintuc.MaCD); return(View(tintuc)); }
public async Task <ActionResult> Create([Bind(Include = "ID,IDTHELOAI,TIEUDE,NOIDUNGPHU,HINHANH,NOIDUNGCHINH,NGAYTHANG")] TINTUC tINTUC) { if (ModelState.IsValid) { db.TINTUCs.Add(tINTUC); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.IDTHELOAI = new SelectList(db.THELOAITINTUCs, "IDTHELOAI", "TENTHELOAI", tINTUC.IDTHELOAI); return(View(tINTUC)); }
public int Update(TINTUC model) { TINTUC dbEntry = context.TINTUCs.Find(model.ID_TIN); if (dbEntry == null) { return(0); } dbEntry.tentin = model.tentin; dbEntry.ImgTin = model.ImgTin; dbEntry.mota = model.mota; context.SaveChanges(); return(1); }
public ActionResult confirmDelete(int id) { TINTUC tintuc = data.TINTUCs.SingleOrDefault(n => n.Matintuc == id); ViewBag.Matintuc = tintuc.Matintuc; if (tintuc == null) { Response.StatusCode = 404; return(null); } data.TINTUCs.DeleteOnSubmit(tintuc); data.SubmitChanges(); return(RedirectToAction("Tintuc")); }
public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TINTUC tINTUC = db.TINTUC.Find(id); if (tINTUC == null) { return(HttpNotFound()); } return(View(tINTUC)); }
public async Task <ActionResult> BLOGDETAIL1(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TINTUC tINTUC = await db.TINTUCs.FindAsync(id); if (tINTUC == null) { return(HttpNotFound()); } return(View(tINTUC)); }
public ActionResult EditTT(TINTUC tINTUC) { if (ModelState.IsValid) { db.Entry(tINTUC).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } db.Entry(tINTUC).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); ViewBag.MAHUYEN = new SelectList(db.HUYENQUAN, "MAHUYEN", "MATINH", tINTUC.MAHUYEN); ViewBag.MALOAITT = new SelectList(db.LOAITT, "MALOAITT", "TENLOAITT", tINTUC.MALOAITT); return(View(tINTUC)); }