示例#1
0
        public ActionResult Ekle(Oyuncu o, HttpPostedFileBase resimGelen)
        {
            if (ModelState.IsValid == false)//validation hatası varsa
            {
                return(View());
            }

            ResimIslem r     = new ResimIslem();
            string     deger = r.Ekle(resimGelen);

            if (deger == "uzanti")
            {
                ViewBag.Hata = "Oyuncu fotoğrafı .png veya .jpg uzantılı olmalı!";
                return(View());
            }
            else if (deger == "boyut")
            {
                ViewBag.Hata = "Oyuncu fotoğrafının boyutu 3 megabyte'tan fazla lütfen daha düşük boyutlu fotoğraf atınız!";
                return(View());
            }
            else
            {
                o.resim = deger;
            }
            db.Oyuncu.Add(o);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#2
0
        public ActionResult KullaniciSil(int id)
        {   //Kullanıcı giriş yapmadan ve eğer girdiyse link üzerinden birisini silmesin diye sağlanan kontrol
            Kullanici k   = db.Kullanici.Where(x => x.kullaniciID == id).SingleOrDefault();
            Bilet     b   = db.Bilet.Where(x => x.kullaniciID == id).SingleOrDefault();
            Kullanici kul = (Kullanici)Session["Kullanici"];

            if (kul == null)
            {
                return(RedirectToAction("Index"));
            }

            else if (kul.kullaniciID == id)
            {
                ResimIslem r = new ResimIslem();
                r.Sil(k.resim);
                db.Kullanici.Remove(k);
                db.Bilet.Remove(b);
                db.SaveChanges();
                Session.Abandon();
            }
            else
            {
                return(RedirectToAction("Index"));
            }

            return(RedirectToAction("Index"));
        }
        public ActionResult Ekle(Kullanici k, HttpPostedFileBase resimGelen)
        {
            Bilet bilet = new Bilet();

            bilet.kullaniciID = k.kullaniciID;
            bilet.hediyebilet = 0;
            db.Bilet.Add(bilet);
            if (ModelState.IsValid == false)//validation hatası varsa
            {
                var yetkiler = db.Yetki.ToList();
                ViewBag.Yetkiler = new SelectList(yetkiler, "yetkiID", "ad");
                return(View());
            }
            Kullanici kul = db.Kullanici.Where(x => x.mail == k.mail).SingleOrDefault();

            if (kul != null)
            {//aynı epostalı kişi var
                ModelState.AddModelError("eposta", "Farklı bir eposta giriniz");
                var yetkiler = db.Yetki.ToList();
                ViewBag.Yetkiler = new SelectList(yetkiler, "yetkiID", "ad");
                return(View());
            }

            ResimIslem r = new ResimIslem();

            if (resimGelen != null)  // Yeni kullanıcı eklerken kullanıcıya fotoğraf eklemezse default olarak kullanici.png.
            {
                string deger = r.Ekle(resimGelen);
                if (deger == "uzanti")
                {
                    var yetkiler = db.Yetki.ToList();
                    ViewBag.Yetkiler = new SelectList(yetkiler, "yetkiID", "ad");
                    ViewBag.Hata     = "Kullanıcı fotoğrafı .png veya .jpg uzantılı olmalı!";
                    return(View());
                }
                else if (deger == "boyut")
                {
                    var yetkiler = db.Yetki.ToList();
                    ViewBag.Yetkiler = new SelectList(yetkiler, "yetkiID", "ad");
                    ViewBag.Hata     = "Kullanıcı fotoğrafının boyutu 3 megabyte'tan fazla lütfen daha düşük boyutlu fotoğraf atınız!";
                    return(View());
                }
                else
                {
                    k.resim = deger;
                }
            }
            else
            {
                k.resim = "kullanici.png";
            }

            db.Kullanici.Add(k);
            db.SaveChanges();
            ViewBag.Sonuc = k.ad + " " + k.soyad + " " + " kişisi eklenmiştir.";
            return(RedirectToAction("Index"));
        }
示例#4
0
        public ActionResult Sil(int id)
        {
            Film       f = db.Film.Where(x => x.filmID == id).SingleOrDefault();
            ResimIslem r = new ResimIslem();

            r.Sil(f.resim);
            db.Film.Remove(f);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#5
0
        public ActionResult Sil(int id)
        {
            Oyuncu     o = db.Oyuncu.Where(x => x.oyuncuID == id).SingleOrDefault();
            ResimIslem r = new ResimIslem();

            r.Sil(o.resim);
            db.Oyuncu.Remove(o);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#6
0
        public ActionResult İlanSil(string id)
        {
            ilan ilan = ctx.ilan.FirstOrDefault(x => x.id == new Guid(id));

            if (ilan == null)
            {
                TempData["Mesaj"] = "ilan bulunamadı";
                return(RedirectToAction("İlanlar"));
            }
            //ilanın resmi var
            List <ilanResim> ilanResims = ctx.ilanResim.Where(x => x.ilan_id == new Guid(id)).ToList();

            foreach (ilanResim item in ilanResims)
            {
                ResimIslem.Sil(item.ad, ResimIslemTip.İlan);
                ctx.ilanResim.Remove(item);
            }
            //ilanın acik artirması var : acik artirmanın teklifi var
            if (ilan.AcikArtirma != null)
            {
                AcikArtirma   acikArtirma = ilan.AcikArtirma;
                List <Teklif> teklifler   = ctx.Teklif.Where(x => x.acikartirma_id == acikArtirma.id).ToList();
                foreach (Teklif item in teklifler)
                {
                    ctx.Teklif.Remove(item);
                }
                ctx.AcikArtirma.Remove(acikArtirma);
            }
            //ilanın favorisi var
            List <Favoriilan> favorileri = ctx.Favoriilan.Where(x => x.ilan_id == ilan.id).ToList();

            foreach (Favoriilan item in favorileri)
            {
                ctx.Favoriilan.Remove(item);
            }
            //ilanın ilan mesajı var
            List <ilanMesaj> mesajlar = ctx.ilanMesaj.Where(x => x.ilan_id == ilan.id).ToList();

            foreach (ilanMesaj item in mesajlar)
            {
                ctx.ilanMesaj.Remove(item);
            }
            //ilanın önce çıkar'ı var
            List <OneCikar> oneCikars = ctx.OneCikar.Where(x => x.ilan_id == ilan.id).ToList();

            foreach (OneCikar item in oneCikars)
            {
                ctx.OneCikar.Remove(item);
            }
            ctx.ilan.Remove(ilan);
            ctx.SaveChanges();
            TempData["Mesaj"]    = "İlan Silindi";
            TempData["MesajTip"] = "info"; // success info warning danger
            return(RedirectToAction("İlanlar"));
        }
        public ActionResult KullaniciDuzenle(Kullanici model, HttpPostedFileBase gelenResim) // ayarlarım
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("KullaniciDuzenle"));
            }
            if (model.id != ((Kullanici)Session["Kullanici"]).id)
            {
                TempData["Mesaj"]    = "Başka Kullanıcının Bilgileri Değiştirilemez.";
                TempData["MesajTip"] = "danger"; // success info warning danger
                return(RedirectToAction("KullaniciDuzenle"));
            }
            Kullanici kullanici = ctx.Kullanici.FirstOrDefault(x => x.id == model.id);

            kullanici.ad      = model.ad;
            kullanici.soyad   = model.soyad;
            kullanici.sifre   = model.sifre;
            kullanici.telefon = model.telefon;
            kullanici.mail    = model.mail;

            if (gelenResim != null) // yeni resim gelmişse
            {
                KullaniciResim kr = kullanici.KullaniciResim;
                if (kr != null) // önceden resmi varsa sil
                {
                    string sonuc = ResimIslem.Sil(kr.ad, ResimIslemTip.Kullanici);
                    ctx.KullaniciResim.Remove(kr);
                }

                //yeni resmi ekle
                string sonuc2 = ResimIslem.Ekle(gelenResim, ResimIslemTip.Kullanici);
                if (sonuc2 == "uzanti")
                {
                    TempData["Mesaj"]    = "Yüklenen Resmin Uzzantısı Farklı";
                    TempData["MesajTip"] = "danger"; // success info warning danger
                    return(RedirectToAction("KullaniciDuzenle"));
                }
                else if (sonuc2 == "boyut")
                {
                    TempData["Mesaj"]    = "Yüklenen Resmin Boyutu Fazla";
                    TempData["MesajTip"] = "danger"; // success info warning danger
                    return(RedirectToAction("KullaniciDuzenle"));
                }
                KullaniciResim kResim = new KullaniciResim();
                kResim.id = Guid.NewGuid();
                kResim.ad = sonuc2;
                ctx.KullaniciResim.Add(kResim);
                kullanici.KullaniciResim = kResim;
            }
            ctx.SaveChanges();
            TempData["Mesaj"]    = "Bilgiler Başarıyla Güncellendi";
            TempData["MesajTip"] = "success"; // success info warning danger
            return(RedirectToAction("Index"));
        }
示例#8
0
        public ActionResult Duzenle(Film f, HttpPostedFileBase resimGelen)
        {
            int  filmID = (int)TempData["filmID"];
            Film film   = db.Film.Where(x => x.filmID == filmID).SingleOrDefault();

            if (resimGelen != null)
            {
                ResimIslem r     = new ResimIslem();
                string     deger = r.Ekle(resimGelen);
                if (deger == "uzanti")
                {
                    var tur = db.Tur.ToList();
                    var yas = db.YasGrup.ToList();
                    ViewBag.Turler = new SelectList(tur, "turID", "ad", film.turID);
                    ViewBag.Yaslar = new SelectList(yas, "yasgrupID", "ad", film.yasgrupID);
                    ViewBag.Hata   = "Film fotoğrafı .png veya .jpg uzantılı olmalı!";
                    return(View(film));
                }
                else if (deger == "boyut")
                {
                    var tur = db.Tur.ToList();
                    var yas = db.YasGrup.ToList();
                    ViewBag.Turler = new SelectList(tur, "turID", "ad", film.turID);
                    ViewBag.Yaslar = new SelectList(yas, "yasgrupID", "ad", film.yasgrupID);
                    ViewBag.Hata   = "Film fotoğrafının boyutu 3 megabyte'tan fazla lütfen daha düşük boyutlu fotoğraf atınız!";
                    return(View(film));
                }
                else
                {
                    f.resim = deger;
                }
            }
            if (f.resim != null)
            {
                if (film.resim != "film.png")
                {
                    new ResimIslem().Sil(film.resim);
                    film.resim = f.resim;
                }
                film.resim = f.resim;
            }
            film.ad          = f.ad;
            film.aciklama    = f.aciklama;
            film.vizyontarih = f.vizyontarih;
            film.seans       = f.seans;
            film.salon       = f.salon;
            film.yasgrupID   = f.yasgrupID;
            film.turID       = f.turID;
            film.fragman     = f.fragman;
            film.yonetmen    = f.yonetmen;
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
        public ActionResult Duzenle(Kullanici k, HttpPostedFileBase resimGelen)
        {
            int       kullaniciID = (int)TempData["kullaniciID"];
            Kullanici kul         = db.Kullanici.Where(x => x.kullaniciID == kullaniciID).SingleOrDefault();

            if (ModelState.IsValid == false)
            {
                var yetkiler = db.Yetki.ToList();
                ViewBag.Yetkiler = new SelectList(yetkiler, "yetkiID", "ad", kul.yetkiID);
                return(View(kul));
            }
            //resim boş mu ?
            if (resimGelen != null)
            {
                ResimIslem r     = new ResimIslem();
                string     deger = r.Ekle(resimGelen);
                if (deger == "uzanti")
                {
                    var yetkiler = db.Yetki.ToList();
                    ViewBag.Yetkiler = new SelectList(yetkiler, "yetkiID", "ad", kul.yetkiID);
                    ViewBag.Hata     = "Kullanıcı fotoğrafı .png veya .jpg uzantılı olmalı!";
                    return(View(kul));
                }
                else if (deger == "boyut")
                {
                    var yetkiler = db.Yetki.ToList();
                    ViewBag.Yetkiler = new SelectList(yetkiler, "yetkiID", "ad", kul.yetkiID);
                    ViewBag.Hata     = "Kullanıcı fotoğrafının boyutu 3 megabyte'tan fazla lütfen daha düşük boyutlu fotoğraf atınız!";
                    return(View(kul));
                }
                else
                {
                    k.resim = deger;
                }
            }

            if (k.resim != null)
            {
                if (kul.resim != "kullanici.png")
                {
                    new ResimIslem().Sil(kul.resim);
                    kul.resim = k.resim;
                }
                kul.resim = k.resim;
            }
            kul.ad      = k.ad;
            kul.soyad   = k.soyad;
            kul.mail    = k.mail;
            kul.sifre   = k.sifre;
            kul.telefon = k.telefon;
            kul.yetkiID = k.yetkiID;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Sil(int id)
        {
            ViewBag.Uyari = "Silme işlemi gerçekleşti";
            kullanici  k = db.kullanici.Where(x => x.kullaniciID == id).SingleOrDefault();
            ResimIslem r = new ResimIslem();

            r.Sil(k.resim);

            db.kullanici.Remove(k);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#11
0
        public ActionResult Sil(int id)
        {
            Kullanici  k = db.Kullanici.Where(x => x.kullaniciID == id).SingleOrDefault();
            Bilet      b = db.Bilet.Where(x => x.kullaniciID == id).SingleOrDefault();
            ResimIslem r = new ResimIslem();

            r.Sil(k.resim);
            db.Kullanici.Remove(k);
            db.Bilet.Remove(b);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#12
0
        public ActionResult KullaniciDuzenle(Kullanici model, HttpPostedFileBase gelenResim)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("KullaniciDuzenle"));
            }
            Kullanici kullanici = ctx.Kullanici.FirstOrDefault(x => x.id == model.id);

            if (kullanici == null) // kullanıcı yoksa geriye at
            {
                TempData["Mesaj"]    = "Kullanici Bulunamadı.";
                TempData["MesajTip"] = "warning"; // success info warning danger
                return(RedirectToAction("Kullanicilar"));
            }
            kullanici.ad        = model.ad;
            kullanici.soyad     = model.soyad;
            kullanici.engellimi = model.engellimi;
            kullanici.mail      = model.mail;
            kullanici.Rol       = model.Rol;
            kullanici.onaylimi  = model.onaylimi;
            kullanici.telefon   = model.telefon;
            string sonuc1, sonuc2;

            if (gelenResim != null)                   // yeni resim eklediysek
            {
                if (kullanici.KullaniciResim != null) // önceden resmi varsa silinir..
                {
                    sonuc1 = ResimIslem.Sil(kullanici.KullaniciResim.ad, ResimIslemTip.Kullanici);
                    if (sonuc1 == "Silindi")
                    {
                        KullaniciResim kr = ctx.KullaniciResim.FirstOrDefault(x => x.id == kullanici.kullaniciresim_id);
                        kullanici.KullaniciResim = null;
                        ctx.KullaniciResim.Remove(kr);
                        ctx.SaveChanges();
                    }
                }
                sonuc2 = ResimIslem.Ekle(gelenResim, ResimIslemTip.Kullanici);
                if (sonuc2 != "boyut" || sonuc2 != "uzanti") // ikisi de değilse resim eklendi demektir.
                {
                    KullaniciResim kResim = new KullaniciResim();
                    kResim.id = Guid.NewGuid();
                    kResim.ad = sonuc2;
                    ctx.KullaniciResim.Add(kResim);
                    kullanici.KullaniciResim = kResim;
                }
            }
            ctx.SaveChanges();
            TempData["Mesaj"]    = "Kullanıcı Düzenlendi.";
            TempData["MesajTip"] = "success"; // success info warning danger
            return(RedirectToAction("Kullanicilar"));
        }
示例#13
0
        public ActionResult Ekle(Film f, HttpPostedFileBase resimGelen)
        {
            if (ModelState.IsValid == false)//validation hatası varsa
            {
                var tur = db.Tur.ToList();
                var yas = db.YasGrup.ToList();
                ViewBag.Turler = new SelectList(tur, "turID", "ad");
                ViewBag.Yaslar = new SelectList(yas, "yasgrupID", "ad");
                return(View());
            }
            Film film = db.Film.Where(x => x.ad == f.ad).SingleOrDefault();

            if (film != null)
            {//aynı epostalı kişi var
                ModelState.AddModelError("filmad", "Aynı isimde film var farklı bir isim deneyiniz");
                var tur = db.Tur.ToList();
                var yas = db.YasGrup.ToList();
                ViewBag.Turler = new SelectList(tur, "turID", "ad");
                ViewBag.Yaslar = new SelectList(yas, "yasgrupID", "ad");
                return(View());
            }
            ResimIslem r     = new ResimIslem();
            string     deger = r.Ekle(resimGelen);

            if (deger == "uzanti")
            {
                var tur = db.Tur.ToList();
                var yas = db.YasGrup.ToList();
                ViewBag.Turler = new SelectList(tur, "turID", "ad");//(Liste,data olarak ne kullanacaz,text olarak ne gösterilecek)
                ViewBag.Yaslar = new SelectList(yas, "yasgrupID", "ad");
                ViewBag.Hata   = "Film fotoğrafı .png veya .jpg uzantılı olmalı!";
                return(View());
            }
            else if (deger == "boyut")
            {
                var tur = db.Tur.ToList();
                var yas = db.YasGrup.ToList();
                ViewBag.Turler = new SelectList(tur, "turID", "ad");//(Liste,data olarak ne kullanacaz,text olarak ne gösterilecek)
                ViewBag.Yaslar = new SelectList(yas, "yasgrupID", "ad");
                ViewBag.Hata   = "Film fotoğrafının boyutu 3 megabyte'tan fazla lütfen daha düşük boyutlu fotoğraf atınız!";
                return(View());
            }
            else
            {
                f.resim = deger;
            }
            db.Film.Add(f);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Ekle(kullanici k, HttpPostedFileBase resimGelen)

        {
            if (ModelState.IsValid == false) // validation hatası varsa demek
            {
                var yetkiler = db.yetki.ToList();
                ViewBag.yetkiler = new SelectList(yetkiler, "yetkiID", "adi");
                return(View());
            }

            kullanici kul = db.kullanici.Where(x => x.eposta == k.eposta).SingleOrDefault();

            if (kul != null)
            {
                //aynı epostayla kaydolan biri var demek
                ModelState.AddModelError("eposta", "Farklı bir eposta adresi giriniz!");
                var yetkiler = db.yetki.ToList();
                ViewBag.yetkiler = new SelectList(yetkiler, "yetkiID", "adi");
                return(View());
            }

            ResimIslem r     = new ResimIslem();
            string     deger = r.Ekle(resimGelen);

            if (deger == "uzanti")
            {
                var yetkiler = db.yetki.ToList();
                ViewBag.yetkiler = new SelectList(yetkiler, "yetkiID", "adi");
                ViewBag.Hata     = "Lütfen .png veya .jpg uzantılı resim seçiniz!";
                return(View());
            }

            else if (deger == "boyut")
            {
                var yetkiler = db.yetki.ToList();
                ViewBag.yetkiler = new SelectList(yetkiler, "yetkiID", "adi");
                ViewBag.Hata     = "Lütfen daha küçük boyutlu bir resim seçiniz!";
                return(View());
            }

            else
            {
                k.resim = deger;
            }

            db.kullanici.Add(k);
            db.SaveChanges();
            ViewBag.Uyari = "Kullanıcı eklendi";
            return(RedirectToAction("Index"));
        }
示例#15
0
        public ActionResult Duzenle(Oyuncu o, HttpPostedFileBase resimGelen)
        {
            int    oyuncuID = (int)TempData["oyuncuID"];
            Oyuncu oyuncu   = db.Oyuncu.Where(x => x.oyuncuID == oyuncuID).SingleOrDefault();

            if (resimGelen != null)
            {
                ResimIslem r     = new ResimIslem();
                string     deger = r.Ekle(resimGelen);
                if (deger == "uzanti")
                {
                    ViewBag.Hata = "Oyuncu fotoğrafı .png veya .jpg uzantılı olmalı!";
                    return(View(oyuncu));
                }
                else if (deger == "boyut")
                {
                    ViewBag.Hata = "Oyuncu fotoğrafının boyutu 3 megabyte'tan fazla lütfen daha düşük boyutlu fotoğraf atınız!";
                    return(View(oyuncu));
                }
                else
                {
                    o.resim = deger;
                }
            }
            if (o.resim != null)
            {
                if (oyuncu.resim != "oyuncu.png")
                {
                    new ResimIslem().Sil(oyuncu.resim);
                    oyuncu.resim = o.resim;
                }
                oyuncu.resim = o.resim;
            }

            oyuncu.ad    = o.ad;
            oyuncu.soyad = o.soyad;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#16
0
        public ActionResult KayitOl(Kullanici model, HttpPostedFileBase gelenResim, string sifre2)
        {
            if (!ModelState.IsValid)
            {
                return(KayitOl());
            }
            if (model.sifre != sifre2)
            {
                TempData["Mesaj"]    = "Şifreler Aynı Olmalı"; // redirect yapılan sayfa için temp data ile hata mesajı atılır
                TempData["MesajTip"] = "warning";              // success info warning danger
                return(View(model));
            }
            if (model.ad == "" || model.soyad == "" || model.mail == "" || model.telefon == "" || model.sifre == "")
            {
                TempData["Mesaj"]    = "Boş Alanları Doldurun"; // redirect yapılan sayfa için temp data ile hata mesajı atılır
                TempData["MesajTip"] = "warning";               // success info warning danger
                return(View(model));
            }

            Kullanici kontrol = ctx.Kullanici.FirstOrDefault(x => x.mail == model.mail || x.telefon == model.telefon);//kullanıcı aynı mail aynı telefonla kayıt olamaz

            if (kontrol != null)
            {
                TempData["Mesaj"]    = "Bu Bilgilerle Kayıtlı Kullanıcı Bulunmaktadır."; // redirect yapılan sayfa için temp data ile hata mesajı atılır
                TempData["MesajTip"] = "danger";                                         // success info warning danger
                return(View());
            }
            if (gelenResim == null)
            {
                model.kullaniciresim_id = null;
            }
            else
            {
                string cevap = ResimIslem.Ekle(gelenResim, ResimIslemTip.Kullanici);
                if (cevap == "uzanti")
                {
                    TempData["Mesaj"]    = "Yüklenen Dosya Resim Değildir."; // redirect yapılan sayfa için temp data ile hata mesajı atılır
                    TempData["MesajTip"] = "warning";                        // success info warning danger
                    return(View(model));
                }
                else if (cevap == "boyut")
                {
                    TempData["Mesaj"]    = "Resim Dosyasının Boyutu Belirlenenden Büyük"; // redirect yapılan sayfa için temp data ile hata mesajı atılır
                    TempData["MesajTip"] = "warning";                                     // success info warning danger
                    return(View(model));
                }
                KullaniciResim kResim = new KullaniciResim();
                kResim.id = Guid.NewGuid();
                kResim.ad = cevap;
                ctx.KullaniciResim.Add(kResim);
                model.KullaniciResim = kResim;
            }
            model.id = Guid.NewGuid();
            model.olusturulmatarih = DateTime.Now;
            model.Rol       = ctx.Rol.FirstOrDefault(x => x.adi == "Kullanici");
            model.engellimi = false;
            model.onaylimi  = false;

            ctx.Kullanici.Add(model);
            ctx.SaveChanges();

            TempData["Mesaj"]    = "Kullanıcı Kayıtı Tamamlandı.(Mail'inize Hesap Onay Linki Gitmiştir. Hesabı Aktifleştirmek İçin Linke Tıklayınız.)"; // redirect yapılan sayfa için temp data ile hata mesajı atılır
            TempData["MesajTip"] = "success";                                                                                                           // success info warning danger
            return(RedirectToAction("Giris"));
        }
示例#17
0
        public ActionResult İlanEkle(ilan ilan, IEnumerable <HttpPostedFileBase> gelenResim)
        {
            if (!ModelState.IsValid)
            {
                return(İlanEkle());
            }
            if (ilan.baslik == "" || ilan.aciklama == "" || ilan.sorunu == "")
            {
                TempData["Mesaj"]    = "Boş Bırakılan Yerleri Doldurunuz";
                TempData["MesajTip"] = "danger"; // success info warning danger
                return(İlanEkle());              // get olan kısım çalışsın aynı sayfaya gitsin giderken de viewbag ile istenilen listeleri versin
            }

            bool hicresimyok = true;

            foreach (HttpPostedFileBase resim in gelenResim)
            {
                if (resim != null)
                {
                    hicresimyok = false;
                    break;
                }
            }

            if (hicresimyok)
            {
                TempData["Mesaj"]    = "En Az 1 Resim Olmalı";
                TempData["MesajTip"] = "warning"; // success info warning danger
                return(İlanEkle());               // get olan kısım çalışsın aynı sayfaya gitsin giderken de viewbag ile istenilen listeleri versin
            }

            ilan.id           = Guid.NewGuid();
            ilan.ilanacikmi   = true;
            ilan.ilantarih    = DateTime.Now;
            ilan.satildimi    = false;
            ilan.kullanici_id = ((Kullanici)Session["Kullanici"]).id;
            ilan.konum        = null; // yapılabilir.

            int resim_sirasi = 1;

            foreach (HttpPostedFileBase resim in gelenResim)
            {
                if (resim != null)
                {
                    ilanResim ir = new ilanResim();
                    ir.ad = ResimIslem.Ekle(resim, ResimIslemTip.İlan);
                    if (ir.ad == "uzanti")
                    {
                        TempData["Mesaj"]    = "Resimin Uzantisi Farklı";
                        TempData["MesajTip"] = "danger"; // success info warning danger
                        return(İlanEkle());              // get olan kısım çalışsın aynı sayfaya gitsin giderken de viewbag ile istenilen listeleri versin
                    }
                    else if (ir.ad == "boyut")
                    {
                        TempData["Mesaj"]    = "Resimin Boyutu Fazla";
                        TempData["MesajTip"] = "danger"; // success info warning danger
                        return(İlanEkle());              // get olan kısım çalışsın aynı sayfaya gitsin giderken de viewbag ile istenilen listeleri versin
                    }
                    ir.id      = Guid.NewGuid();
                    ir.ilan_id = ilan.id;
                    ir.sirasi  = resim_sirasi;
                    ctx.ilanResim.Add(ir);
                }
                resim_sirasi++;
            }
            ctx.ilan.Add(ilan);
            ctx.SaveChanges();
            return(RedirectToAction("ilanlar"));
        }
示例#18
0
        [HttpPost] // DENEE
        public ActionResult İlanDuzenle(ilan model, IEnumerable <HttpPostedFileBase> gelenResim)
        {
            ilan ilan = ctx.ilan.FirstOrDefault(x => x.id == model.id);

            if (ilan == null)
            {
                ViewBag.Mesaj = "İlan Bulunamadı";
                return(View());
            }
            ilan.aciklama   = model.aciklama;
            ilan.baslik     = model.baslik;
            ilan.ilanacikmi = model.ilanacikmi;
            ilan.il         = model.il;
            if (model.ilce != "0")
            {
                ilan.ilce = model.ilce;
            }
            if (model.mahalle != "0")
            {
                ilan.mahalle = model.mahalle;
            }
            ilan.kullanimsuresi = model.kullanimsuresi;
            ilan.satildimi      = model.satildimi;
            ilan.sorunu         = model.sorunu;
            ilan.fiyat          = model.fiyat;
            ilan.kategori_id    = model.kategori_id;

            bool hicresimyok = true;

            foreach (HttpPostedFileBase resim in gelenResim)
            {
                if (resim != null)
                {
                    hicresimyok = false;
                    break;
                }
            }

            if (!hicresimyok) // gelen resim varsa resim eklenir.
            {
                int resim_sirasi = 1;
                foreach (HttpPostedFileBase resim in gelenResim)
                {
                    if (resim != null)
                    {
                        // önceden ilanda o SIRA NUMARASINDA resim varsa o silinir.
                        ilanResim ilanResim = ctx.ilanResim.FirstOrDefault(x => x.ilan_id == ilan.id && x.sirasi == resim_sirasi);
                        if (ilanResim != null)
                        {
                            string sonuc = ResimIslem.Sil(ilanResim.ad, ResimIslemTip.İlan);
                            if (sonuc == "Silindi")
                            {
                                ctx.ilanResim.Remove(ilanResim);
                            }
                            else
                            {
                                ViewBag.Mesaj = "Eski Resim Silinemedi // Bulunamadı";
                                return(İlanDuzenle(model.id.ToString()));
                            }
                        }
                        // resim ekleme
                        ilanResim ir = new ilanResim();
                        ir.ad = ResimIslem.Ekle(resim, ResimIslemTip.İlan);
                        if (ir.ad == "uzanti")
                        {
                            TempData["Mesaj"] = "Resimin Uzantisi Farklı";
                            return(İlanDuzenle(model.id.ToString())); // get olan kısım çalışsın aynı sayfaya gitsin giderken de viewbag ile istenilen listeleri versin
                        }
                        else if (ir.ad == "boyut")
                        {
                            TempData["Mesaj"] = "Resimin Boyutu Fazla";
                            return(İlanDuzenle(model.id.ToString()));// get olan kısım çalışsın aynı sayfaya gitsin giderken de viewbag ile istenilen listeleri versin
                        }
                        ir.id      = Guid.NewGuid();
                        ir.ilan_id = ilan.id;
                        ir.sirasi  = resim_sirasi;
                        ctx.ilanResim.Add(ir);
                    }
                    resim_sirasi++;
                }
            }
            ctx.SaveChanges();
            return(RedirectToAction("İlanlar"));
        }
        public ActionResult Duzenle(kullanici k, HttpPostedFileBase resimGelen)

        {
            int       kullaniciID = (int)TempData["kullaniciID"];
            kullanici kul         = db.kullanici.Where(x => x.kullaniciID == kullaniciID).SingleOrDefault();


            //boş gelmesi durumu
            if (resimGelen != null)
            {
                ResimIslem r     = new ResimIslem();
                string     deger = r.Ekle(resimGelen);


                if (deger == "uzanti")
                {
                    var yetkiler = db.yetki.ToList();
                    ViewBag.yetkiler = new SelectList(yetkiler, "yetkiID", "adi", kul.yetkiID);
                    ViewBag.Hata     = "Lütfen .png veya .jpg uzantılı resim seçiniz!";
                    return(View(kul));
                }

                else if (deger == "boyut")
                {
                    var yetkiler = db.yetki.ToList();
                    ViewBag.yetkiler = new SelectList(yetkiler, "yetkiID", "adi", kul.yetkiID);
                    ViewBag.Hata     = "Lütfen daha küçük boyutlu bir resim seçiniz!";
                    return(View(kul));
                }

                else
                {
                    k.resim = deger;
                }
            }

            if (k.resim != null)
            {
                //yeni resim sorunsuz eklendiyse
                if (kul.resim != "bos.png")
                {
                    //eski resmi silmek icin
                    new ResimIslem().Sil(kul.resim);
                }
                //yeni resmi atamak icin
                kul.resim = k.resim;
            }



            kul.ad      = k.ad;
            kul.soyad   = k.soyad;
            kul.eposta  = k.eposta;
            kul.sifre   = k.sifre;
            kul.yetkiID = k.yetkiID;
            db.SaveChanges();



            return(RedirectToAction("Index"));
        }
        public ActionResult KayitOl(string ad, string soyad, HttpPostedFileBase profilFotografi, string sifretekrari, string eposta, string sifre, string kullaniciadi, string kayitturu, string ogrenciNumarasi)
        {
            Kullanicilar tempKullanici = kullaniciManager.Find(x => x.EPosta == eposta || x.KullaniciAdi == kullaniciadi || x.Ogrenciler.OgrenciNumarasi == ogrenciNumarasi);

            if (tempKullanici == null)
            {
                if (ad != null && soyad != null && sifretekrari != null && eposta != null && sifre != null && kullaniciadi != null)
                {
                    if (sifre == sifretekrari)
                    {
                        try
                        {
                            string fotograf = "";
                            kullanici = new Kullanicilar();
                            kullanici.KullaniciAdi = kullaniciadi;
                            kullanici.Sifre        = sifre;
                            kullanici.EPosta       = eposta;
                            if (kayitturu == "1")
                            {
                                ogrenci                 = new Ogrenciler();
                                ogrenci.OgrenciAdi      = ad;
                                ogrenci.OgrenciSoyadi   = soyad;
                                ogrenci.OgrenciNumarasi = ogrenciNumarasi;
                                kullanici.Yetki         = yetkiManager.Find(x => x.YetkiAdi == "Ogrenci");
                                if (profilFotografi != null)
                                {
                                    string     yeniResimAdi = "";
                                    ResimIslem r            = new ResimIslem();
                                    yeniResimAdi = r.Ekle(profilFotografi);
                                    //yeniResimAdi = new ResimIslem().Ekle(resimGelen);

                                    if (yeniResimAdi == "uzanti")
                                    {
                                        ViewData["Hata"] = "Lütfen .png veya .jpg uzantılı dosya giriniz.";
                                    }
                                    else if (yeniResimAdi == "boyut")
                                    {
                                        ViewData["Hata"] = "En fazla 1MB boyutunda dosya girebilirsiniz.";
                                    }
                                    else
                                    {
                                        fotograf = yeniResimAdi;
                                    }
                                    ogrenci.OgrenciFotografi = fotograf;
                                    kullanici.Ogrenciler     = ogrenci;
                                }
                            }
                            if (kayitturu == "2")
                            {
                                ogretmen                = new Ogretmenler();
                                ogretmen.OgretmenAdi    = ad;
                                ogretmen.OgretmenSoyadi = soyad;
                                kullanici.Yetki         = yetkiManager.Find(x => x.YetkiAdi == "Ogretmen");
                                if (profilFotografi != null)
                                {
                                    string             yeniResimAdi = "";
                                    ResimIslemOgretmen r            = new ResimIslemOgretmen();
                                    yeniResimAdi = r.Ekle(profilFotografi);
                                    //yeniResimAdi = new ResimIslem().Ekle(resimGelen);

                                    if (yeniResimAdi == "uzanti")
                                    {
                                        ViewData["Hata"] = "Lütfen .png veya .jpg uzantılı dosya giriniz.";
                                    }
                                    else if (yeniResimAdi == "boyut")
                                    {
                                        ViewData["Hata"] = "En fazla 1MB boyutunda dosya girebilirsiniz.";
                                    }
                                    else
                                    {
                                        fotograf = yeniResimAdi;
                                    }
                                    ogretmen.OgretmenFotografi = fotograf;
                                    kullanici.Ogretmenler      = ogretmen;
                                }
                            }
                            using (var client = new HttpClient())
                            {
                                var jsonformatter = new JsonMediaTypeFormatter();
                                jsonformatter.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
                                client.BaseAddress = new Uri("http://localhost:64663/api/LoginApi/Kayit");
                                var postTask = client.PostAsync("Kayit", kullanici, jsonformatter);
                                postTask.Wait();

                                var result = postTask.Result;

                                if (result.IsSuccessStatusCode)
                                {
                                    TempData["mesaj"] = "Kayıt işlemi başarılı bir şekilde tamamlandı.";
                                    return(RedirectToAction("Index", "Login"));
                                }
                                else
                                {
                                    TempData["mesaj"] = "Hatalı Bilgi Girişi";
                                    return(RedirectToAction("Index", "Login"));
                                }
                            }
                        }
                        catch (DbEntityValidationException e)
                        {
                            TempData["mesaj"] = "Sunucuyla bağlantı kurulamadı.";
                        }
                    }

                    return(RedirectToAction("Index", "Login"));
                }
                TempData["mesaj"] = "Eksik Bilgi Girişi";
            }
            else
            {
                TempData["mesaj"] = "Kullanıcı Sistemle Kayıtlı Tekrar Deneyin";
            }

            return(RedirectToAction("Index", "Login"));
        }
示例#21
0
        public ActionResult İlanSil(string id)
        {
            //ÖNCESİNDE BAĞLI OLDUĞU HER ŞEYİ SİLMELİSİN !!!!
            Guid kullanici_id = ((Kullanici)Session["Kullanici"]).id;
            ilan ilanim       = ctx.ilan.FirstOrDefault(x => x.id == new Guid(id) && x.kullanici_id == kullanici_id);

            if (ilanim == null)
            {
                TempData["Mesaj"]    = "Belirtilen İlan Bulunamadı";
                TempData["MesajTip"] = "danger"; // success info warning danger
                return(RedirectToAction("Index"));
            }

            List <ilanMesaj> ilanMesajs = ctx.ilanMesaj.Where(x => x.ilan_id == ilanim.id).ToList();

            if (ilanMesajs != null)
            {
                foreach (ilanMesaj item in ilanMesajs)
                {
                    List <Mesaj> mesajs = ctx.Mesaj.Where(x => x.ilanmesaj_id == item.id).ToList();
                    if (mesajs != null)
                    {
                        foreach (Mesaj item2 in mesajs)
                        {
                            ctx.Mesaj.Remove(item2);//Mesaj
                        }
                    }
                    ctx.ilanMesaj.Remove(item);//ilanMesaj
                }
            }

            List <Favoriilan> favoriilans = ctx.Favoriilan.Where(x => x.ilan_id == ilanim.id).ToList();

            if (favoriilans != null)
            {
                foreach (Favoriilan item in favoriilans)
                {
                    ctx.Favoriilan.Remove(item);//Favori
                }
            }

            AcikArtirma acikArtirma = ilanim.AcikArtirma;

            if (acikArtirma != null)
            {
                List <Teklif> teklifs = ctx.Teklif.Where(x => x.acikartirma_id == acikArtirma.id).ToList();
                if (teklifs != null)
                {
                    foreach (Teklif item in teklifs)
                    {
                        ctx.Teklif.Remove(item);//Teklif
                    }
                }
                ctx.AcikArtirma.Remove(acikArtirma);//AcikArtirma
            }

            List <OneCikar> oneCikars = ctx.OneCikar.Where(x => x.ilan_id == ilanim.id).ToList();

            if (oneCikars != null)
            {
                foreach (OneCikar item in oneCikars)
                {
                    ctx.OneCikar.Remove(item);//ÖneCikarma
                }
            }

            List <ilanResim> ilanResims = ctx.ilanResim.Where(x => x.ilan_id == ilanim.id).ToList();

            foreach (ilanResim item in ilanResims)
            {
                ResimIslem.Sil(item.ad, ResimIslemTip.İlan); //ilanResim
                ctx.ilanResim.Remove(item);                  //ilanResim
            }
            ctx.ilan.Remove(ilanim);
            ctx.SaveChanges();
            TempData["Mesaj"]    = "İlan Silindi";
            TempData["MesajTip"] = "info"; // success info warning danger
            return(RedirectToAction("ilanlar"));
        }