public ActionResult ViewNewsDetails(string Id) { var newsId = Convert.ToInt64(new Md5Ecryption().DecryptPrimaryKey(Id, true)); if (ModelState.IsValid) { var news = new NewsDataFactory().GetNewsById(Convert.ToInt64(newsId)); var newsUpdate = _db.News.Find(newsId); newsUpdate.NewsView = newsUpdate.NewsView + 1; _db.Entry(newsUpdate).State = EntityState.Modified; _db.SaveChanges(); return(View("ViewNewsDetails", news)); } var newsToRedirect = _db.News.Find(newsId); return(View(newsToRedirect)); }
public ActionResult Edit([Bind(Include = "rssID,NewspaperMenuId,Title,IconRss,IconSave,Link,Description,Summary,rssDate,DateInput,HotNews,PopularNews,MoreNews,Effect,MaNV")] rssNew rssNew) { if (ModelState.IsValid) { db.Entry(rssNew).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(rssNew)); }
public ActionResult Edit([Bind(Include = "NewsId,Title,Content,Image,CreatedById")] News news, FormCollection collectedValues) { var user = Session["bhuinfologgedinuser"] as AppUser; if (ModelState.IsValid) { if (user != null) { news.LastModifiedById = user.AppUserId; news.DateLastModified = DateTime.Now; news.DateCreated = Convert.ToDateTime(collectedValues["date"]); news.NewsCategoryId = long.Parse(collectedValues["NewsCategory.NewsCategoryId"]); news.CreatedById = long.Parse(collectedValues["createdby"]); news.NewsView = int.Parse(collectedValues["newsview"]); news.Likes = int.Parse(collectedValues["likes"]); news.Dislikes = int.Parse(collectedValues["dislikes"]); news.LastModifiedById = user.AppUserId; news.Image = collectedValues["image"]; news.SecondImage = news.SecondImage != null ? collectedValues["secondimage"] : null; news.ThirdImage = news.ThirdImage != null ? collectedValues["thirdimage"] : null; _db.Entry(news).State = EntityState.Modified; _db.SaveChanges(); TempData["news"] = "This article has been modified Succesfully!"; TempData["notificationtype"] = NotificationType.Success.ToString(); } else { TempData["login"] = "******"; TempData["notificationtype"] = NotificationType.Info.ToString(); return(RedirectToAction("Index")); } return(RedirectToAction("Index")); } return(View(news)); }
public JsonResult NewsEdit(NewsModel model) { var response = new JsonResponse(); var newModel = new News(); try { using (var ctx = new NewsDataContext()) { newModel = Mapper.Map <NewsModel, News>(model); ctx.Entry(newModel).State = EntityState.Modified; response.Success = true; response.Result = "Success"; ctx.SaveChanges(); } } catch (Exception e) { response.Result = "Error" + e.Message; } RedirectToAction("Index"); return(Json(response)); }