public ActionResult YoneticiGuncelle(FormCollection frm) { yoneticiConcrete = new YoneticiConcrete(); Yonetici yonetici = yoneticiConcrete._yoneticiRepository.GetById(Convert.ToInt32(frm["YoneticiID"])); yonetici.KullaniciAdi = frm["KullaniciAdi"]; yonetici.Sifre = frm["Sifre"]; yonetici.AktifMi = true; yoneticiConcrete._yoneticiUnitOfWork.SaveChanges(); yoneticiConcrete._yoneticiUnitOfWork.Dispose(); Session["KullaniciAdi"] = null; return(RedirectToAction("Giris", "Yonetici")); }
public static void YoneticiEkle(Yonetici yonetici) { YoneticiConcrete yoneticiConcrete = new YoneticiConcrete(); var roleStore = new RoleStore <IdentityRole>(yoneticiConcrete._dbContext); var roleManager = new RoleManager <IdentityRole>(roleStore); var userStore = new UserStore <Kullanici>(yoneticiConcrete._dbContext); var userManager = new UserManager <Kullanici>(userStore); var kullanici = userManager.FindByName((yonetici.Ad.ToLower() + yonetici.Soyad.ToLower())); if (kullanici == null) { kullanici = new Kullanici() { UserName = yonetici.Ad.ToLower() + yonetici.Soyad.ToLower(), Email = yonetici.Ad.ToLower() + yonetici.Soyad.ToLower() + "@uni.edu.tr" }; } else { int sayi = 0; while (kullanici != null) { sayi++; kullanici = userManager.FindByName((yonetici.Ad.ToLower() + yonetici.Soyad.ToLower() + sayi)); } kullanici = new Kullanici() { UserName = yonetici.Ad.ToLower() + yonetici.Soyad.ToLower() + sayi, Email = yonetici.Ad.ToLower() + yonetici.Soyad.ToLower() + sayi + "@uni.edu.tr" }; } //Yapicalak: Sifre kisminda TC Ogrenci kismina alinacak, asagidaki ornek gibi sifre girisi yapilacak. //Muhammed Talha Balci //Mb123717238192739. string sifre = yonetici.Ad.Substring(0, 1).ToUpper() + yonetici.Soyad.Substring(0, 1).ToLower() + yonetici.TC + "."; var result = userManager.Create(kullanici, sifre); if (result.Succeeded) { userManager.AddToRole(kullanici.Id, "yonetici"); } yonetici.KullaniciAdi = kullanici.UserName; yonetici.YoneticiID = kullanici.Id; yoneticiConcrete._yoneticiRepository.Insert(yonetici); yoneticiConcrete._yoneticiUnitOfWork.SaveChanges(); yoneticiConcrete._yoneticiUnitOfWork.Dispose(); }
public ActionResult Giris(FormCollection frm) { string kullaniciAdi = frm["username"]; string sifre = frm["password"]; YoneticiConcrete yoneticiConcrete = new YoneticiConcrete(); if (yoneticiConcrete.Login(kullaniciAdi, sifre)) { Session["KullaniciAdi"] = kullaniciAdi; return(RedirectToAction("Index", "Yonetici")); } else { return(View()); } }
public ActionResult YoneticiGuncelle(int id) { yoneticiConcrete = new YoneticiConcrete(); return(View(yoneticiConcrete._yoneticiRepository.GetById(id))); }