public ActionResult Edit(tintuc tintuc) { if (Session["user_id"].Equals("")) { return(RedirectToAction("Login", "Auth")); } else { ViewBag.idLoaiTin = new SelectList(db.loaitins, "id", "Ten"); ViewBag.User_Create = new SelectList(db.users, "id", "name"); if (ModelState.IsValid) { tintuc.updated_at = DateTime.Now; tintuc.TieuDeKhongDau = mystring.convertToUnSign(tintuc.TieuDe); //upload file var f = Request.Files["img[]"]; if (f != null && f.ContentLength > 0) { tintuc.ImagePath = DateTime.Now.ToString("ddMMyyyyHHmmss") + f.FileName.Substring(f.FileName.LastIndexOf(".")); string pathfiles = Path.Combine(Server.MapPath("~/Image/Tintuc/"), tintuc.ImagePath); f.SaveAs(pathfiles); } db.Entry(tintuc).State = EntityState.Modified; db.SaveChanges(); ViewBag.Message = "Update data successfully!"; //return RedirectToAction("Index"); } ViewBag.idLoaiTin = new SelectList(db.loaitins, "id", "Ten", tintuc.idLoaiTin); ViewBag.User_Create = new SelectList(db.users, "id", "name", tintuc.User_Create); return(View(tintuc)); } }
public ActionResult Insert(tintuc tintuc) { if (Session["user_id"].Equals("")) { return(RedirectToAction("Login", "Auth")); } else { ViewBag.idLoaiTin = new SelectList(db.loaitins, "id", "Ten"); ViewBag.User_Create = new SelectList(db.users, "id", "name"); if (ModelState.IsValid) { if (tintuc.TieuDe != null || tintuc.NoiDung != null) { ViewBag.tam = 1; tintuc.SoLuotXem = 0; tintuc.created_at = DateTime.Now; tintuc.updated_at = null; tintuc.status = 2; tintuc.TieuDeKhongDau = mystring.convertToUnSign(tintuc.TieuDe); string ckInput = mystring.RemoveHTMLTags(tintuc.NoiDung); //upload file var f = Request.Files["img[]"]; if (f != null && f.ContentLength > 0) { tintuc.ImagePath = DateTime.Now.ToString("ddMMyyyyHHmmss") + f.FileName.Substring(f.FileName.LastIndexOf(".")); string pathfiles = Path.Combine(Server.MapPath("~/Image/Tintuc/"), tintuc.ImagePath); f.SaveAs(pathfiles); } else { tintuc.ImagePath = "noimage.png"; } db.tintucs.Add(tintuc); db.SaveChanges(); //ViewBag.Message = System.Text.Encoding.UTF8.GetBytes("Thêm dữ liệu thành công!"); ViewBag.Message = "Add data successfully!"; //return RedirectToAction("Index"); } else { ViewBag.tam = 2; ViewBag.Message = "The input data is empty!"; } } ViewBag.idLoaiTin = new SelectList(db.loaitins, "id", "Ten", tintuc.idLoaiTin); ViewBag.User_Create = new SelectList(db.users, "id", "name", tintuc.User_Create); return(View(tintuc)); } }
[ValidateInput(false)]//tat co che bao mat de su dung dc ckedit public ActionResult Insert() { if (Session["user_id"].Equals("")) { return(RedirectToAction("Login", "Auth")); } else { tintuc tintuc = new tintuc(); tintuc.User_Create = Session["user_id"].ToString(); ViewBag.idLoaiTin = new SelectList(db.loaitins, "id", "Ten"); ViewBag.User_Create = new SelectList(db.users, "id", "name"); return(View()); } }
public bool edit_tin_tuc(int id, tintuc tt) { string msgError = ""; try { var result = _Helper.ExecuteScalarSProcedureWithTransaction(out msgError, "update_tin_tuc", "@matt", tt.matt, "@ten_lnv", tt.tieude, "@tomtat", tt.tomtat, "@hinhanh", tt.hinhanh, "@maloaitt", tt.maloaitt, "@noidung", tt.noidung); if ((!string.IsNullOrEmpty(msgError)) || (!string.IsNullOrEmpty(result.ToString()) && result != null)) { throw new Exception(msgError); } return(true); } catch (Exception ex) { throw ex; } }
// GET: Admin/Tintuc/Delete/5 public ActionResult Delete(int?id) { if (Session["user_id"].Equals("")) { return(RedirectToAction("Login", "Auth")); } else { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tintuc tintuc = db.tintucs.Find(id); db.tintucs.Remove(tintuc); db.SaveChanges(); ViewBag.Message = "Delete data successfully!"; return(RedirectToAction("Trash", "Tintuc")); } }
public ActionResult Deltrash(int?id) { if (Session["user_id"].Equals("")) { return(RedirectToAction("Login", "Auth")); } else { if (id == null) { return(RedirectToAction("Index")); } tintuc tintuc = db.tintucs.Find(id); tintuc.status = 0; db.Entry(tintuc).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } }
public ActionResult Status(int?id) { if (id == null) { return(RedirectToAction("Index")); } tintuc tintuc = db.tintucs.Find(id); if (tintuc.status == 1) { tintuc.status = 2; } else { tintuc.status = 1; } db.Entry(tintuc).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Retrash(int?id) { if (Session["user_id"].Equals("")) { return(RedirectToAction("Login", "Auth")); } else { if (id == null) { return(RedirectToAction("Trash", "Tintuc")); } tintuc tintuc = db.tintucs.Find(id); tintuc.status = 2; db.Entry(tintuc).State = EntityState.Modified; db.SaveChanges(); ViewBag.Message = "Data recovery success!"; return(RedirectToAction("Trash", "Tintuc")); } }
public int save_tintuc(tintuc vtintuc, ref string errMsg) { try { errMsg = ""; int i = 0; int result = 0; SqlParameter[] prms = new SqlParameter[11]; prms[i] = new SqlParameter("@matintuc", vtintuc.Matintuc); i = i + 1; prms[i] = new SqlParameter("@teude", vtintuc.Teude); i = i + 1; prms[i] = new SqlParameter("@mota", vtintuc.Mota); i = i + 1; prms[i] = new SqlParameter("@noidung", vtintuc.Noidung); i = i + 1; prms[i] = new SqlParameter("@anh", vtintuc.Anh); i = i + 1; prms[i] = new SqlParameter("@nguoidang", vtintuc.Nguoidang); i = i + 1; prms[i] = new SqlParameter("@nguoitao", vtintuc.Nguoitao); i = i + 1; prms[i] = new SqlParameter("@trangthai", vtintuc.Trangthai); i = i + 1; prms[i] = new SqlParameter("@ngaydang", vtintuc.Ngaydang); i = i + 1; prms[i] = new SqlParameter("@outreturn", SqlDbType.Int, 1); prms[i].Direction = ParameterDirection.Output; result = SQLExecute.ExcuteSPOutput("[dbo].[sp_save_tintuc]", ref prms, 10, ref errMsg, "@outreturn"); return(result); } catch (Exception ex) { errMsg = ex.Message; return(0); } }
[ValidateInput(false)]//tat co che bao mat de su dung dc ckedit public ActionResult Edit(int?id) { if (Session["user_id"].Equals("")) { return(RedirectToAction("Login", "Auth")); } else { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tintuc tintuc = db.tintucs.Find(id); if (tintuc == null) { return(HttpNotFound()); } ViewBag.idLoaiTin = new SelectList(db.loaitins, "id", "Ten", tintuc.idLoaiTin); ViewBag.User_Create = new SelectList(db.users, "id", "name", tintuc.User_Create); return(View(tintuc)); } }
public bool edit_tin_tuc(int id, tintuc tt) { return(_Respo.edit_tin_tuc(id, tt)); }
public bool create_tin_tuc(tintuc tt) { return(_Respo.create_tin_tuc(tt)); }
public bool edit_tin_tuc(int id, [FromBody] tintuc tt) { return(_Buss.edit_tin_tuc(id, tt)); }
public bool create__tin_tuc([FromBody] tintuc tt) { return(_Buss.create_tin_tuc(tt)); }