// GET: News public ActionResult Index() { var news = artSer.GetMany(); var games = artgamesSer.GetMany(); var articles = arrticles.GetMany(); var Commentednews = artSer.getMostCommented(); List <newsViewModels> gVM = new List <newsViewModels>(); foreach (var item in news) { newsViewModels gm = new newsViewModels() { idArticle = item.idArticle, DTYPE = item.DTYPE, name = item.name, description = item.description, link_img = item.link_img, date = item.date, }; gVM.Add(gm); } ViewBag.Article = arrticles.GetMany().Count(); ViewBag.games = artgamesSer.GetMany().Count(); ViewBag.news = artSer.GetMany().Count(); ViewBag.commnewss = artSer.getMostCommented().Count(); return(View(gVM)); }
public ActionResult EditCoverPicture(newsViewModels itemm, HttpPostedFileBase idFile, HttpPostedFileBase idFilee) { if (ModelState.IsValid) { string uniqueName = Guid.NewGuid().ToString() + System.IO.Path.GetExtension(idFile.FileName); var uploadUrl = Server.MapPath("~/Content/img"); idFile.SaveAs(Path.Combine(uploadUrl, uniqueName)); var imgPath = "~/Content/img" + uniqueName; itemm.link_img = "img\\" + uniqueName; news g = artSer.GetById(itemm.idArticle); g.link_img = itemm.link_img; artSer.Update(g); return(RedirectToAction("Edit", new { id = itemm.idArticle })); } else { return(View()); } }
public ActionResult EditCoverPicture(int id) { news itemm = new news(); itemm = artSer.GetById(id); newsViewModels g1 = new newsViewModels() { idArticle = itemm.idArticle, link_img = itemm.link_img, link_imgg = itemm.link_imgg, }; return(View(g1)); }
// GET: News/Delete/5 public ActionResult Delete(int id) { news item = new news(); item = artSer.GetById(id); newsViewModels g = new newsViewModels() { idArticle = item.idArticle, DTYPE = item.DTYPE, name = item.name, description = item.description, link_img = item.link_img, date = item.date, }; return(View(g)); }
// GET: News/Edit/5 public ActionResult Edit(int id) { news item = new news(); item = artSer.GetById(id); newsViewModels g = new newsViewModels() { idArticle = item.idArticle, name = item.name, description = item.description, link_img = item.link_img, link_imgg = item.link_imgg, }; return(View(g)); }
// GET: News/Details/5 public ActionResult Details(int id) { news item = artSer.GetById(id); newsViewModels g = new newsViewModels() { idArticle = item.idArticle, name = item.name, date = item.date, description = item.description, link_img = item.link_img, link_imgg = item.link_imgg, commentts = item.commentts, }; return(View(g)); }
public ActionResult Create(newsViewModels item, HttpPostedFileBase idFile, HttpPostedFileBase idFilee) { if (ModelState.IsValid) { //upload de l'image // var path = Path.Combine(Server.MapPath("~/Content/img"), idFile.FileName); // idFile.SaveAs(path); // g.link_imgg = "img\\"+idFile.FileName; // g.link_img= "img\\" + idFilee.FileName; string uniqueName = Guid.NewGuid().ToString() + System.IO.Path.GetExtension(idFile.FileName); var uploadUrl = Server.MapPath("~/Content/img"); idFile.SaveAs(Path.Combine(uploadUrl, uniqueName)); string uniqueNamee = Guid.NewGuid().ToString() + System.IO.Path.GetExtension(idFilee.FileName); var uploadUrll = Server.MapPath("~/Content/img"); idFilee.SaveAs(Path.Combine(uploadUrll, uniqueNamee)); item.link_imgg = "img\\" + uniqueName; item.link_img = "img\\" + uniqueNamee; item.DTYPE = "news"; item.date = DateTime.UtcNow; // artSer.AddGames(g); news n = new news() { idArticle = item.idArticle, name = item.name, description = item.description, link_imgg = item.link_imgg, link_img = item.link_img, DTYPE = item.DTYPE, date = item.date, }; artSer.Add(n); return(RedirectToAction("Index")); } else { return(View()); } }
public ActionResult Edit(newsViewModels item, HttpPostedFileBase idFile, HttpPostedFileBase idFilee) { if (ModelState.IsValid) { item.date = DateTime.Now; news g = artSer.GetById(item.idArticle); g.name = item.name; g.description = item.description; g.date = item.date; artSer.Update(g); return(RedirectToAction("Index")); } else { return(View()); } }
public ActionResult getMostCommented() { var news = artSer.getMostCommented().ToArray(); var TotalGames = artSer.GetMany().ToArray(); var comm = commSer.getDateOfComm().ToArray(); var totalFund = artSer.GetMany().ToArray(); // var totalFund = artSer.GetMany().ToArray(); // var comm = commSer.getDateOfComm().ToArray(); List <newsViewModels> gVM = new List <newsViewModels>(); foreach (var item in news) { newsViewModels gm = new newsViewModels() { idArticle = item.idArticle, DTYPE = item.DTYPE, name = item.name, description = item.description, link_img = item.link_img, date = item.date, commentts = item.commentts, }; ViewBag.newsCount = news.Count(); ViewBag.TotalCount = TotalGames.Count(); ViewBag.notcommented = TotalGames.Count() - news.Count(); ViewBag.usersComm = users.getUsersComments().Count(); ViewBag.totalUsers = users.GetMany().Count(); ViewBag.NonActiveUsers = users.GetMany().Count() - users.getUsersComments().Count(); var comms1 = commSer.GetCommentsNewsByMonth(1).ToArray(); var comms2 = commSer.GetCommentsNewsByMonth(2).ToArray(); var comms3 = commSer.GetCommentsNewsByMonth(3).ToArray(); var comms4 = commSer.GetCommentsNewsByMonth(4).ToArray(); var comms5 = commSer.GetCommentsNewsByMonth(5).ToArray(); var comms6 = commSer.GetCommentsNewsByMonth(6).ToArray(); var comms7 = commSer.GetCommentsNewsByMonth(7).ToArray(); var comms8 = commSer.GetCommentsNewsByMonth(8).ToArray(); var comms9 = commSer.GetCommentsNewsByMonth(9).ToArray(); var comms10 = commSer.GetCommentsNewsByMonth(10).ToArray(); var comms11 = commSer.GetCommentsNewsByMonth(11).ToArray(); var comms12 = commSer.GetCommentsNewsByMonth(12).ToArray(); ViewBag.nbComm1 = comms1.Count(); ViewBag.nbComm2 = comms2.Count(); ViewBag.nbComm3 = comms3.Count(); ViewBag.nbComm4 = comms4.Count(); ViewBag.nbComm5 = comms5.Count(); ViewBag.nbComm6 = comms6.Count(); ViewBag.nbComm7 = comms7.Count(); ViewBag.nbComm8 = comms8.Count(); ViewBag.nbComm9 = comms9.Count(); ViewBag.nbComm10 = comms10.Count(); ViewBag.nbComm11 = comms11.Count(); ViewBag.nbComm12 = comms12.Count(); gVM.Add(gm); } //CommentViewModels cm = new CommentViewModels(); //ViewBag.gmCount = games.Count(); //ViewBag.TotalCount = TotalGames.Count(); //ViewBag.notcommented = TotalGames.Count() - games.Count(); //ViewBag.usersComm = users.getUsersComments().Count(); //ViewBag.totalUsers = users.GetMany().Count(); //ViewBag.NonActiveUsers = users.GetMany().Count() - users.getUsersComments().Count(); //var comms1 = commSer.GetCommentsByMonth(1).ToArray(); //var comms2 = commSer.GetCommentsByMonth(2).ToArray(); //var comms3 = commSer.GetCommentsByMonth(3).ToArray(); //var comms4 = commSer.GetCommentsByMonth(4).ToArray(); //var comms5 = commSer.GetCommentsByMonth(5).ToArray(); //var comms6 = commSer.GetCommentsByMonth(6).ToArray(); //var comms7 = commSer.GetCommentsByMonth(7).ToArray(); //var comms8 = commSer.GetCommentsByMonth(8).ToArray(); //var comms9 = commSer.GetCommentsByMonth(9).ToArray(); //var comms10 = commSer.GetCommentsByMonth(10).ToArray(); //var comms11 = commSer.GetCommentsByMonth(11).ToArray(); //var comms12 = commSer.GetCommentsByMonth(12).ToArray(); //ViewBag.nbComm1 = comms1.Count(); //ViewBag.nbComm2 = comms2.Count(); //ViewBag.nbComm3 = comms3.Count(); //ViewBag.nbComm4 = comms4.Count(); //ViewBag.nbComm5 = comms5.Count(); //ViewBag.nbComm6 = comms6.Count(); //ViewBag.nbComm7 = comms7.Count(); //ViewBag.nbComm8 = comms8.Count(); //ViewBag.nbComm9 = comms9.Count(); //ViewBag.nbComm10 = comms10.Count(); //ViewBag.nbComm11 = comms11.Count(); //ViewBag.nbComm12 = comms12.Count(); return(View(gVM)); }