public ActionResult Login(kullanici kullanici) { if (kullanici.KullaniciAdi != null || kullanici.Sifre != null) { var kullaniciindb = db.kullanici.FirstOrDefault(m => m.KullaniciAdi == kullanici.KullaniciAdi && m.Sifre == kullanici.Sifre); //veri tabanında bu kullanıcı adı ve şifresi olan kullanıcı var mı? if (kullaniciindb != null) //varsa index sayfasına git { FormsAuthentication.SetAuthCookie(kullaniciindb.KullaniciAdi, false); Response.Cookies["KullaniciID"].Value = kullaniciindb.KullaniciID.ToString(); Response.Cookies["KullaniciID"].Expires = DateTime.Now.AddDays(2); return(RedirectToAction("Index", "Home")); } else { var model = new UserModelClass() { Sehirler = db.Sehirler.ToList() }; ViewBag.Mesaj = "Hatalı kullanıcı adı veya parola.";//Eğer yoksa bu uyarıyı ver return(View("Login", model)); } } else { var model = new UserModelClass() { Sehirler = db.Sehirler.ToList() }; ViewBag.Mesaj = "Kullanıcı adı ve parola kısmı boş geçilemez."; return(View("Login", model)); } }
public ActionResult Update(UserModelClass modelClass) { string url = "api/UserManagement/User/Update"; var User = CallAPI.InsertUpdateEntity2 <UserModelClass>(url, modelClass); return(View("User", User)); }
public ActionResult AssignUserRoles() { JurisprudenceDBEntities db = new JurisprudenceDBEntities(); var email = Session["Username"].ToString(); tbl_User tbl = db.tbl_User.Single(u => u.Email == email); if (tbl.Role == "Admin") { JurisprudenceDBEntities _db = new JurisprudenceDBEntities(); var tb = _db.tbl_User; List <UserModelClass> ulst = new List <UserModelClass>(); foreach (tbl_User item in tb) { UserModelClass umc = new UserModelClass(); umc.UserID = item.UserID; umc.Name = item.Name; umc.Address = item.Address; umc.Contact = item.Contact; umc.Role = item.Role; ulst.Add(umc); } return(View(ulst)); } List <UserModelClass> ll = new List <UserModelClass>(); ViewBag.Message = "Please Contact Admin"; return(View(ll)); }
public int Checkuser(UserModelClass modelClass) { try { if (modelClass.Name != null && modelClass.Name != "" && modelClass.LoginPassword != null && modelClass.LoginPassword != "") { var user = db.UserInfoes.Where(x => x.Name == modelClass.Name).FirstOrDefault(); if (user != null && user.LoginPassword == modelClass.LoginPassword) { return(user.UserId); } else { return(0); } } else { return(0); } } catch (DbEntityValidationException ex) { foreach (var errors in ex.EntityValidationErrors) { foreach (var validationError in errors.ValidationErrors) { // get the error message string message = validationError.ErrorMessage; } } } return(0); }
public ActionResult Insert(UserModelClass modelClass) { string url = "api/UserManagement/User/Insert"; var User = CallAPI.InsertUpdateEntity2 <UserModelClass>(url, modelClass); string _url = Url.Action("Login", "User"); return(Json(new { data = User }, JsonRequestBehavior.AllowGet)); //View("Register"); }
public ActionResult AddRole(UserModelClass umc) { JurisprudenceDBEntities _db = new JurisprudenceDBEntities(); tbl_User tb = _db.tbl_User.Single(u => u.UserID == umc.UserID); tb.Role = umc.Role; _db.SaveChanges(); return(RedirectToAction("AssignUserRoles")); }
public ActionResult Signup(UserModelClass KullaniciModel) { var kullaniciindb = db.kullanici.FirstOrDefault(m => m.KullaniciAdi == KullaniciModel.SKullaniciAdi); var mailindb = db.kullanici.FirstOrDefault(m => m.Mail == KullaniciModel.Mail); if (ModelState.IsValid) { if (kullaniciindb == null && mailindb == null) //Kayıt olmak için girilen kullanıcı adı ve e mail veri tabanında yoksa kaydet { kullanici k = new kullanici(); k.Ad = KullaniciModel.Ad; k.Soyad = KullaniciModel.Soyad; k.KullaniciAdi = KullaniciModel.SKullaniciAdi; k.Sifre = KullaniciModel.SSifre; k.Mail = KullaniciModel.Mail; k.Tel = KullaniciModel.Tel; k.SehirID = KullaniciModel.SehirID; k.DogumTarihi = KullaniciModel.DogumTarihi; k.Cinsiyet = KullaniciModel.Cinsiyet; k.MedeniHal = KullaniciModel.MedeniHal; k.Yetki = "U"; db.kullanici.Add(k); db.SaveChanges(); TempData["AlertMessage"] = "Başarıyla kayıt olundu."; return(RedirectToAction("Login")); } else //Varsa uyarı ver { var model = new UserModelClass() { Sehirler = db.Sehirler.ToList() }; if (kullaniciindb != null) { ViewBag.Mesaj2 = "Bu kullanıcı adı daha önce alınmış!."; } if (mailindb != null) { ViewBag.Mesaj2 = "Bu e-posta adresi daha önce alınmış!."; } return(View("Login", model)); } } else { var model = new UserModelClass() { Sehirler = db.Sehirler.ToList() }; return(View("Login", model)); } }
public ActionResult AddRole(int id) { JurisprudenceDBEntities _db = new JurisprudenceDBEntities(); var tb = _db.tbl_User.Single(u => u.UserID == id); UserModelClass umc = new UserModelClass(); umc.UserID = tb.UserID; umc.Name = tb.Name; return(View(umc)); }
public void Delete(UserModelClass ModelClass) { try { db.Entry(ModelClass).State = System.Data.Entity.EntityState.Deleted; db.SaveChanges(); } catch (Exception ex) { throw ex; } }
public ActionResult Login() //Sayfa yüklenirken dropdownliste şehirlei atarak sayfayı çalıştırıyor. { if (((User.IsInRole("A")) || (User.IsInRole("U")))) { return(RedirectToAction("Index", "Home")); } else { var model = new UserModelClass() { Sehirler = db.Sehirler.ToList() }; return(View("Login", model)); } }
public ActionResult Checkuser(UserModelClass modelClass) { string url = "api/UserManagement/User/Checkuser"; var loginUser = CallAPI.InsertUpdateEntity <UserModelClass>(url, modelClass); if (loginUser > 0) { OSMS.Models.GenricClass.UserName = modelClass.Name; OSMS.Models.GenricClass.UserId = loginUser; } //else //{ // return View("Login", loginUser); //} return(Json(new { data = loginUser }, JsonRequestBehavior.AllowGet));//View("Register"); }
public ActionResult EditAccount(UserModelClass umc) { JurisprudenceDBEntities _db = new JurisprudenceDBEntities(); tbl_User tb = _db.tbl_User.Single(u => u.UserID == umc.UserID); tb.Name = umc.Name; tb.UserID = umc.UserID; tb.Name = umc.Name; tb.Address = umc.Address; tb.Contact = umc.Contact; tb.Email = umc.Email; tb.Username = umc.Username; tb.Password = umc.Password; _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult AccountDetails() { JurisprudenceDBEntities _db = new JurisprudenceDBEntities(); var email = Session["Username"].ToString(); tbl_User tb = _db.tbl_User.Single(u => u.Email == email); UserModelClass umc = new UserModelClass(); umc.UserID = tb.UserID; umc.Name = tb.Name; umc.Address = tb.Address; umc.Contact = tb.Contact; umc.Email = tb.Email; umc.Username = tb.Username; umc.Password = tb.Password; return(View(umc)); }