public ActionResult MakaleSil(int GelenMakaleID) { RazorBlogContext _db = new RazorBlogContext(); Makale ToDel = _db.Makales.FirstOrDefault(x => x.MakaleID == GelenMakaleID); return(View(ToDel)); }
public bool MailGonder(string GelenMail, string Konu, string Mesaj) { try { RazorBlogContext _db = new RazorBlogContext(); string MailFrom = _db.SistemMails.FirstOrDefault(x => x.SistemMailID == 1).Mail; string MailPassword = _db.SistemMails.FirstOrDefault(x => x.SistemMailID == 1).Password; MailMessage Email = new MailMessage(); Email.From = new MailAddress(MailFrom); Email.IsBodyHtml = true; Email.Subject = Konu; Email.Body = Mesaj; Email.To.Add(MailFrom); Email.BodyEncoding = System.Text.Encoding.UTF8; string Host = "smtp.gmail.com"; string smtpUserName = MailFrom; string smtpPassword = MailPassword; int smtpPort = 465; SmtpClient smtp = new SmtpClient(Host, smtpPort); smtp.EnableSsl = true; smtp.Credentials = new System.Net.NetworkCredential(smtpUserName, smtpPassword); smtp.Send(Email); return(true); } catch (Exception) { return(false); } }
public ActionResult KategoriGoster(int ViewKategoriID, string StrSayfa) { int Sayfa = 0; if (StrSayfa == "" || StrSayfa == null) { Sayfa = 1; } else { Sayfa = Convert.ToInt32(StrSayfa); } int Kactan = 0; int Kacar = 2; RazorBlogContext _db = new RazorBlogContext(); int MakaleSayisi = _db.Makales.Where(x => x.Category.CategoryID == ViewKategoriID).Count(); double SayfaSayisi = Math.Ceiling((float)((1.0 * MakaleSayisi) / Kacar)); ViewBag.sayfasayisi = SayfaSayisi; ViewBag.sayfa = Sayfa; Kactan = ((Sayfa - 1) * Kacar); List <Makale> SayfaMakale = new List <Makale>(_db.Makales.Where(x => x.Category.CategoryID == ViewKategoriID).OrderByDescending(x => x.MakaleID).Skip(Kactan).Take(Kacar)); ViewBag.sayfamakale = SayfaMakale; ViewBag.AktifKategoriID = ViewKategoriID; return(View()); }
public ActionResult YorumlariYonet() { RazorBlogContext _db = new RazorBlogContext(); List <Yorum> YorumlarList = _db.Yorums.ToList(); return(View(YorumlarList)); }
public ActionResult MailGuncelle() { RazorBlogContext _db = new RazorBlogContext(); SistemMail ToEdit = _db.SistemMails.FirstOrDefault(x => x.SistemMailID == 1); return(View(ToEdit)); }
// GET: Home public ActionResult Index(string StrSayfa) { int Sayfa = 0; if (StrSayfa == "" || StrSayfa == null) { Sayfa = 1; } else { Sayfa = Convert.ToInt32(StrSayfa); } int Kactan = 0; int Kacar = 2; RazorBlogContext _db = new RazorBlogContext(); //List<Makale> MakalelerList = _db.Makales.ToList(); int MakaleSayisi = _db.Makales.Count(); double SayfaSayisi = Math.Ceiling((float)((1.0 * MakaleSayisi) / Kacar)); ViewBag.sayfasayisi = SayfaSayisi; ViewBag.sayfa = Sayfa; Kactan = ((Sayfa - 1) * Kacar); List <Makale> SayfaMakale = new List <Makale>(_db.Makales.OrderByDescending(x => x.MakaleID).Skip(Kactan).Take(Kacar)); ViewBag.sayfamakale = SayfaMakale; return(View()); }
public ActionResult KategoriSil(int KategoriID) { RazorBlogContext _db = new RazorBlogContext(); Category CategoryToDel = _db.Categories.FirstOrDefault(x => x.CategoryID == KategoriID); return(View(CategoryToDel)); }
public ActionResult KategoriGuncelle(int KategoriID) { RazorBlogContext _db = new RazorBlogContext(); Category ToEdit = _db.Categories.FirstOrDefault(x => x.CategoryID == KategoriID); return(View(ToEdit)); }
public ActionResult MakaleGoster(int ViewMakaleID) { RazorBlogContext _db = new RazorBlogContext(); Makale MakaleToShow = _db.Makales.FirstOrDefault(x => x.MakaleID == ViewMakaleID); return(View(MakaleToShow)); }
public List <Admin> TumAdminler() { RazorBlogContext _db = new RazorBlogContext(); List <Admin> AdminList = _db.Admins.ToList(); ViewBag.admins = AdminList; return(AdminList); }
public List <Category> TumKategoriler() { RazorBlogContext _db = new RazorBlogContext(); List <Category> KategorilerList = _db.Categories.ToList(); ViewBag.kategoriler = KategorilerList; return(KategorilerList); }
public ActionResult YorumSil(int ViewYorumID) { RazorBlogContext _db = new RazorBlogContext(); Yorum ToDelete = _db.Yorums.FirstOrDefault(x => x.YorumID == ViewYorumID); _db.Yorums.Remove(ToDelete); _db.SaveChanges(); return(RedirectToAction("YorumlariYonet")); }
public ActionResult YorumOnayiKaldir(int ViewYorumID) { RazorBlogContext _db = new RazorBlogContext(); Yorum ToEdit = _db.Yorums.FirstOrDefault(x => x.YorumID == ViewYorumID); ToEdit.OnayDurumu = 0; _db.SaveChanges(); return(RedirectToAction("YorumlariYonet")); }
public ActionResult MakaleSil(Makale m) { RazorBlogContext _db = new RazorBlogContext(); Makale ToDel = _db.Makales.FirstOrDefault(x => x.MakaleID == m.MakaleID); _db.Makales.Remove(ToDel); _db.SaveChanges(); return(RedirectToAction("MakaleListele")); }
public ActionResult KategoriSil(Category c) { RazorBlogContext _db = new RazorBlogContext(); Category ToDel = _db.Categories.FirstOrDefault(x => x.CategoryID == c.CategoryID); _db.Categories.Remove(ToDel); _db.SaveChanges(); return(RedirectToAction("KategoriListele")); }
public ActionResult KategoriGuncelle(Category c) { RazorBlogContext _db = new RazorBlogContext(); Category ToEdit = _db.Categories.FirstOrDefault(x => x.CategoryID == c.CategoryID); ToEdit.Name = c.Name; ToEdit.UrlName = c.UrlName; _db.SaveChanges(); return(RedirectToAction("KategoriListele")); }
public ActionResult Login(AdminHelper model) { if (ModelState.IsValid) { using (RazorBlogContext _db = new RazorBlogContext()) { var admin = _db.Admins.FirstOrDefault(x => x.UserName == model.UserName && x.Password == model.Password); if (admin != null) { Session.Add("giris", true); Session.Add("adminid", admin.AdminID); return(RedirectToAction("Index", "Admin")); } } } ViewBag.mesaj = "Kullanıcı Adı veya Şifre Yanlış"; return(View()); }
public ActionResult MakaleEkle(FormCollection frm, HttpPostedFileBase file) { string ViewTitle = frm.Get("Title"); string ViewDescription = frm.Get("Description"); int ViewCategoryID = Convert.ToInt32(frm.Get("Category.CategoryID")); string ViewText = frm.Get("Text"); string ViewKeywords = frm.Get("Keywords"); int ViewYazarID = Convert.ToInt32(Session["adminid"]); RazorBlogContext _db = new RazorBlogContext(); Makale ToAdd = new Makale(); ToAdd.AuthorName = _db.Admins.FirstOrDefault(x => x.AdminID == ViewYazarID); ToAdd.Category = _db.Categories.FirstOrDefault(x => x.CategoryID == ViewCategoryID); ToAdd.Description = ViewDescription; if (file != null) { Random rnd = new Random(); string sayi = rnd.Next(111111, 999999).ToString(); string FileName = Path.GetFileName(file.FileName); string File = Path.Combine(Server.MapPath("~/MakaleResimler/"), sayi + FileName); file.SaveAs(File); string FilePath = "~/MakaleResimler/" + sayi + FileName; ToAdd.Image = FilePath; } ToAdd.Keywords = ViewKeywords; ToAdd.Text = ViewText; ToAdd.Title = ViewTitle; _db.Makales.Add(ToAdd); if (_db.SaveChanges() > 0) { ViewBag.Mesaj = "Makale Ekleme Başarılı"; } else { ViewBag.Mesaj = ""; } TumKategoriler(); return(View()); }
public ActionResult MakaleGuncelle(FormCollection frm, HttpPostedFileBase file) { int ViewMakaleID = Convert.ToInt32(frm.Get("MakaleID")); string ViewTitle = frm.Get("Title"); string ViewDescription = frm.Get("Description"); int ViewCategoryID = Convert.ToInt32(frm.Get("Category.CategoryID")); string ViewText = frm.Get("Text"); string ViewKeywords = frm.Get("Keywords"); bool ViewResmiSil = frm.Get("ResmiSil").Contains("true"); RazorBlogContext _db = new RazorBlogContext(); Makale MakaleToEdit = _db.Makales.FirstOrDefault(x => x.MakaleID == ViewMakaleID); Category CategoryToAdd = _db.Categories.FirstOrDefault(x => x.CategoryID == ViewCategoryID); if (ViewResmiSil) { string FileFullPath = Request.MapPath(MakaleToEdit.Image); System.IO.File.Delete(FileFullPath); MakaleToEdit.Image = null; } else { if (file != null) { string FileFullPath = Request.MapPath(MakaleToEdit.Image); System.IO.File.Delete(FileFullPath); Random rnd = new Random(); string sayi = rnd.Next(111111, 999999).ToString(); var FileName = Path.GetFileName(file.FileName); var File = Path.Combine(Server.MapPath("~/MakaleResimler/"), sayi + FileName); file.SaveAs(File); string FilePath = "~/MakaleResimler/" + sayi + FileName; MakaleToEdit.Image = FilePath; } } MakaleToEdit.Title = ViewTitle; MakaleToEdit.Description = ViewDescription; MakaleToEdit.Text = ViewText; MakaleToEdit.Keywords = ViewKeywords; MakaleToEdit.Category = CategoryToAdd; _db.SaveChanges(); return(RedirectToAction("MakaleListele")); }
public ActionResult MailGuncelle(FormCollection frm) { RazorBlogContext _db = new RazorBlogContext(); SistemMail ToEdit = _db.SistemMails.FirstOrDefault(x => x.SistemMailID == 1); string ViewMail = frm.Get("Mail"); string ViewPassword = frm.Get("Password"); ToEdit.Mail = ViewMail; ToEdit.Password = ViewPassword; if (_db.SaveChanges() > 0) { ViewBag.mesaj = "Mail Ayarları Güncellendi"; } else { ViewBag.mesaj = "Mail Ayarları Güncelleme Esnasında Bir Hata Oluştu"; } return(RedirectToAction("index")); }
public ActionResult OzhakikiKategoriEkle(FormCollection frm) { string KategoriAdi = frm.Get("CategoryName"); if (KategoriAdi == "" || KategoriAdi == null) { ViewBag.hatavar = true; ViewBag.hata = "Kategori Adı Boş Geçilemez"; } else { ViewBag.hatavar = false; RazorBlogContext _db = new RazorBlogContext(); List <Category> CakisanKategoriler = _db.Categories.Where(x => x.Name == KategoriAdi).ToList(); if (CakisanKategoriler.Count > 0) { ViewBag.hatavar = true; ViewBag.hata = "Bu Kategori Zaten Mevcut"; } else { ViewBag.hatavar = false; CategoryHelper chelp = new CategoryHelper(); chelp.kategoriolustur(KategoriAdi); Category c = new Category(); c.Name = chelp.CategoryName; c.UrlName = chelp.UrlName; _db.Categories.Add(c); if (_db.SaveChanges() == 0) { ViewBag.hatavar = true; ViewBag.hata = "veritabanı bağlantısında bir sorun oluştu"; } else { ViewBag.hatavar = false; } } } return(View()); }
public ActionResult MakaleGuncelle(int GelenMakaleID) { RazorBlogContext _db = new RazorBlogContext(); Makale ToEdit = _db.Makales.FirstOrDefault(x => x.MakaleID == GelenMakaleID); List <SelectListItem> ForDropDown = new List <SelectListItem>(); List <Category> AllCategoryList = _db.Categories.ToList(); foreach (var item in AllCategoryList) { SelectListItem sl = new SelectListItem(); if (ToEdit.Category.CategoryID == item.CategoryID) { sl.Selected = true; } sl.Text = item.Name; sl.Value = item.CategoryID.ToString(); ForDropDown.Add(sl); } ViewBag.SelectedCategoryListForDropDown = ForDropDown; return(View(ToEdit)); }
public ActionResult MakaleGoster(FormCollection frm, int ViewMakaleID) { RazorBlogContext _db = new RazorBlogContext(); string ViewCommenterName = frm.Get("isim"); string ViewComment = frm.Get("yorum"); Yorum YorumToAdd = new Yorum(); YorumToAdd.Name = ViewCommenterName; YorumToAdd.Comment = ViewComment; Makale MakaleToEdit = _db.Makales.FirstOrDefault(x => x.MakaleID == ViewMakaleID); MakaleToEdit.Yorumlar.Add(YorumToAdd); if (_db.SaveChanges() > 0) { ViewBag.Mesaj = "Yorum Başarı İle Gönderildi Yöneticiler Tarafından Onaylanınca Yayınlanacak"; } else { ViewBag.Mesaj = "Yorum Gönderme Sırasında Bir Hata Oluştu"; } return(View(MakaleToEdit)); }
public ActionResult KategoriListele() { RazorBlogContext _db = new RazorBlogContext(); return(View(_db.Categories.ToList())); }
public ActionResult MakaleListele() { RazorBlogContext _db = new RazorBlogContext(); return(View(_db.Makales.ToList())); }