Beispiel #1
0
        public ActionResult Ayarlar(Kullanici kullanici, HttpPostedFileBase dosya)
        {
            VMKullaniciVeAlert vm = new VMKullaniciVeAlert();
            var kul = db.Kullanici.FirstOrDefault(m => m.Kadi == User.Identity.Name);

            if (ModelState.IsValid)
            {
                if (dosya != null)
                {
                    UserHelpers.FotografSil(kul.Foto);
                    kul.Foto = UserHelpers.FotografYukle(dosya);
                }
                kul.AdSoyad = kullanici.AdSoyad;
                kul.Email   = kullanici.Email;

                if (!string.IsNullOrEmpty(kullanici.Sifre))
                {
                    kul.Sifre = kullanici.Sifre;
                }

                vm.Alert = new VMAlert("success", Resources.Dil.basariliguncelleme);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            else
            {
                vm.Alert = new VMAlert("danger", Resources.Dil.formukontrolet);
            }
            return(View(vm));
        }
        public ActionResult Index(VMIletisim iletisim)
        {
            string dosya = "";

            if (iletisim.dosya != null)
            {
                dosya = UserHelpers.FotografYukle(iletisim.dosya);
            }

            WebMail.SmtpServer = ConfigurationManager.AppSettings["mailSmtp"];
            WebMail.SmtpPort   = Convert.ToInt32(ConfigurationManager.AppSettings["mailPort"]);
            WebMail.UserName   = ConfigurationManager.AppSettings["sunucuMail"];
            WebMail.Password   = ConfigurationManager.AppSettings["sunucuMailSifre"];

            WebMail.EnableSsl = true;

            try
            {
                if (!string.IsNullOrEmpty(dosya))
                {
                    string file = Server.MapPath("~" + dosya);
                    WebMail.Send(
                        to: ConfigurationManager.AppSettings["adminMail"],
                        subject: iletisim.baslik,
                        body: iletisim.mesaj + "<br><br> TC: " + iletisim.tc + " <br><br>Ad Soyad: " + iletisim.adsoyad + " <br><br>Telefon Numarası: " + iletisim.telefon,
                        replyTo: ConfigurationManager.AppSettings["sunucuMail"],
                        isBodyHtml: true,
                        filesToAttach: new[] { file });
                }
                else
                {
                    WebMail.Send(
                        to: ConfigurationManager.AppSettings["adminMail"],
                        subject: iletisim.baslik,
                        body: iletisim.mesaj + "<br><br> TC: " + iletisim.tc + " <br><br>Ad Soyad: " + iletisim.adsoyad + " <br><br>Telefon Numarası: " + iletisim.telefon,
                        replyTo: ConfigurationManager.AppSettings["sunucuMail"],
                        isBodyHtml: true);
                }
                VMAlert alert = new VMAlert("success", Resources.Dil.basariliiletisim);

                VMIletisim vm = new VMIletisim()
                {
                    alert = alert
                };
                return(View(vm));
            }
            catch (Exception ex)
            {
                VMAlert alert = new VMAlert("danger", ex.Message);

                VMIletisim vm = new VMIletisim()
                {
                    alert = alert
                };
                return(View(vm));
            }
        }
        public ActionResult Create([Bind(Include = "Mid,Baslik,KisaIcerik,Icerik,Foto,EklenmeTarihi,GuncellemeTarihi,KatId,Kid")] Makale makale, HttpPostedFileBase dosya)
        {
            if (ModelState.IsValid)
            {
                if (dosya != null)
                {
                    makale.Foto = UserHelpers.FotografYukle(dosya);
                }

                var kul = db.Kullanici.FirstOrDefault(m => m.Kadi == User.Identity.Name);
                makale.Kid           = kul.Kid;
                makale.EklenmeTarihi = DateTime.Now;
                db.Makale.Add(makale);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.KatId = new SelectList(db.Kategori, "KatId", "KategoriAdi", makale.KatId);
            return(View(makale));
        }
        public ActionResult Edit([Bind(Include = "Mid,Baslik,KisaIcerik,Icerik,Foto,EklenmeTarihi,GuncellemeTarihi,KatId,Kid")] Makale makale, HttpPostedFileBase dosya)
        {
            if (ModelState.IsValid)
            {
                var mak = db.Makale.Find(makale.Mid);
                if (dosya != null)
                {
                    UserHelpers.FotografSil(mak.Foto);
                    mak.Foto = UserHelpers.FotografYukle(dosya);
                }
                mak.GuncellemeTarihi = DateTime.Now;
                mak.Baslik           = makale.Baslik;
                mak.KisaIcerik       = makale.KisaIcerik;
                mak.Icerik           = makale.Icerik;
                mak.KatId            = makale.KatId;

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.KatId = new SelectList(db.Kategori, "KatId", "KategoriAdi", makale.KatId);
            return(View(makale));
        }
 public ActionResult Create([Bind(Include = "Kid,Kadi,Sifre,AdSoyad,Email,UyelikTarihi,Foto,Yetki")] Kullanici kullanici, HttpPostedFileBase dosya)
 {
     if (ModelState.IsValid)
     {
         var bak = db.Kullanici.FirstOrDefault(m => m.Kadi == kullanici.Kadi);
         if (!UserHelpers.KullaniciAdiKontrolu(kullanici.Kadi) || bak != null)
         {
             VMKullaniciVeAlert kullaniciVeAlert = new VMKullaniciVeAlert()
             {
                 Alert = new VMAlert("danger", Resources.Dil.gecersizkul)
             };
             return(View(kullaniciVeAlert));
         }
         else if (string.IsNullOrEmpty(kullanici.Sifre))
         {
             VMKullaniciVeAlert kullaniciVeAlert = new VMKullaniciVeAlert()
             {
                 Alert = new VMAlert("danger", Resources.Dil.sifregir)
             };
             return(View(kullaniciVeAlert));
         }
         string foto = UserHelpers.FotografYukle(dosya);
         kullanici.Foto         = foto;
         kullanici.UyelikTarihi = DateTime.Now;
         db.Kullanici.Add(kullanici);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else
     {
         VMKullaniciVeAlert kullaniciVeAlert2 = new VMKullaniciVeAlert()
         {
             Alert = new VMAlert("danger", Resources.Dil.formukontrolet)
         };
         return(View(kullaniciVeAlert2));
     }
 }
        public ActionResult Edit([Bind(Include = "Kid,Kadi,Sifre,AdSoyad,Email,UyelikTarihi,Foto,Yetki")] Kullanici kullanici, HttpPostedFileBase dosya)
        {
            VMKullaniciVeAlert vm = new VMKullaniciVeAlert();

            if (ModelState.IsValid)
            {
                var kul = db.Kullanici.Find(kullanici.Kid);
                if (kul == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                if (dosya != null)
                {
                    UserHelpers.FotografSil(kul.Foto);
                    kul.Foto = UserHelpers.FotografYukle(dosya);
                }
                kul.AdSoyad = kullanici.AdSoyad;
                kul.Email   = kullanici.Email;
                kul.Yetki   = kullanici.Yetki;

                if (!string.IsNullOrEmpty(kullanici.Sifre))
                {
                    kul.Sifre = kullanici.Sifre;
                }

                vm.Alert = new VMAlert("success", Resources.Dil.basariliguncelleme);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            else
            {
                vm.Alert = new VMAlert("danger", Resources.Dil.formukontrolet);
            }
            return(View(vm));
        }