public ActionResult AddArticle(ArticleVM model) { ArticleVM vmodel = new ArticleVM(); vmodel.drpCategories = DrpServices.getDrpCategories(); if (ModelState.IsValid) { Article article = new Article(); article.CategoryID = model.CategoryID; article.Content = model.Content; article.Title = model.Title; db.Articles.Add(article); db.SaveChanges(); ViewBag.submitStatus = 1; return(View(vmodel)); } else { ViewBag.submitStatus = 2; return(View(model)); } }
public ActionResult AddBlogPost() { BlogPostVM model = new BlogPostVM(); model.drpCategories = DrpServices.getDrpCategories(); return(View(model)); }
// GET: Admin/Article public ActionResult AddArticle() { ArticleVM model = new ArticleVM(); model.drpCategories = DrpServices.getDrpCategories(); return(View(model)); }
public ActionResult UpdateBlogPost(int id) { var blogpost = db.BlogPosts.FirstOrDefault(x => x.ID == id); var model = new BlogPostVM(); model.CategoryID = blogpost.CategoryID; model.Title = blogpost.Title; model.Content = blogpost.Content; model.drpCategories = DrpServices.getDrpCategories(); return(View(model)); }
public ActionResult UpdateArticle(int id) { Article article = db.Articles.FirstOrDefault(x => x.ID == id); ArticleVM model = new ArticleVM(); model.CategoryID = article.CategoryID; model.Title = article.Title; model.Content = article.Content; model.drpCategories = DrpServices.getDrpCategories(); return(View(model)); }
public ActionResult AddBlogPost(BlogPostVM model) { BlogPostVM vmodel = new BlogPostVM(); vmodel.drpCategories = DrpServices.getDrpCategories(); if (ModelState.IsValid) { string filename = ""; foreach (string name in Request.Files) { model.PostImage = Request.Files[name]; string ext = Path.GetExtension(model.PostImage.FileName); if (ext == ".jpg" || ext == ".jpeg" || ext == ".png") { string uniqnumber = Guid.NewGuid().ToString(); filename = uniqnumber + model.PostImage.FileName; model.PostImage.SaveAs(Server.MapPath("~/Content/Img/BlogPostResim/" + filename)); } else { ViewBag.hata = "resim formatı uygun degildir."; } } BlogPost blogpost = new BlogPost(); blogpost.CategoryID = model.CategoryID; blogpost.Title = model.Title; blogpost.Content = model.Content; blogpost.ImagePath = filename; db.BlogPost.Add(blogpost); db.SaveChanges(); ViewBag.IslemDurum = 1; return(View(vmodel)); } else { ViewBag.IslemDurum = 2; return(View(vmodel)); } }
public ActionResult AddBlogPost(BlogPostVM model) { BlogPostVM vmodel = new BlogPostVM(); vmodel.drpCategories = DrpServices.getDrpCategories(); if (ModelState.IsValid) { var blogpost = new BlogPost(); blogpost.Title = model.Title; blogpost.CategoryID = model.CategoryID; blogpost.Content = model.Content; foreach (string name in Request.Files) { model.PostImage = Request.Files[name]; string ext = Path.GetExtension(model.PostImage.FileName); if (ext == ".jpg" || ext == ".jpeg" || ext == "*.png" || ext == "*.gif") { string uniqnumber = Guid.NewGuid().ToString().Replace("-", ""); string filename = uniqnumber + model.PostImage.FileName; string TamYol = "~/Areas/Admin/Content/Site/images/blogpost/" + filename; //Request.Files[0].SaveAs(Server.MapPath(TamYol)); model.PostImage.SaveAs(Server.MapPath(TamYol)); blogpost.ImagePath = filename; } } db.BlogPosts.Add(blogpost); db.SaveChanges(); ViewBag.IslemDurum = 1; return(View(vmodel)); } else { ViewBag.IslemDurum = 2; return(View(vmodel)); } }
public ActionResult UpdateArticle(ArticleVM model) { model.drpCategories = DrpServices.getDrpCategories(); if (ModelState.IsValid) { Article article = db.Articles.FirstOrDefault(x => x.ID == model.ID); article.CategoryID = model.CategoryID; article.Title = model.Title; article.Content = model.Content; db.SaveChanges(); ViewBag.SubmitStatus = 1; return(View(model)); } else { ViewBag.SubmitStatus = 2; return(View(model)); } }
public ActionResult UpdateBlogPost(BlogPostVM model) { model.drpCategories = DrpServices.getDrpCategories(); if (ModelState.IsValid) { BlogPost blogpost = db.BlogPosts.FirstOrDefault(x => x.ID == model.ID); blogpost.CategoryID = model.CategoryID; blogpost.Title = model.Title; blogpost.Content = model.Content; db.SaveChanges(); ViewBag.IslemDurum = 1; return(View(model)); } else { ViewBag.IslemDurum = 2; return(View(model)); } }