示例#1
0
        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"));
        }
示例#2
0
        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"));
        }
示例#3
0
        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"));
        }
示例#4
0
        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"));
        }
示例#5
0
        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"));
        }
示例#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");
            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"));
        }
示例#7
0
        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());
        }
示例#8
0
        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"));
        }
示例#9
0
        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());
        }
示例#10
0
        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));
        }