public Messages <tblNew> InsertAndUpdate(short permissions, tblNew news) { var response = new Commons.Messages <tblNew>() { Status = false, Message = string.Empty }; try { if (ADecentralize.Create(permissions)) { response.Status = new ANews().InsertAndUpdate(news); if (new ANews().GetById(news.Id) != null) { response.Message = response.Status ? "Update successfully." : "Update failed."; } else { response.Message = response.Status ? "Insert successfully." : "Insert failed."; } return(response); } response.Message = "Limit permissions!"; return(response); } catch (Exception ex) { FileHelper.WriteLine(Settings.Path, ex); response.Message = "Execution error!"; return(response); } }
public ActionResult AddOrEditNews(tblNew news) { if (news.NewsId == 0) { HttpPostedFileBase fup = Request.Files["Photo"]; news.Photo = fup.FileName; if (fup.ContentLength > 0) { fup.SaveAs(Path.Combine(Server.MapPath("~/Images/News/"), fup.FileName)); } db.tblNews.Add(news); db.SaveChanges(); return(RedirectToAction("News", "Admin")); } else { HttpPostedFileBase fup = Request.Files["Photo"]; tblNew tb = db.tblNews.Where(x => x.NewsId == news.NewsId).FirstOrDefault(); tb.Title = news.Title; tb.Description = news.Description; if (fup.ContentLength > 0) { System.IO.File.Delete(Path.Combine(Server.MapPath("~/Images/News/"), tb.Photo)); tb.Photo = fup.FileName; fup.SaveAs(Path.Combine(Server.MapPath("~/Images/News/"), fup.FileName)); } db.SaveChanges(); return(RedirectToAction("News", "Admin")); } }
public bool EditNews(tblNew obj) { bool isOk = false; try { tblNew exist = dbContext.tblNews.SingleOrDefault(a => a.Id == obj.Id); if (exist != null) { exist.Title = obj.Title; exist.UserId = obj.UserId; exist.CateID = obj.CateID; exist.Contents = obj.Contents; exist.Statust = obj.Statust; exist.Alias = obj.Alias; exist.LinkYoutube = obj.LinkYoutube; exist.CateID = obj.CateID; exist.Type = obj.Type; exist.CreateDate = obj.CreateDate; dbContext.SubmitChanges(); isOk = true; } return(true); } catch (Exception) { return(isOk); } }
public bool InsertAndUpdate(tblNew news) { using (var db = new ModelDbContext()) { var item = new tblNew() { Id = news.Id }; if (db.tblNews.Any(p => p.Id == news.Id)) { db.tblNews.Attach(item); item.Content = news.Content; item.ModifyDate = DateTime.Now; item.Describe = news.Describe; item.Group = news.Group; item.Img = news.Img; item.ImgResizer = news.ImgResizer; item.Position = news.Position; item.Titles = news.Titles; } else { db.tblNews.Add(news); } return(db.SaveChanges() > 0); } }
public ActionResult DeleteNews(int id) { if (ClsCheckRole.CheckQuyen(4, 3, int.Parse(Request.Cookies["Username"].Values["UserID"])) == true) { tblNew tblnews = db.tblNews.Find(id); clsSitemap.DeteleSitemap(id.ToString(), "News"); var result = string.Empty; int ord = int.Parse(tblnews.Ord.ToString()); int idCate = int.Parse(tblnews.idCate.ToString()); var kiemtra = db.tblNews.Where(p => p.Ord > ord && p.idCate == idCate).ToList(); if (kiemtra.Count > 0) { var ListNews = db.tblNews.Where(p => p.Ord > ord && p.idCate == idCate).ToList(); for (int i = 0; i < ListNews.Count; i++) { int idp = int.Parse(ListNews[i].id.ToString()); var NewsUpdate = db.tblNews.Find(idp); NewsUpdate.Ord = NewsUpdate.Ord - 1; db.SaveChanges(); } } db.tblNews.Remove(tblnews); db.SaveChanges(); result = "Bạn đã xóa thành công."; return(Json(new { result = result })); } else { var result = string.Empty; result = "Bạn không có quyền thay đổi tính năng này !."; return(Json(new { result = result })); } }
public ActionResult Create([Bind(Include = "Id,Group,Titles,Describe,Content,Img,Order,View")] tblNew tblNew) { if (IsLogin()) { if (ModelState.IsValid) { tblNew.ImgResizer = tblNew.Img.Replace("/Uploads", "/Uploads/_thumbs"); tblNew.Creators = 1; tblNew.Position = 1; tblNew.Status = 1; tblNew.CreateDate = DateTime.Now; tblNew.ModifyDate = DateTime.Now; //db.tblNews.Add(tblNew); //db.SaveChanges(); var a = ExecuteNews.News.InsertAndUpdate(SessionDecentralize(), tblNew).Status; return(RedirectToAction("Index")); } ViewBag.Group = new SelectList(ExecuteNews.Group.GetAll(), "Id", "Title", tblNew.Group); return(View(tblNew)); } else { return(RedirectToAction("Login", "User")); } }
public ActionResult Edit(int?id) { if ((Request.Cookies["Username"] == null)) { return(RedirectToAction("LoginIndex", "Login")); } if (ClsCheckRole.CheckQuyen(5, 2, int.Parse(Request.Cookies["Username"].Values["UserID"])) == true) { Session["id"] = id.ToString(); Int32 ids = Int32.Parse(id.ToString()); tblNew tblnews = db.tblNews.Find(ids); if (tblnews == null) { return(HttpNotFound()); } var menuModel = db.tblGroupNews.Where(m => m.ParentID == null).OrderBy(m => m.id).ToList(); carlist.Clear(); string strReturns = "---"; foreach (var item in menuModel) { carlist.Add(new SelectListItem { Text = item.Name, Value = item.id.ToString() }); StringClass.DropDownListNews(item.id, carlist, strReturns); strReturns = "---"; } int idGroups = 0; if (tblnews.idCate != null) { idGroups = int.Parse(tblnews.idCate.ToString()); } ViewBag.drMenu = new SelectList(carlist, "Value", "Text", idGroups); var menuModelProduct = db.tblGroupProducts.Where(m => m.ParentID == null).OrderBy(m => m.id).ToList(); carlistProduct.Clear(); string strReturn = "---"; foreach (var item in menuModelProduct) { carlistProduct.Add(new SelectListItem { Text = item.Name, Value = item.id.ToString() }); StringClass.DropDownListFor(item.id, carlistProduct, strReturn); strReturn = "---"; } var ListNews = db.tblConnectNews.Where(p => p.idNew == id).ToList(); List <int> mang = new List <int>(); for (int i = 0; i < ListNews.Count; i++) { mang.Add(int.Parse(ListNews[i].idCate.ToString())); } ViewBag.MutilMenu = new MultiSelectList(carlistProduct, "Value", "Text", mang); return(View(tblnews)); } else { return(Redirect("/Users/Erro")); } }
public ActionResult DeleteConfirmed(int id) { tblNew tblNew = db.tblNews.Find(id); db.tblNews.Remove(tblNew); db.SaveChanges(); return(RedirectToAction("Index")); }
public void InsertNews(tblNew tblnew) { if (tblnew != null && tblnew.ID != null && !tblnew.ID.Equals(Guid.Empty)) { tblnew.PostedDate = DateTime.Now; tblnew.CreatedDate = DateTime.Now; _dataContext.tblNews.InsertOnSubmit(tblnew); _dataContext.SubmitChanges(); } }
public ActionResult Create(tblNew tblnews, FormCollection Collection, string id, int[] MutilMenu) { if ((Request.Cookies["Username"] == null)) { return(RedirectToAction("LoginIndex", "Login")); } string nidCate = Collection["drMenu"]; if (nidCate != "") { tblnews.idCate = int.Parse(nidCate); int idcate = int.Parse(nidCate); tblnews.DateCreate = DateTime.Now; tblnews.Tag = StringClass.NameToTag(tblnews.Name); tblnews.DateCreate = DateTime.Now; string idUser = Request.Cookies["Username"].Values["UserID"]; tblnews.idUser = int.Parse(idUser); StringClass.NewsCreateTag(tblnews.id, tblnews.Keyword); db.tblNews.Add(tblnews); db.SaveChanges(); var listprro = db.tblNews.OrderByDescending(p => p.id).Take(1).ToList(); clsSitemap.CreateSitemap("tin-tuc/" + tblnews.Tag, listprro[0].id.ToString(), "News"); #region [Updatehistory] Updatehistoty.UpdateHistory("Create News", Request.Cookies["Username"].Values["Username"].ToString(), Request.Cookies["Username"].Values["UserID"].ToString()); #endregion var ListNews = db.tblNews.OrderByDescending(p => p.id).Take(1).ToList(); int idNews = int.Parse(ListNews[0].id.ToString()); if (MutilMenu != null) { foreach (var idCate in MutilMenu) { tblConnectNew tblconnectnews = new tblConnectNew(); tblconnectnews.idCate = idCate; tblconnectnews.idNew = idNews; db.tblConnectNews.Add(tblconnectnews); db.SaveChanges(); } } if (Collection["btnSave"] != null) { Session["Thongbao"] = "<div class=\"alert alert-info alert1\">Bạn đã thêm tinthành công !<button class=\"close\" data-dismiss=\"alert\">×</button></div>"; return(Redirect("/Newsad/index?idCate=" + nidCate + "")); } if (Collection["btnSaveCreate"] != null) { Session["Thongbao"] = "<div class=\"alert alert-info\">Bạn đã thêm tin thành công, mời bạn thêm tin mới !<button class=\"close\" data-dismiss=\"alert\">×</button></div>"; return(Redirect("/Newsad/Create?id=" + nidCate + "")); } } return(View()); }
public ActionResult Edit([Bind(Include = "NewsId,UserId,Title,ShortDescription,Image,Content,CreatedDate,Status")] tblNew tblNew) { if (ModelState.IsValid) { db.Entry(tblNew).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.UserId = new SelectList(db.tblUsers, "UserId", "Username", tblNew.UserId); return(View(tblNew)); }
public ActionResult Edit(int?id) { if ((Request.Cookies["Username"] == null)) { return(RedirectToAction("LoginIndex", "Login")); } if (ClsCheckRole.CheckQuyen(5, 2, int.Parse(Request.Cookies["Username"].Values["UserID"])) == true) { Session["id"] = id.ToString(); Int32 ids = Int32.Parse(id.ToString()); tblNew tblnews = db.tblNews.Find(ids); if (tblnews == null) { return(HttpNotFound()); } var menuModel = db.tblGroupNews.Where(m => m.ParentID == null).OrderBy(m => m.id).ToList(); carlist.Clear(); string strReturns = "---"; foreach (var item in menuModel) { carlist.Add(new SelectListItem { Text = item.Name, Value = item.id.ToString() }); StringClass.DropDownListNews(item.id, carlist, strReturns); strReturns = "---"; } int idGroups = 0; if (tblnews.idCate != null) { idGroups = int.Parse(tblnews.idCate.ToString()); } ViewBag.drMenu = new SelectList(carlist, "Value", "Text", idGroups); var Manufacture = db.SelectListItem.Where(m => m.Active == true).OrderBy(m => m.Ord).ToList(); var listIdManu = db.tblConnectManuToNews.Where(p => p.idNews == id).Select(p => p.idManu).ToList(); var lstmanu = new List <SelectListItem>(); foreach (var item in Manufacture) { lstmanu.Add(new SelectListItem { Text = item.Name, Value = item.id.ToString() }); } ViewBag.mutilManu = new MultiSelectList(lstmanu, "Value", "Text", listIdManu); return(View(tblnews)); } else { return(Redirect("/Users/Erro")); } }
public ActionResult AddOrEditNews(int id = 0) { if (id == 0) { return(View("AddOrEditNews")); } else { tblNew tn = db.tblNews.Where(x => x.NewsId == id).FirstOrDefault(); return(View("AddOrEditNews", tn)); } }
public ActionResult NewsDetail(string tag) { int idNew; string Chuoi = tag; string[] Mang = Chuoi.Split('-'); int one = int.Parse(Mang.Length.ToString()); string chuoi1 = Mang[one - 1].ToString(); string[] Mang1 = chuoi1.Split('.'); idNew = int.Parse(Mang1[0].ToString()); tblNew tblnew = db.tblNews.Find(idNew); string chuoinew = ""; var listnew = db.tblNews.Where(p => p.idCate == tblnew.idCate && p.id != tblnew.id && p.Active == true).OrderByDescending(p => p.Ord).Take(3).ToList(); for (int i = 0; i < listnew.Count; i++) { chuoinew += "<a href=\"/2/" + listnew[i].Tag + "-" + listnew[i].id + ".aspx\" title=\"" + listnew[i].Name + "\"> - " + listnew[i].Name + "</a>"; } ViewBag.chuoinew = chuoinew; ViewBag.Title = "<title>" + tblnew.Title + "</title>"; ViewBag.dcTitle = "<meta name=\"DC.title\" content=\"" + tblnew.Title + "\" />"; ViewBag.Description = "<meta name=\"description\" content=\"" + tblnew.Description + "\"/>"; ViewBag.Keyword = "<meta name=\"keywords\" content=\"" + tblnew.Keyword + "\" /> "; ViewBag.canonical = "<link rel=\"canonical\" href=\"http://Thietbivesinhcaesar.vn/2/" + tblnew.Tag + "-" + tblnew.id + ".aspx\" />"; string meta = ""; meta += "<meta itemprop=\"name\" content=\"" + tblnew.Name + "\" />"; meta += "<meta itemprop=\"url\" content=\"" + Request.Url.ToString() + "\" />"; meta += "<meta itemprop=\"description\" content=\"" + tblnew.Description + "\" />"; meta += "<meta itemprop=\"image\" content=\"http://Thietbivesinhcaesar.vn" + tblnew.Images + "\" />"; meta += "<meta property=\"og:title\" content=\"" + tblnew.Title + "\" />"; meta += "<meta property=\"og:type\" content=\"product\" />"; meta += "<meta property=\"og:url\" content=\"" + Request.Url.ToString() + "\" />"; meta += "<meta property=\"og:image\" content=\"http://Thietbivesinhcaesar.vn" + tblnew.Images + "\" />"; meta += "<meta property=\"og:site_name\" content=\"http://Thietbivesinhcaesar.vn\" />"; meta += "<meta property=\"og:description\" content=\"" + tblnew.Description + "\" />"; meta += "<meta property=\"fb:admins\" content=\"\" />"; ViewBag.Meta = meta; var Groupnews = db.tblGroupNews.First(p => p.id == tblnew.idCate); int idCate = Groupnews.id; ViewBag.nUrl = "<a href=\"/\" title=\"Trang chu\" rel=\"nofollow\"><span class=\"iCon\"></span>Trang chủ</a> / " + UrlNews(idCate) + " " + tblnew.Name; tblConfig tblconfig = db.tblConfigs.FirstOrDefault(); if (tblconfig.Coppy == true) { ViewBag.coppy = " <script src=\"/Scripts/disable-copyright.js\"></script> <link href=\"/Content/Display/Css/Coppy.css\" rel=\"stylesheet\" />"; } return(View(tblnew)); }
// GET: GeneralNews/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblNew tblNew = db.tblNews.Find(id); if (tblNew == null) { return(HttpNotFound()); } return(View(tblNew)); }
public List <accccc> GetDichVu() { int from = 1; int to = 3; int ID = 61; List <dynamic> arr = new List <dynamic>(); arr.AddRange((from p in sql.tblNews where p.STATUS == 1 && (p.CATEGORYID.IndexOf(ID + ";") > -1 || p.CATEGORYID.Replace(";", "").Equals(ID.ToString()))select new { id = p.ID, time = p.CREATED_DATE, type = 0 }).OrderByDescending(d => d.time).Take(to)); arr.AddRange((from p in sql.tblQuizs where p.Status == 1 select new { id = p.ID, time = p.CreateDate, type = 1 }).OrderByDescending(d => d.time).Take(to)); arr = arr.OrderByDescending(d => d.time).ToList(); List <accccc> arrRe = new List <accccc>(); to = to > arr.Count ? arr.Count : to; for (int i = from - 1; i < to; i++) { dynamic nData = arr[i]; accccc _data = new accccc(); int nId = Convert.ToInt32(nData.id); if (nData.type == 0) { tblNew _new = (from p in sql.tblNews where p.ID == nId select p).FirstOrDefault(); _data.ID = _new.ID; _data.CATEGORYNAME = "0"; _data.TITLE = _new.TITLE; _data.IMAGE = _new.IMAGE; _data.SUMMARY = _new.SUMMARY; _data.CREATED_DATE = _new.CREATED_DATE; _data.RowNumber = to - (to - i); _data.RecordsTotal = to + 1; arrRe.Add(_data); } else { tblQuiz _quiz = (from p in sql.tblQuizs where p.ID == nId select p).FirstOrDefault(); _data.ID = _quiz.ID; _data.CATEGORYNAME = "quiz"; _data.TITLE = _quiz.Title; _data.IMAGE = _quiz.Img; _data.SUMMARY = _quiz.Des; _data.CREATED_DATE = _quiz.CreateDate; _data.RowNumber = to - (to - i); _data.RecordsTotal = to + 1; arrRe.Add(_data); } } return(arrRe); }
public PartialViewResult Tintuclienquan(string tag) { tblNew tblnew = db.tblNews.First(p => p.Tag == tag); int idcate = int.Parse(tblnew.idCate.ToString()); string chuoi = ""; var listnew = db.tblNews.Where(p => p.idCate == idcate && p.Active == true && p.Tag != tag).OrderByDescending(p => p.DateCreate).Take(10).ToList(); for (int i = 0; i < listnew.Count; i++) { chuoi += " <h3><a href=\"/3/" + listnew[i].Tag + "\" rel=\"nofollow\" title=\"" + listnew[i].Name + "\">" + listnew[i].Name + " </a></h3> "; } ViewBag.chuoi = chuoi; return(PartialView()); }
// GET: GeneralNews/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblNew tblNew = db.tblNews.Find(id); if (tblNew == null) { return(HttpNotFound()); } ViewBag.UserId = new SelectList(db.tblUsers, "UserId", "Username", tblNew.UserId); return(View(tblNew)); }
public ActionResult Edit(int id, tblNew news) { try { // TODO: Add update logic here using (var db = new CheeseWorld_DatabaseEntities1()) { db.Entry(news).State = System.Data.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } } catch { return(View()); } }
public ActionResult Create(tblNew news) { try { // TODO: Add insert logic here using (var db = new CheeseWorld_DatabaseEntities1()) { db.tblNews.Add(news); db.SaveChanges(); } return(RedirectToAction("Index")); } catch { return(View()); } }
public bool DeleteById(int id) { using (var db = new ModelDbContext()) { if (!db.tblNews.Any(p => p.Id == id)) { return(false); } var item = new tblNew() { Id = id }; db.tblNews.Attach(item); db.tblNews.Remove(item); return(db.SaveChanges() > 0); } }
public ActionResult NewsDetail(string tag, string id) { int nId = int.Parse(id); tblNew tblnew = db.tblNews.First(p => p.id == nId); string chuoinew = ""; var listnew = db.tblNews.Where(p => p.idCate == tblnew.idCate && p.id != tblnew.id && p.Active == true).OrderByDescending(p => p.Ord).Take(3).ToList(); for (int i = 0; i < listnew.Count; i++) { chuoinew += "<a href=\"/News/" + listnew[i].Tag + "-" + listnew[i].id + ".aspx\" title=\"" + listnew[i].Name + "\"> - " + listnew[i].Name + "</a>"; } ViewBag.chuoinew = chuoinew; ViewBag.Title = "<title>" + tblnew.Title + "</title>"; ViewBag.dcTitle = "<meta name=\"DC.title\" content=\"" + tblnew.Title + "\" />"; ViewBag.Description = "<meta name=\"description\" content=\"" + tblnew.Description + "\"/>"; ViewBag.Keyword = "<meta name=\"keywords\" content=\"" + tblnew.Keyword + "\" /> "; ViewBag.canonical = "<link rel=\"canonical\" href=\"http://Binhnuocnonglanhariston.vn/News/" + StringClass.NameToTag(tblnew.Tag) + "-" + tblnew.id + ".aspx\" />"; string meta = ""; meta += "<meta itemprop=\"name\" content=\"" + tblnew.Name + "\" />"; meta += "<meta itemprop=\"url\" content=\"" + Request.Url.ToString() + "\" />"; meta += "<meta itemprop=\"description\" content=\"" + tblnew.Description + "\" />"; meta += "<meta itemprop=\"image\" content=\"" + tblnew.Images + "\" />"; meta += "<meta property=\"og:title\" content=\"" + tblnew.Title + "\" />"; meta += "<meta property=\"og:type\" content=\"product\" />"; meta += "<meta property=\"og:url\" content=\"" + Request.Url.ToString() + "\" />"; meta += "<meta property=\"og:image\" content=\"" + tblnew.Images + "\" />"; meta += "<meta property=\"og:site_name\" content=\"http://Binhnuocnonglanhariston.vn\" />"; meta += "<meta property=\"og:description\" content=\"" + tblnew.Description + "\" />"; meta += "<meta property=\"fb:admins\" content=\"\" />"; ViewBag.Meta = meta; int idcate = int.Parse(tblnew.idCate.ToString()); ViewBag.nUrl = "<a href=\"http://BinhnuocnonglanhAriston.vn\" title=\"Trang chu\" rel=\"nofollow\"><span class=\"iCon\"></span>Trang chủ</a> /" + UrlNews(idcate); string coppy = ""; var tblconfig = db.tblConfigs.First(); if (tblconfig.Coppy == true) { coppy += "<script src=\"/Scripts/disable-copyright.js\"></script>"; coppy += "<link href=\"/Content/Display/Css/Coppy.css\" rel=\"stylesheet\" />"; } ViewBag.coppy = coppy; return(View(tblnew)); }
public bool InsertNews(tblNew obj) { try { if (obj != null) { dbContext.tblNews.InsertOnSubmit(obj); dbContext.SubmitChanges(); return(true); } else { return(false); } } catch (Exception ex) { return(false); } }
public bool UpdateView(int id) { using (var db = new ModelDbContext()) { var item = new tblNew() { Id = id }; if (db.tblNews.Any(p => p.Id == id)) { db.tblNews.Attach(item); item.View++; } else { return(false); } return(db.SaveChanges() > 0); } }
public ActionResult Delete(int id) { if (IsLogin()) { if (id == 0) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblNew tblNew = ExecuteNews.News.GetById(SessionDecentralize(), id).Data; if (tblNew == null) { return(HttpNotFound()); } return(View(tblNew)); } else { return(RedirectToAction("Login", "User")); } }
public ActionResult Delete(int id, string name = "") { if (name == "News") { tblNew news = db.tblNews.Where(x => x.NewsId == id).FirstOrDefault(); System.IO.File.Delete(Path.Combine(Server.MapPath("~/Images/News/"), news.Photo)); db.tblNews.Remove(news); db.SaveChanges(); return(RedirectToAction("News", "Admin")); } if (name == "Banner") { tblBanner add = db.tblBanners.Where(x => x.BannerId == id).FirstOrDefault(); System.IO.File.Delete(Path.Combine(Server.MapPath("~/Images/Banner/"), add.Photo)); db.tblBanners.Remove(add); db.SaveChanges(); return(RedirectToAction("Banner", "Admin")); } return(RedirectToAction("Index", "Opening")); }
// GET: Convert public ActionResult Index() { var listProduct = db.tblNews.ToList(); foreach (var item in listProduct) { int id = item.id; tblNew tblproduct = db.tblNews.Find(id); tblproduct.Tag = StringClass.NameToTag(tblproduct.Name); db.SaveChanges(); } var listProducts = db.tblGroupNews.ToList(); foreach (var item in listProducts) { int id = item.id; tblGroupNew tblproduct = db.tblGroupNews.Find(id); tblproduct.Tag = StringClass.NameToTag(tblproduct.Name); db.SaveChanges(); } var listProductss = db.tblAgencies.ToList(); foreach (var item in listProductss) { int id = item.id; tblAgency tblproduct = db.tblAgencies.Find(id); tblproduct.Tag = StringClass.NameToTag(tblproduct.Name); db.SaveChanges(); } var listProducstsss = db.tblGroupAgencies.ToList(); foreach (var item in listProducstsss) { int id = item.id; tblGroupAgency tblproduct = db.tblGroupAgencies.Find(id); tblproduct.Tag = StringClass.NameToTag(tblproduct.Name); db.SaveChanges(); } return(View()); }
public void UpdateNews(tblNew tblnew) { if (tblnew != null && tblnew.ID != null && !tblnew.ID.Equals(Guid.Empty)) { var query = _dataContext.tblNews.Where("ID.ToString()=@0", tblnew.ID.ToString()); if (query != null && query.ToList().Count > 0) { query.First().TitleVN = tblnew.TitleVN; query.First().TitleEN = tblnew.TitleEN; query.First().Type = tblnew.Type; query.First().ContentVN = tblnew.ContentVN; query.First().ContentEN = tblnew.ContentEN; query.First().Image = tblnew.Image; query.First().PostedBy = tblnew.PostedBy; query.First().SubjectEN = tblnew.SubjectEN; query.First().SubjectVN = tblnew.SubjectVN; query.First().EndedBy = tblnew.EndedBy; query.First().EndedDate = tblnew.EndedDate; _dataContext.SubmitChanges(); } } }
public tblNew GetNewsByID(Guid newID, bool isEN) { if (isEN) { var query = _dataContext.tblNews.Where("ID.ToString()=@0 and ContentEN != null", newID.ToString()); if (query.ToList().Count() > 0) { tblNew tblnew = query.ToList().First(); return(tblnew); } } else { var query = _dataContext.tblNews.Where("ID.ToString()=@0 and ContentVN != null", newID.ToString()); if (query.ToList().Count() > 0) { tblNew tblnew = query.ToList().First(); return(tblnew); } } return(null); }
public ActionResult Edit([Bind(Include = "Id,Group,Titles,Describe,Content,Img,Order,View")] tblNew tblNew) { if (IsLogin()) { if (SessionDecentralize() == (short)NewsProject.Commons.Decentralize.Admin) { if (ModelState.IsValid) { tblNew.ImgResizer = tblNew.Img.Replace("/Uploads", "/Uploads/_thumbs"); tblNew.ModifyDate = DateTime.Now; db.Entry(tblNew).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tblNew)); } return(View("Index")); } else { return(RedirectToAction("Login", "User")); } }