public ActionResult WriterEdits(WriterCommun wir, HttpPostedFileBase EWCImage) { if (EWCImage != null) { //拿到图片名称 string fileName = Path.GetFileName(EWCImage.FileName); //判断文件是否是图片 //string hz = Path.GetExtension(fileName);//.jpg if (fileName.EndsWith("jpg") || fileName.EndsWith("png") || fileName.EndsWith("gif") || fileName.EndsWith("jpeg") || fileName.EndsWith("JPG") || fileName.EndsWith("PNG") || fileName.EndsWith("GIF") || fileName.EndsWith("JPEG")) { //保存图片到项目文件夹中 EWCImage.SaveAs(Server.MapPath("~/Content/WriterImage/Commun/" + fileName)); //将图片文件名,绑定到该用户的Photo wir.WCImage = fileName; } else { return(Content("<script>alert('图片格式错误');history.go(-1);</script>")); } } wir.WCTime = DateTime.Now; db.Entry(wir).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", "WriterVNGLGD")); }
public ActionResult WriterCommunAdd(WriterCommun wic, HttpPostedFileBase WCImage) { if (WCImage != null) { //拿到图片名称 string fileName = Path.GetFileName(WCImage.FileName); //判断文件是否是图片 //string hz = Path.GetExtension(fileName);//.jpg if (fileName.EndsWith("jpg") || fileName.EndsWith("png") || fileName.EndsWith("gif") || fileName.EndsWith("jpeg") || fileName.EndsWith("JPG") || fileName.EndsWith("PNG") || fileName.EndsWith("GIF") || fileName.EndsWith("JPEG")) { //保存图片到项目文件夹中 WCImage.SaveAs(Server.MapPath("~/Content/WriterImage/Commun/" + fileName)); //将图片文件名,绑定到该用户的Photo wic.WCImage = fileName; } else { return(Content("<script>alert('图片格式错误');history.go(-1);</script>")); } } else { return(Content("<script>alert('未获取上传文件');history.go(-1);</script>")); } wic.WCTime = DateTime.Now; db.WriterCommun.Add(wic); db.SaveChanges(); return(RedirectToAction("Index", "WriterVNGLGD")); }
public ActionResult WriterWenZhang(int?WriterCoID) { WriterCommun writerCommun = db.WriterCommun.Find(WriterCoID); writerCommun.WCClick = writerCommun.WCClick + 1; db.SaveChanges(); ViewBag.writersWen = writerCommun; ViewBag.EssCommComm = db.WriterCommunComment.Where(a => a.WriterCommunID == WriterCoID).OrderByDescending(a => a.WCCTime).ToList(); List <News> news = db.News.OrderByDescending(a => a.NewsClick + (a.NewsComment.Count() * 2)).ToList(); List <News> newss = new List <News>(); foreach (var item in news) { DateTime timeHost1 = DateTime.Now; DateTime timeHost2 = item.NewsTime; var jian1 = timeHost1 - timeHost2; var jieguoHost = jian1.TotalHours; if (jieguoHost < 4) { newss.Add(item); } } ViewBag.renews = newss; ViewBag.Allnews = news; //ViewBag.renews = db.News.OrderByDescending(a => a.NewsClick + (a.NewsComment.Count() * 2)).ToList(); List <WriterCommun> writerCommuns = db.WriterCommun.OrderByDescending(a => a.WCClick + (a.WriterCommunComment.Count() * 2)).ToList(); List <WriterCommun> writerCommunss = new List <WriterCommun>(); foreach (var item in writerCommuns) { DateTime timeHost1 = DateTime.Now; DateTime timeHost2 = item.WCTime; var jian1 = timeHost1 - timeHost2; var jieguoHost = jian1.TotalHours; if (jieguoHost < 4) { writerCommunss.Add(item); } } ViewBag.rewritercommun = writerCommunss; ViewBag.Allwritercommun = writerCommuns; List <EssayCommun> essayCommuns = db.EssayCommun.OrderByDescending(a => a.ECClick + (a.EssayCommunComment.Count() * 2)).Where(a => a.ECState == 2).ToList(); List <EssayCommun> essayCommunss = new List <EssayCommun>(); foreach (var item in essayCommuns) { DateTime timeHost1 = DateTime.Now; DateTime timeHost2 = item.ECTime; var jian1 = timeHost1 - timeHost2; var jieguoHost = jian1.TotalHours; if (jieguoHost < 4) { essayCommunss.Add(item); } } ViewBag.reessaycommun = essayCommunss; ViewBag.Allessaycommun = essayCommuns; return(View()); }