예제 #1
0
        public ActionResult MakaleSil(int GelenID)
        {
            RazerBlogContext _db   = new RazerBlogContext();
            Makale           ToDel = _db.Makales.FirstOrDefault(x => x.MakaleID == GelenID);

            return(View(ToDel));
        }
예제 #2
0
        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;
            RazerBlogContext _db = new RazerBlogContext();
            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 * Kacar) - 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());
        }
예제 #3
0
        public ActionResult KategoriSil(int KategoriID)
        {
            RazerBlogContext _db           = new RazerBlogContext();
            Category         CategoryToDel = _db.Categories.First(x => x.CategoryID == KategoriID);

            return(View(CategoryToDel));
        }
예제 #4
0
        public ActionResult YorumlariYonet()
        {
            RazerBlogContext _db          = new RazerBlogContext();
            List <Yorum>     YorumlarList = _db.Yorums.ToList();

            return(View(YorumlarList));
        }
예제 #5
0
        public void yakalaıd(int yakalananıd)
        {
            RazerBlogContext      _db      = new RazerBlogContext();
            List <SelectListItem> katlist  = new List <SelectListItem>();
            List <Category>       katsorgu = _db.Categories.ToList();

            foreach (Category item in katsorgu)
            {
                SelectListItem li = new SelectListItem();
                li.Text  = item.Name;
                li.Value = item.CategoryID.ToString();

                if (yakalananıd == item.CategoryID)
                {
                    li.Selected = true;
                    //katlist.Add(new SelectListItem { Text = item.Name, Value = item.CategoryID.ToString(), Selected = true });
                }
                katlist.Add(li);
                //else
                //{
                //    katlist.Add(new SelectListItem { Text = item.Name, Value = item.CategoryID.ToString() });
                //}
            }
            ViewBag.kat = katlist;
        }
예제 #6
0
 public bool MailGonder(string GelenMail, string Konu, string Mesaj)
 {
     try
     {
         RazerBlogContext _db          = new RazerBlogContext();
         string           MailFrom     = _db.SistemMails.FirstOrDefault(x => x.SistemMailID == 1).Mail;
         string           MailPassword = _db.SistemMails.FirstOrDefault(x => x.SistemMailID == 1).Password;
         new SmtpClient
         {
             Host                  = "Smtp.Gmail.com",
             Port                  = 465,
             EnableSsl             = true,
             Timeout               = 10000,
             DeliveryMethod        = SmtpDeliveryMethod.Network,
             UseDefaultCredentials = false,
             Credentials           = new NetworkCredential(MailFrom, MailPassword)
         }.Send(new MailMessage {
             From = new MailAddress(MailFrom, ""), To = { MailFrom }, Subject = Konu, Body = Mesaj, BodyEncoding = Encoding.UTF8
         });
         return(true);
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #7
0
        public ActionResult KategoriGuncelle(int KategoriID)
        {
            RazerBlogContext _db    = new RazerBlogContext();
            Category         ToEdit = _db.Categories.First(x => x.CategoryID == KategoriID);

            return(View(ToEdit));
        }
예제 #8
0
        public ActionResult MakaleGoster(int ViewMakaleID)
        {
            RazerBlogContext _db          = new RazerBlogContext();
            Makale           MakaleToShow = _db.Makales.FirstOrDefault(x => x.MakaleID == ViewMakaleID);

            return(View(MakaleToShow));
        }
예제 #9
0
        // 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;
            RazerBlogContext _db = new RazerBlogContext();
            //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 * Kacar) - Kacar;
            List <Makale> SayfaMakale = new List <Makale>(_db.Makales.OrderByDescending(x => x.MakaleID).Skip(Kactan).Take(Kacar));

            ViewBag.sayfamakale = SayfaMakale;
            return(View());
        }
예제 #10
0
        public ActionResult MailGuncelle()
        {
            RazerBlogContext _db    = new RazerBlogContext();
            SistemMail       ToEdit = _db.SistemMails.FirstOrDefault(x => x.SistemMailID == 1);

            return(View(ToEdit));
        }
예제 #11
0
        public ActionResult MakaleGuncelle(int GelenMakaleID, FormCollection frm)
        {
            RazerBlogContext _db    = new RazerBlogContext();
            Makale           ToEdit = _db.Makales.FirstOrDefault(x => x.MakaleID == GelenMakaleID);

            yakalaıd(Convert.ToInt32(ToEdit.Category.CategoryID));
            return(View(ToEdit));
        }
예제 #12
0
        public List <Admin> TumAdmin()
        {
            RazerBlogContext _db       = new RazerBlogContext();
            List <Admin>     AdminList = _db.Admins.ToList();

            ViewBag.admins = AdminList;
            return(AdminList);
        }
예제 #13
0
        public List <Category> TumKategoriler()
        {
            RazerBlogContext _db             = new RazerBlogContext();
            List <Category>  KategorilerList = _db.Categories.ToList();

            ViewBag.kategoriler = KategorilerList;
            return(KategorilerList);
        }
예제 #14
0
        public ActionResult YorumOnayiKaldir(int ViewYorumID)
        {
            RazerBlogContext _db    = new RazerBlogContext();
            Yorum            ToEdit = _db.Yorums.FirstOrDefault(x => x.YorumID == ViewYorumID);

            ToEdit.OnayDurumu = 0;
            _db.SaveChanges();
            return(RedirectToAction("YorumlariYonet"));
        }
예제 #15
0
        public ActionResult YorumSil(int ViewYorumID)
        {
            RazerBlogContext _db      = new RazerBlogContext();
            Yorum            ToDelete = _db.Yorums.FirstOrDefault(x => x.YorumID == ViewYorumID);

            _db.Yorums.Remove(ToDelete);
            _db.SaveChanges();
            return(RedirectToAction("YorumlariYonet"));
        }
예제 #16
0
        public ActionResult MakaleSil(Makale m)
        {
            RazerBlogContext _db   = new RazerBlogContext();
            Makale           ToDel = _db.Makales.FirstOrDefault(x => x.MakaleID == m.MakaleID);

            _db.Makales.Remove(ToDel);
            _db.SaveChanges();
            return(RedirectToAction("MakaleListele"));
        }
예제 #17
0
        public ActionResult KategoriSil(Category c)
        {
            RazerBlogContext _db   = new RazerBlogContext();
            Category         ToDel = _db.Categories.First(x => x.CategoryID == c.CategoryID);

            _db.Categories.Remove(ToDel);
            _db.SaveChanges();
            return(RedirectToAction("KategoriListele"));
        }
예제 #18
0
        public ActionResult KategoriGuncelle(Category c)
        {
            RazerBlogContext _db    = new RazerBlogContext();
            Category         ToEdit = _db.Categories.First(x => x.CategoryID == c.CategoryID);

            ToEdit.Name    = c.Name;
            ToEdit.UrlName = c.UrlName;
            _db.SaveChanges();
            return(RedirectToAction("KategoriListele"));
        }
예제 #19
0
 public ActionResult Login(AdminHelper model)
 {
     if (ModelState.IsValid)
     {
         using (RazerBlogContext _db = new RazerBlogContext())
         {
             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());
 }
예제 #20
0
        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");

            RazerBlogContext _db           = new RazerBlogContext();
            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"));
        }
예제 #21
0
        public ActionResult MakaleEkle(FormCollection frm, HttpPostedFileBase file)
        {
            RazerBlogContext _db             = new RazerBlogContext();
            string           ViewTitle       = frm.Get("Title");
            string           ViewDescription = frm.Get("Description");
            int    ViewCategoryID            = Convert.ToInt32(frm.Get("Category"));
            string ViewText     = frm.Get("Text");
            string ViewKeywords = frm.Get("Keywords");
            int    ViewYazarID  = Convert.ToInt32(Session["adminid"]);

            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();
                var    FileName = Path.GetFileName(file.FileName);
                var    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;

            //RazerBlogContext _db = new RazerBlogContext();
            _db.Makales.Add(ToAdd);
            if (_db.SaveChanges() > 0)
            {
                ViewBag.Mesaj = "Makale Ekleme Başarılı";
            }
            else
            {
                ViewBag.Mesaj = "";
            }
            TumKategoriler();
            TumAdmin();
            return(View());
        }
예제 #22
0
        public ActionResult MailGuncelle(FormCollection frm)
        {
            RazerBlogContext _db          = new RazerBlogContext();
            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ı sırasında Bir Hata olustu";
            }
            return(RedirectToAction("Index"));
        }
예제 #23
0
        public ActionResult Ozhakikikategoriekle(FormCollection frm)
        {
            string KategoriAdi = frm.Get("CategoryName");

            if (KategoriAdi == "")
            {
                ViewBag.hatavar = true;
                ViewBag.hata    = "Kategori Adi Boş Geçilemez";
            }
            else
            {
                ViewBag.hatavar = false;
                RazerBlogContext _db = new RazerBlogContext();
                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 Sorun var";
                    }
                    else
                    {
                        ViewBag.hatavar = false;
                    }
                }
            }
            return(View());
        }
예제 #24
0
        public ActionResult MakaleGoster(FormCollection frm, int ViewMakaleID)
        {
            RazerBlogContext _db = new RazerBlogContext();
            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 = "Yorumunuz Başarı İle Gönderildi Onay Bekleniyor";
            }
            else
            {
                ViewBag.mesaj = "Yorum Gönderme Sırasında Bir Hata Oluştu";
            }
            return(View(MakaleToEdit));
        }
예제 #25
0
        public ActionResult KategoriListele()
        {
            RazerBlogContext _db = new RazerBlogContext();

            return(View(_db.Categories.ToList()));
        }
예제 #26
0
        public ActionResult MakaleListele()
        {
            RazerBlogContext _db = new RazerBlogContext();

            return(View(_db.Makales.ToList()));
        }