public ActionResult DeleteConfirmed(int id) { OgrenciBilgileri ogrenciBilgileri = db.OgrenciBilgileri.Find(id); db.OgrenciBilgileri.Remove(ogrenciBilgileri); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "OgrenciID,Adres,Telefon,TCNo,OgrenciMail,MezunMu,Fotograf,Sifre")] OgrenciBilgileri ogrenciBilgileri) { if (ModelState.IsValid) { db.Entry(ogrenciBilgileri).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.OgrenciID = new SelectList(db.Ogrenciler, "OgrenciID", "OgrenciAdi", ogrenciBilgileri.OgrenciID); return(View(ogrenciBilgileri)); }
public static void OgrenciEkle(Ogrenci ogrenci, OgrenciBilgileri ogrenciBilgileri) { OgrenciConcrete ogrenciConcrete = new OgrenciConcrete(); OgrenciBilgileriConcrete ogrenciBilgileriConcrete = new OgrenciBilgileriConcrete(); var roleStore = new RoleStore <IdentityRole>(ogrenciConcrete._dbContext); var roleManager = new RoleManager <IdentityRole>(roleStore); var userStore = new UserStore <Kullanici>(ogrenciConcrete._dbContext); var userManager = new UserManager <Kullanici>(userStore); var kullanici = userManager.FindByName((ogrenci.OgrenciAdi.ToLower() + ogrenci.OgrenciSoyadi.ToLower())); if (kullanici == null) { kullanici = new Kullanici() { UserName = ogrenci.OgrenciAdi.ToLower() + ogrenci.OgrenciSoyadi.ToLower(), Email = ogrenci.OgrenciAdi.ToLower() + ogrenci.OgrenciSoyadi.ToLower() + "@uni.edu.tr" }; } else { int sayi = 0; while (kullanici != null) { sayi++; kullanici = userManager.FindByName((ogrenci.OgrenciAdi.ToLower() + ogrenci.OgrenciSoyadi.ToLower() + sayi)); } kullanici = new Kullanici() { UserName = ogrenci.OgrenciAdi.ToLower() + ogrenci.OgrenciSoyadi.ToLower() + sayi, Email = ogrenci.OgrenciAdi.ToLower() + ogrenci.OgrenciSoyadi.ToLower() + sayi + "@uni.edu.tr" }; } //Yapicalak: Sifre kisminda TC Ogrenci kismina alinacak, asagidaki ornek gibi sifre girisi yapilacak. //Muhammed Talha Balci //Mb123717238192739. string sifre = ogrenci.OgrenciAdi.Substring(0, 1).ToUpper() + ogrenci.OgrenciAdi.Substring(1) + ogrenci.KayitTarihi.Date.Year + "."; var result = userManager.Create(kullanici, sifre); if (result.Succeeded) { userManager.AddToRole(kullanici.Id, "ogrenci"); } ogrenci.OgrenciID = kullanici.Id; ogrenciBilgileri.OgrenciID = ogrenci.OgrenciID; ogrenciBilgileri.OgrenciMail = kullanici.Email; ogrenciConcrete._ogrenciRepository.Insert(ogrenci); ogrenciConcrete._ogrenciUnitOfWork.SaveChanges(); ogrenciConcrete._ogrenciUnitOfWork.Dispose(); ogrenciBilgileriConcrete._ogrenciBilgileriRepository.Insert(ogrenciBilgileri); ogrenciBilgileriConcrete._ogrenciBilgileriUnitOfWork.SaveChanges(); ogrenciBilgileriConcrete._ogrenciBilgileriUnitOfWork.Dispose(); }
// GET: OgrenciBilgileri/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } OgrenciBilgileri ogrenciBilgileri = db.OgrenciBilgileri.Find(id); if (ogrenciBilgileri == null) { return(HttpNotFound()); } return(View(ogrenciBilgileri)); }
public ActionResult DeleteConfirmed(string id) { Ogrenci ogrenci = ogrenciConcrete._ogrenciRepository.GetById(id); OgrenciBilgileri ogrenciBilgileri = ogrenciBilgileriConcrete._ogrenciBilgileriRepository.GetById(id); ogrenci.MezuniyetTarihi = DateTime.Now; ogrenciBilgileri.MezunMu = true; ogrenciConcrete._ogrenciRepository.Update(ogrenci); ogrenciConcrete._ogrenciUnitOfWork.SaveChanges(); ogrenciConcrete._ogrenciUnitOfWork.Dispose(); ogrenciBilgileriConcrete._ogrenciBilgileriRepository.Update(ogrenciBilgileri); ogrenciBilgileriConcrete._ogrenciBilgileriUnitOfWork.SaveChanges(); ogrenciBilgileriConcrete._ogrenciBilgileriUnitOfWork.Dispose(); return(RedirectToAction("Index")); }
// GET: OgrenciBilgileri/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } OgrenciBilgileri ogrenciBilgileri = db.OgrenciBilgileri.Find(id); if (ogrenciBilgileri == null) { return(HttpNotFound()); } ViewBag.OgrenciID = new SelectList(db.Ogrenciler, "OgrenciID", "OgrenciAdi", ogrenciBilgileri.OgrenciID); return(View(ogrenciBilgileri)); }
public ActionResult Create([Bind(Include = "OgrenciID,OgrenciAdi,OgrenciSoyadi,OgrenciNumarasi,KayitTarihi,MezuniyetTarihi,FakulteBolumlerID,OgrencininFakulteBolumu,OgrenimSekliID,EgitimDuzeyiID")] Ogrenci ogrenci, FormCollection frm, HttpPostedFileBase file) { if (ModelState.IsValid) { string ad = ""; if (file != null) { if (file.ContentLength > 0) { if (Path.GetExtension(file.FileName).ToLower() == ".jpg" || Path.GetExtension(file.FileName).ToLower() == ".png" || Path.GetExtension(file.FileName).ToLower() == ".gif" || Path.GetExtension(file.FileName).ToLower() == ".jpeg") { ad = Guid.NewGuid() + Path.GetExtension(file.FileName); var path = Path.Combine(Server.MapPath("~/images"), ad); file.SaveAs(path); } } } ogrenci.KayitTarihi = DateTime.Parse(frm["kayitTarihi"]); ogrenci.FakulteBolumlerID = int.Parse(frm["bolumId"]); int sayi = ogrenciConcrete._ogrenciRepository.GetEntity().Where(x => x.FakulteBolumlerID == ogrenci.FakulteBolumlerID).Count() + 1; FakulteBolumler fakulteBolumler = fakulteBolumlerConcrete._fakulteBolumlerRepository.GetById(int.Parse(frm["bolumId"])); ogrenci.OgrenciNumarasi = ogrenci.KayitTarihi.Year.ToString() + ogrenci.EgitimDuzeyiID + ogrenci.OgrenimSekliID + fakulteBolumler.FakulteID + fakulteBolumler.BolumID + sayi; OgrenciBilgileri ogrenciBilgileri = new OgrenciBilgileri() { Adres = frm["adres"], Fotograf = ad, OgrenciID = ogrenci.OgrenciID, TCNo = frm["tc"], Telefon = frm["telefon"], MezunMu = false }; KullaniciIslemleri.OgrenciEkle(ogrenci, ogrenciBilgileri); return(RedirectToAction("Index")); } return(View(ogrenci)); }