//Blog Ekleme -Post public ActionResult blogadd(blogpost post, HttpPostedFileBase foto, blogviewmodel bvm) { if (online() == false) { return(RedirectToAction("Login", "Security")); } try { WebImage img = new WebImage(foto.InputStream); FileInfo fotoinfo = new FileInfo(foto.FileName); string newfoto = Guid.NewGuid().ToString() + fotoinfo.Extension; img.Resize(600, 400); img.Save("~/Image/blogImage/" + newfoto); post.postImagePath = "~/Image/blogImage/" + newfoto; post.categoryId = Convert.ToInt32(bvm.categorylist[0]); post.postDate = Convert.ToDateTime(DateTime.Now.ToShortDateString()); db.blogposts.Add(post); db.SaveChanges(); var b = db.blogposts.Where(x => x.postTitle == post.postTitle && x.postImagePath == post.postImagePath && x.postDescription == post.postDescription).FirstOrDefault(); process(b.postid, "Blog", "Eklendi"); return(RedirectToAction("blog", "Admin")); } catch (Exception ex) { return(RedirectToAction("Error", "Home", new { ex = ex })); } }
//Blog Ekleme-Get public ActionResult blogadd() { if (online() == false) { return(RedirectToAction("Login", "Security")); } blogviewmodel bv = new blogviewmodel(); bv.category = db.categories.ToList(); return(View(bv)); }
//Blog-Get public ActionResult blog(int?id) { if (online() == false) { return(RedirectToAction("Login", "Security")); } if (id != null) { ViewBag.mesaj = "Yetkiniz Yok"; } blogviewmodel bv = new blogviewmodel(); bv.blog = db.blogposts.ToList(); bv.category = db.categories.ToList(); return(View(bv)); }