public JsonResult List()
 {
     using (TezProjectEntities db = new TezProjectEntities())
     {
         return(Json(db.Duyurus.ToList(), JsonRequestBehavior.AllowGet));
     }
 }
 public ActionResult Onaylama(KullaniciOnayModel model)
 {
     if (ModelState.IsValid)
     {
         using (TezProjectEntities db = new TezProjectEntities())
         {
             for (int i = 0; i < model.SecilmisKullanicilar.Count; i++)
             {
                 int Bekleyen_id = model.SecilmisKullanicilar[i];
                 Bekleyen_Kullanici bekleyenkullanici = db.Bekleyen_Kullanici.Where(x => x.B_Id == Bekleyen_id).FirstOrDefault();
                 if (bekleyenkullanici != null)
                 {
                     Kullanici kullanici = new Kullanici();
                     kullanici.Kullanici_Adi = bekleyenkullanici.Kullanici_Adi;
                     kullanici.Ad            = bekleyenkullanici.Ad;
                     kullanici.Soyad         = bekleyenkullanici.Soyad;
                     kullanici.Sifre         = bekleyenkullanici.Sifre;
                     kullanici.Email         = bekleyenkullanici.Email;
                     kullanici.user_type     = bekleyenkullanici.Kullanici_Tipi;
                     db.Kullanicis.Add(kullanici);
                     db.Bekleyen_Kullanici.Remove(bekleyenkullanici);
                     db.SaveChanges();
                     return(RedirectToAction("Success"));
                 }
             }
         }
     }
     return(RedirectToAction("Fail"));
 }
 public ActionResult DosyaYukle(string Gorev_Id, string Kullanici_Id, HttpPostedFileBase dosya)
 {
     using (TezProjectEntities db = new TezProjectEntities())
     {
         try
         {
             string dosyaYolu   = Gorev_Id + Kullanici_Id + Path.GetFileName(dosya.FileName);
             var    yuklemeYeri = Path.Combine(Server.MapPath("~/UploadedFiles"), dosyaYolu);
             dosya.SaveAs(yuklemeYeri);
             Dosya dosyam = new Dosya();
             dosyam.Gorev_Id       = Convert.ToInt32(Gorev_Id);
             dosyam.Kullanici_Id   = Convert.ToInt32(Kullanici_Id);
             dosyam.Dosya_Adi      = dosyaYolu;
             dosyam.Yukleme_Yeri   = yuklemeYeri;
             dosyam.Dosya_Uzantisi = Path.GetExtension(dosya.FileName);
             //TODO: Dosya Uzantısı kontrol edilecek.
             db.Dosyas.Add(dosyam);
             db.SaveChanges();
             TempData["Message"] = Gorev_Id + " Idli gorev için dosya Yukleme işlemi Başarılı";
             return(RedirectToAction("OgrenciGorevListele"));
         }
         catch (Exception)
         {
             TempData["Message"] = Gorev_Id + " Idli gorev için dosya Yukleme işlemi Başarısız";
             return(RedirectToAction("OgrenciGorevListele"));
         }
     }
 }
        public override string[] GetRolesForUser(string kullanici_adi)
        {
            TezProjectEntities db   = new TezProjectEntities();
            string             data = db.Kullanicis.Where(x => x.Kullanici_Adi == kullanici_adi).FirstOrDefault().user_type;

            string[] result = { data.Trim() };
            return(result);
        }
 public ActionResult Duyurular()
 {
     using (TezProjectEntities db = new TezProjectEntities())
     {
         var model = db.Duyurus.ToList();
         return(View(model));
     }
 }
 // GET: LoggedDanisman
 public ActionResult GorevBilgisiListele()
 {
     using (TezProjectEntities db = new TezProjectEntities())
     {
         var model = db.Gorevs.ToList();
         return(View(model));
     }
 }
 public ActionResult DuyuruDetay(int duyuruID)
 {
     using (TezProjectEntities db = new TezProjectEntities())
     {
         Duyuru model = db.Duyurus.Where(x => x.Duyuru_Id.Equals(duyuruID)).FirstOrDefault();
         return(View(model));
     }
 }
 public ActionResult DosyaIndır(int kullanici_Id, int gorev_Id)
 {
     using (TezProjectEntities db = new TezProjectEntities())
     {
         Dosya dosya = db.Dosyas.Where(x => x.Gorev_Id == gorev_Id && x.Kullanici_Id == kullanici_Id).FirstOrDefault();
         //return File("~/Content/MyFile.pdf", "application/pdf", "MyRenamedFile.pdf");
         return(File(dosya.Yukleme_Yeri, dosya.Dosya_Uzantisi, dosya.Dosya_Adi));
     }
 }
        public JsonResult GetbyID(int ID)
        {
            using (TezProjectEntities db = new TezProjectEntities())
            {
                Duyuru duyuru = db.Duyurus.Where(x => x.Duyuru_Id.Equals(ID)).FirstOrDefault();

                return(Json(duyuru, JsonRequestBehavior.AllowGet));
            }
        }
 public ActionResult OgrenciGorevListele()
 {
     using (TezProjectEntities db = new TezProjectEntities())
     {
         ViewBag.Message = TempData["Message"];
         var model = db.Gorevs.ToList();
         return(View(model));
     }
 }
 public ActionResult GorevDosyaYukle(int gorev_Id)
 {
     using (TezProjectEntities db = new TezProjectEntities())
     {
         GorevModel model = new GorevModel();
         model.Kullanici_Id = db.Kullanicis.Where(x => x.Kullanici_Adi == User.Identity.Name).FirstOrDefault().Kullanici_Id;
         model.Gorev_Id     = gorev_Id;
         return(View(model));
     }
 }
 public ActionResult Onaylama()
 {
     using (TezProjectEntities database = new TezProjectEntities())
     {
         var model = new KullaniciOnayModel {
             TumKullanicilar = database.Bekleyen_Kullanici.ToList()
         };
         return(View(model));
     }
 }
 public JsonResult Delete(int ID)
 {
     using (TezProjectEntities db = new TezProjectEntities())
     {
         Duyuru duyuru = db.Duyurus.Where(x => x.Duyuru_Id.Equals(ID)).FirstOrDefault();
         db.Duyurus.Remove(duyuru);
         db.SaveChanges();
         return(Json(db.Duyurus.ToList(), JsonRequestBehavior.AllowGet));
     }
 }
 public ActionResult GorevEkle(Gorev gorev)
 {
     using (TezProjectEntities db = new TezProjectEntities())
     {
         db.Gorevs.Add(gorev);
         db.SaveChanges();
         TempData["Message"] = "Gorev Ekleme İşleme işlemi başarılı";
         return(RedirectToAction("GorevListele"));
     }
 }
 public JsonResult Update(Duyuru gelenduyuru)
 {
     using (TezProjectEntities db = new TezProjectEntities())
     {
         Duyuru duyuru = db.Duyurus.Where(x => x.Duyuru_Id.Equals(gelenduyuru.Duyuru_Id)).FirstOrDefault();
         duyuru.Duyuru_Basligi = gelenduyuru.Duyuru_Basligi;
         duyuru.Duyuru_Icerigi = gelenduyuru.Duyuru_Icerigi;
         db.SaveChanges();
         return(Json(db.Duyurus.ToList(), JsonRequestBehavior.AllowGet));
     }
 }
 public ActionResult BilgileriniDuzenle()
 {
     using (TezProjectEntities db = new TezProjectEntities())
     {
         ViewBag.Message = TempData["Message"];
         OgrenciModel omodel   = new OgrenciModel();
         string       username = User.Identity.Name;
         omodel.kogrenci = db.Kullanicis.Where(x => x.Kullanici_Adi.Equals(username)).FirstOrDefault();
         omodel.ogrenci  = db.Ogrencis.Where(x => x.Kullanici_Id.Equals(omodel.kogrenci.Kullanici_Id)).FirstOrDefault();
         return(View(omodel));
     }
 }
 public JsonResult Add(Duyuru duyuru)
 {
     using (TezProjectEntities db = new TezProjectEntities())
     {
         Duyuru yeniduyuru = new Duyuru();
         yeniduyuru.Duyuru_Basligi = duyuru.Duyuru_Basligi;
         yeniduyuru.Duyuru_Icerigi = duyuru.Duyuru_Icerigi;
         db.Duyurus.Add(yeniduyuru);
         db.SaveChanges();
         return(Json(db.Duyurus.ToList(), JsonRequestBehavior.AllowGet));
     }
 }
 public ActionResult BilgileriniDuzenle()
 {
     using (TezProjectEntities db = new TezProjectEntities())
     {
         ViewBag.Message = TempData["Message"];
         KoordinatorModel kmodel   = new KoordinatorModel();
         string           username = User.Identity.Name;
         kmodel.kkoordinator = db.Kullanicis.Where(x => x.Kullanici_Adi.Equals(username)).FirstOrDefault();
         kmodel.koordinator  = db.Koordinators.Where(x => x.Kullanici_Id.Equals(kmodel.kkoordinator.Kullanici_Id)).FirstOrDefault();
         return(View(kmodel));
     }
 }
 public ActionResult DanismanAtamaIslemi(DanismanAtamaModel model)
 {
     using (TezProjectEntities db = new TezProjectEntities())
     {
         Tez tez = new Tez();
         tez.Ogrenci_Id  = model.Kullanici_Id;
         tez.Danisman_Id = model.secilenDanismanId;
         db.Tezs.Add(tez);
         db.SaveChanges();
         TempData["Message"] = "Atama işlemi başarılı";
         return(RedirectToAction("DanismanAtama"));
     }
 }
 public ActionResult DanismanAtama()
 {
     using (TezProjectEntities db = new TezProjectEntities())
     {
         ViewBag.Message = TempData["Message"];
         DanismanAtamaModel model   = new DanismanAtamaModel();                    // Ogrenci ve Danisman listesi, kullanici_id ve danisman_ıd tutar;
         var ogrenciIdswithDanisman = db.Tezs.Select(s => s.Ogrenci_Id).ToArray(); // Danisman atanmıs ogrenciler
         var query = from kullanicilar in db.Kullanicis.Where(x => x.user_type == "Ogrenci")
                     where !ogrenciIdswithDanisman.Contains(kullanicilar.Kullanici_Id)
                     select kullanicilar;// Danismanı olmayan ogrencileri bulur.
         model.ogrenciler  = query.ToList();
         model.danismanlar = db.Kullanicis.Where(x => x.user_type == "Danisman").ToList();
         return(View(model));
     }
 }
 public ActionResult TezGuncelle(string Ogrenci_Id, string Danisman_Id, string Abstract, string Donem)
 {
     using (TezProjectEntities db = new TezProjectEntities())
     {
         string    username  = User.Identity.Name;
         Tez       tez       = new Tez();
         Kullanici kullanici = db.Kullanicis.Where(x => x.Kullanici_Adi.Equals(username)).FirstOrDefault();
         tez          = db.Tezs.Where(x => x.Ogrenci_Id.Equals(kullanici.Kullanici_Id)).FirstOrDefault();
         tez.Abstract = Abstract;
         tez.Donem    = Donem;
         db.SaveChanges();
         TempData["Message"] = "Güncelleme İşlemi Başarılı";
         return(RedirectToAction("TezDuzenle"));
     }
 }
 public ActionResult BilgileriGuncelle(string Ogrenci_No, string Ad, string Soyad, string Sifre, string Email)
 {
     using (TezProjectEntities db = new TezProjectEntities())
     {
         string    username  = User.Identity.Name;
         Kullanici kullanici = db.Kullanicis.Where(x => x.Kullanici_Adi.Equals(username)).FirstOrDefault();
         Ogrenci   ogrenci   = db.Ogrencis.Where(x => x.Kullanici_Id.Equals(kullanici.Kullanici_Id)).FirstOrDefault();
         ogrenci.Ogrenci_No = Ogrenci_No;
         kullanici.Ad       = Ad;
         kullanici.Soyad    = Soyad;
         kullanici.Sifre    = Sifre;
         kullanici.Email    = Email;
         db.SaveChanges();
         TempData["Message"] = "Güncelleme İşlemi Başarılı";
         return(RedirectToAction("BilgileriniDuzenle"));
     }
 }
 public ActionResult TezDuzenle()
 {
     using (TezProjectEntities db = new TezProjectEntities())
     {
         ViewBag.Message = TempData["Message"];
         Tez       tez       = new Tez();
         string    username  = User.Identity.Name;
         Kullanici kullanici = db.Kullanicis.Where(x => x.Kullanici_Adi.Equals(username)).FirstOrDefault();
         tez = db.Tezs.Where(x => x.Ogrenci_Id.Equals(kullanici.Kullanici_Id)).FirstOrDefault();
         if (tez == null)
         {
             TempData["Message"] = "Ogrenci Danisman Ataması Beklemektedir";
             return(RedirectToAction("DanismanOnayBekleme"));
         }
         else
         {
             return(View(tez));
         }
     }
 }
        public ActionResult GorevAyrinti(int gorev_Id)
        {
            using (TezProjectEntities db = new TezProjectEntities())
            {
                GorevAyrintiModel gayrinti = new GorevAyrintiModel();
                // O görev için Dosya yükleyen Öğrencileri listele. Öğrenciye tıklayinca yuklediği dosyayı indirme sayfası açılsın
                List <Dosya> dosyalar           = db.Dosyas.Where(x => x.Gorev_Id == gorev_Id).ToList();
                int          currentDanisman_Id = db.Kullanicis.Where(x => x.Kullanici_Adi == User.Identity.Name).FirstOrDefault().Kullanici_Id;

                foreach (Dosya dosya in dosyalar)
                {
                    Kullanici kullanici = db.Kullanicis.Where(x => x.Kullanici_Id == dosya.Kullanici_Id).FirstOrDefault();
                    Tez       tez       = db.Tezs.Where(x => x.Ogrenci_Id == kullanici.Kullanici_Id && x.Danisman_Id == currentDanisman_Id).FirstOrDefault();
                    if (tez != null)
                    {
                        gayrinti.dosyaYukleyenKullanicilar.Add(kullanici);
                    }
                }

                gayrinti.Gorev_Id = gorev_Id;
                return(View(gayrinti));
            }
        }
        public ActionResult Login(Kullanici model, string returnUrl)
        {
            TezProjectEntities db = new TezProjectEntities();
            var dataItem          = db.Kullanicis.Where(x => x.Kullanici_Adi == model.Kullanici_Adi && x.Sifre == model.Sifre).FirstOrDefault();

            if (dataItem != null)
            {
                FormsAuthentication.SetAuthCookie(dataItem.Kullanici_Adi, false);
                if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") &&
                    !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))

                {
                    return(Redirect(returnUrl));
                }
                else if (dataItem.user_type.Trim() == "Koordinator")
                {
                    return(RedirectToAction("Index", "LoggedKoordinator"));
                }
                else if (dataItem.user_type.Trim() == "Danisman")
                {
                    return(RedirectToAction("Index", "LoggedDanisman"));
                }
                else if (dataItem.user_type.Trim() == "Ogrenci")
                {
                    return(RedirectToAction("Index", "LoggedOgrenci"));
                }
                else
                {
                    return(Redirect(returnUrl));
                }
            }
            else
            {
                ModelState.AddModelError("", "Invalid user/pass");
                return(View());
            }
        }
        public ActionResult Register(Bekleyen_Kullanici model)
        {
            if (ModelState.IsValid)
            {
                using (TezProjectEntities db = new TezProjectEntities())
                {
                    var gelenBekleyen  = db.Bekleyen_Kullanici.Where(x => x.Kullanici_Adi == model.Kullanici_Adi).FirstOrDefault();
                    var gelenKullanici = db.Kullanicis.Where(x => x.Kullanici_Adi == model.Kullanici_Adi).FirstOrDefault();
                    if (gelenBekleyen == null && gelenKullanici == null)
                    {
                        db.Bekleyen_Kullanici.Add(model);
                        db.SaveChanges();
                        ViewBag.Message = "Kayıt onaya gonderildi";
                    }
                    else
                    {
                        ViewBag.Message = "Bu kullanici adina sahip bir kullanici var. Lutfen Kullanici Adinizi Degistiriniz.";
                    }
                }
            }

            //return RedirectToAction("Index","Home"); ;
            return(View());
        }