public async Task <ActionResult> Create([Bind(Include = "Id,RefBlogKategoriId,Baslik,Yazi,Tarih,Yazar,Seo")] BlogYazi blogYazi) { if (ModelState.IsValid) { try { db.BlogYazis.Add(blogYazi); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Response.Write(string.Format("Entity türü \"{0}\" şu hatalara sahip \"{1}\" Geçerlilik hataları:", eve.Entry.Entity.GetType().Name, eve.Entry.State)); foreach (var ve in eve.ValidationErrors) { Response.Write(string.Format("- Özellik: \"{0}\", Hata: \"{1}\"", ve.PropertyName, ve.ErrorMessage)); } Response.End(); } return(View()); } } ViewBag.RefBlogKategoriId = new SelectList(db.BlogKategoris, "Id", "BlogKategoriAdi", blogYazi.RefBlogKategoriId); return(View(blogYazi)); }
public async Task <ActionResult> DeleteConfirmed(int id) { BlogYazi blogYazi = await db.BlogYazis.FindAsync(id); db.BlogYazis.Remove(blogYazi); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
// GET: Blog/Edit/5 public ActionResult Edit(int id) { if (user == null) { return(RedirectToAction("Login", "Account")); } BlogYazi co = datas.BlogYazis.Where(t => t.id == id).FirstOrDefault(); return(View(co)); }
public async Task <ActionResult> Edit([Bind(Include = "Id,RefBlogKategoriId,Baslik,Yazi,Tarih,Yazar,Seo")] BlogYazi blogYazi) { if (ModelState.IsValid) { db.Entry(blogYazi).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.RefBlogKategoriId = new SelectList(db.BlogKategoris, "Id", "BlogKategoriAdi", blogYazi.RefBlogKategoriId); return(View(blogYazi)); }
// GET: Admin/BlogYazi/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BlogYazi blogYazi = await db.BlogYazis.FindAsync(id); if (blogYazi == null) { return(HttpNotFound()); } return(View(blogYazi)); }
// GET: Admin/BlogYazi/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BlogYazi blogYazi = await db.BlogYazis.FindAsync(id); if (blogYazi == null) { return(HttpNotFound()); } ViewBag.RefBlogKategoriId = new SelectList(db.BlogKategoris, "Id", "BlogKategoriAdi", blogYazi.RefBlogKategoriId); return(View(blogYazi)); }
// GET: Blog/Details/5 public ActionResult detay(int id) { BlogYazi blg = datas.BlogYazis.Where(t => t.id == id).FirstOrDefault(); List <yorumlar> yrm = datas.yorumlars.Where(t => t.blogid == id && t.satutus == 1).ToList(); Models.BlogViewMoldels blgg = new Models.BlogViewMoldels(); blgg.yrms = yrm; blgg.blogid = id; blgg.Baslik = blg.Baslik; blgg.aySira = blg.aySira; blgg.Content = blg.Content; blgg.folder = blg.folder; blgg.path = blg.path; return(View(blgg)); }
public ActionResult Edit(int id, FormCollection frm) { if (user == null) { return(RedirectToAction("Login", "Account")); } try { // TODO: Add update logic here BlogYazi blg = datas.BlogYazis.Where(t => t.id == id).FirstOrDefault(); blg.Baslik = frm["Baslik"].ToString(); blg.Content = frm["editor1"].ToString(); blg.tanitimYazi = frm["tanitimYazi"].ToString(); blg.tarih = DateTime.Now; blg.aySira = DateTime.Now.Month; if (Request.Files.Count > 0) { string path = Server.MapPath("/"); if (!string.IsNullOrEmpty(Request.Files["pic"].FileName)) { Request.Files["pic"].SaveAs(path + "BlogPics/" + Request.Files["pic"].FileName); } if (string.IsNullOrEmpty(Request.Files["pic"].FileName) == false) { blg.folder = "BlogPics/" + Request.Files["pic"].FileName; } } datas.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create(FormCollection frm) { if (user == null) { return(RedirectToAction("Login", "Account")); } BlogYazi blg = new BlogYazi(); blg.Baslik = frm["Baslik"].ToString(); blg.Content = frm["editor1"].ToString(); blg.tanitimYazi = frm["tanitim"].ToString(); blg.tarih = DateTime.Now; blg.aySira = DateTime.Now.Month; switch (DateTime.Now.Month) { case 1: blg.aylar = "Ocak"; break; case 2: blg.aylar = "Şubat"; break; case 3: blg.aylar = "Mart"; break; case 4: blg.aylar = "Nisan"; break; case 5: blg.aylar = "Mayıs"; break; case 6: blg.aylar = "Haziran"; break; case 7: blg.aylar = "Temmuz"; break; case 8: blg.aylar = "Ağustos"; break; case 9: blg.aylar = "Eylül"; break; case 10: blg.aylar = "Ekim"; break; case 11: blg.aylar = "Kasım"; break; case 12: blg.aylar = "Aralık"; break; default: break; } if (Request.Files.Count > 0) { string path = Server.MapPath("/"); blg.path = path; if (Directory.Exists(path + "/BlogPics") == false) { Directory.CreateDirectory(path + "BlogPics/"); } if (!string.IsNullOrEmpty(Request.Files["pic"].FileName)) { Request.Files["pic"].SaveAs(path + "BlogPics/" + Request.Files["pic"].FileName); } } blg.folder = string.IsNullOrEmpty(Request.Files["pic"].FileName) == true ? "" : " BlogPics/" + Request.Files["pic"].FileName; try { // TODO: Add insert logic here datas.BlogYazis.Add(blg); datas.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult yorumgnder(FormCollection frm) { int blgid = Convert.ToInt32(frm[0]); if (frm[2] != "") { if (frm[1] != "") { if (ModelState.IsValid) { yorumlar yrm = new yorumlar { mail = frm[1], content = frm[2], satutus = 2, blogid = Convert.ToInt32(frm[0]), date = DateTime.Now.Date, }; try { datas.yorumlars.Add(yrm); datas.SaveChanges(); ViewBag.mesaj = "Yorumunuz Başarıyla Kaydedilmiştir."; BlogYazi blg = datas.BlogYazis.Where(t => t.id == blgid).FirstOrDefault(); List <yorumlar> yorm = datas.yorumlars.Where(t => t.blogid == blgid && t.satutus == 1).OrderBy(t => t.id).ToList(); Models.BlogViewMoldels blgg = new Models.BlogViewMoldels(); blgg.yrms = yorm; blgg.blogid = blgid; blgg.Baslik = blg.Baslik; blgg.aySira = blg.aySira; blgg.Content = blg.Content; blgg.folder = blg.folder; blgg.path = blg.path; return(View("detay", blgg)); } catch (Exception ex) { ViewBag.mesaj = "Bilgilerinizi eksik veya hatalı girdiniz."; BlogYazi blg = datas.BlogYazis.Where(t => t.id == blgid).FirstOrDefault(); List <yorumlar> yorm = datas.yorumlars.Where(t => t.blogid == blgid && t.satutus == 1).OrderBy(t => t.id).ToList(); Models.BlogViewMoldels blgg = new Models.BlogViewMoldels(); blgg.yrms = yorm; blgg.blogid = blgid; blgg.Baslik = blg.Baslik; blgg.aySira = blg.aySira; blgg.Content = blg.Content; blgg.folder = blg.folder; blgg.path = blg.path; return(View("detay", blgg)); } } } } BlogYazi blggg = datas.BlogYazis.Where(t => t.id == blgid).FirstOrDefault(); List <yorumlar> yormm = datas.yorumlars.Where(t => t.blogid == blgid && t.satutus == 1).OrderBy(t => t.id).ToList(); Models.BlogViewMoldels blgggg = new Models.BlogViewMoldels(); blgggg.yrms = yormm; blgggg.blogid = blgid; blgggg.Baslik = blggg.Baslik; blgggg.aySira = blggg.aySira; blgggg.Content = blggg.Content; blgggg.folder = blggg.folder; blgggg.path = blggg.path; ViewBag.mesaj = "Bilgilerinizi eksik veya hatalı girdiniz."; return(View("detay", blgggg)); }