예제 #1
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"));
        }
예제 #2
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"));
        }
예제 #3
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"));
        }
예제 #4
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"));
        }
예제 #5
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"));
        }
예제 #6
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"));
        }
예제 #7
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"));
        }
예제 #8
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());
        }
예제 #9
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());
        }
예제 #10
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));
        }