public OperatorController(MembershipTools membershipTools, IRepository <Issue, string> issueRepo, IRepository <IssueLog, string> issueLogRepo, IRepository <Photograph, string> photoRepo) : base(membershipTools, issueRepo) { _membershipTools = membershipTools; _issueRepo = issueRepo; _issueLogRepo = issueLogRepo; _photoRepo = photoRepo; }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RouteConfig.RegisterRoutes(RouteTable.Routes); var roleManager = MembershipTools.NewRoleManager(); if (!roleManager.RoleExists("Admin")) { roleManager.Create(new ApplicationRole() { Name = "Admin", Description = "Sistem Yöneticisi" }); } if (!roleManager.RoleExists("User")) { roleManager.Create(new ApplicationRole() { Name = "User", Description = "Sistem Kullanıcısı" }); } if (!roleManager.RoleExists("Passive")) { roleManager.Create(new ApplicationRole() { Name = "Passive", Description = "E-Mail Aktivasyonu Gerekli" }); } }
protected List <SelectListItem> GetUserList() { var data = new List <SelectListItem>(); MembershipTools.NewUserStore().Users .ToList() .ForEach(x => { data.Add(new SelectListItem() { Text = $"{x.Name} {x.Surname}", Value = x.Id }); }); //veya //var users = MembershipTools.NewUserStore().Users; //var data = new List<SelectListItem>(); //foreach (var user in users) //{ // data.Add(new SelectListItem() // { // Text = $"{user.Name} {user.Surname}", // Value = user.Id, // }); //} return(data); }
public async Task <ActionResult> RecoverPassword(string email) { var userStore = MembershipTools.NewUserStore(); var userManager = new UserManager <ApplicationUser>(userStore); var sonuc = userStore.Context.Set <ApplicationUser>().FirstOrDefault(x => x.Email == email); if (sonuc == null) { ViewBag.sonuc = "email adresiniz kayıtlı değil"; return(View()); } var randomPas = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 6); await userStore.SetPasswordHashAsync(sonuc, userManager.PasswordHasher.HashPassword(randomPas)); await userStore.UpdateAsync(sonuc); await userStore.Context.SaveChangesAsync(); await SiteSettings.SendMail(new MailModel() { To = sonuc.Email, Subject = "Şifreniz değiştirildi", Message = $"Merhaba {sonuc.Name} {sonuc.SurName} yeni şifreniz:<b>{randomPas}</b> olmuştur" }); ViewBag.sonuc = "Email adresinize yeni şifre gönderilmiştir"; return(View()); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); AutoMapperConfig.RegisterMappings(); var userManager = MembershipTools.NewUserManager(); var userStore = MembershipTools.NewUserStore(); var roller = Enum.GetNames(typeof(IdentityRoles)); var roleManager = MembershipTools.NewRoleManager(); foreach (var rol in roller) { if (!roleManager.RoleExists(rol)) { roleManager.Create(new Role() { Name = rol, }); } } if (!userStore.Users.Any()) { DataHelper.DataEkle(); } }
public AdminController(MembershipTools membershipTools, MyContext dbContext, IRepository <Failure, int> failureRepo, IRepository <Survey, string> surveyRepo) : base(membershipTools) { _membershipTools = membershipTools; _dbContext = dbContext; _failureRepo = failureRepo; _surveyRepo = surveyRepo; }
public ActionResult IlanListele() { var userManager = MembershipTools.NewUserManager(); var user = userManager.FindById(HttpContext.User.Identity.GetUserId()); List <KonutViewModel> model = new KonutRepo().GetAll().Where(x => x.KullaniciID == user.Id).Select(x => new KonutViewModel() { Aciklama = x.Aciklama, YayindaMi = x.YayindaMi, Adres = x.Adres, Baslik = x.Baslik, BinaYasi = x.BinaYasi, Boylam = x.Boylam, EklenmeTarihi = x.EklenmeTarihi, Enlem = x.Enlem, Fiyat = x.Fiyat, FotografYollari = (x.Fotograflar.Count > 0 ? x.Fotograflar.Select(y => y.Yol).ToList() : new List <string>()), ID = x.ID, IlanTuruID = x.IlanTuruID, IsitmaTuruID = x.IsitmaSistemiID, KatTuruID = x.KatturID, KullaniciID = x.KullaniciID, Metrekare = x.Metrekare, OdaSayisi = x.OdaSayisi, OnaylanmaTarihi = x.OnaylanmaTarihi }).ToList(); return(View(model)); }
public ActionResult UserProfile() { try { var id = HttpContext.GetOwinContext().Authentication.User.Identity.GetUserId(); var user = MembershipTools.NewUserManager().FindById(id); var data = new ProfilePasswordViewModel() { UserProfileViewModel = new UserProfileViewModel() { Email = user.Email, Id = user.Id, Name = user.Name, PhoneNumber = user.PhoneNumber, Surname = user.Surname, UserName = user.UserName, AvatarPath = string.IsNullOrEmpty(user.AvatarPath) ? "/assets/img/avatars/avatar3.jpg" : user.AvatarPath } }; return(View(data)); } catch (Exception ex) { TempData["Model"] = new ErrorViewModel() { Text = $"Bir hata oluştu {ex.Message}", ActionName = "UserProfile", ControllerName = "Account", ErrorCode = 500 }; return(RedirectToAction("Error", "Home")); } }
public async Task <ActionResult> ChangePassword(ProfilePasswordViewModel model) { try { var userManager = MembershipTools.NewUserManager(); var id = HttpContext.GetOwinContext().Authentication.User.Identity.GetUserId(); var user = MembershipTools.NewUserManager().FindById(id); var data = new ProfilePasswordViewModel() { UserProfileViewModel = new UserProfileViewModel() { Email = user.Email, Id = user.Id, Name = user.Name, PhoneNumber = user.PhoneNumber, Surname = user.Surname, UserName = user.UserName } }; model.UserProfileViewModel = data.UserProfileViewModel; if (!ModelState.IsValid) { model.ChangePasswordViewModel = new ChangePasswordViewModel(); return(View("UserProfile", model)); } var result = await userManager.ChangePasswordAsync( HttpContext.GetOwinContext().Authentication.User.Identity.GetUserId(), model.ChangePasswordViewModel.OldPassword, model.ChangePasswordViewModel.NewPassword); if (result.Succeeded) { //todo kullanıcıyı bilgilendiren bir mail atılır return(RedirectToAction("Logout", "Account")); } else { var err = ""; foreach (var resultError in result.Errors) { err += resultError + " "; } ModelState.AddModelError("", err); model.ChangePasswordViewModel = new ChangePasswordViewModel(); return(View("UserProfile", model)); } } catch (Exception ex) { TempData["Model"] = new ErrorViewModel() { Text = $"Bir hata oluştu {ex.Message}", ActionName = "UserProfile", ControllerName = "Account", ErrorCode = 500 }; return(RedirectToAction("Error", "Home")); } }
public async Task <JsonResult> RolGuncelle(string id, string rolename, string oldrole) { var userStore = MembershipTools.NewUserStore(); var userManager = new UserManager <ApplicationUser>(userStore); var user = userManager.FindById(id); try { userManager.RemoveFromRole(user.Id, oldrole); userManager.AddToRole(user.Id, rolename); user.PreRole = oldrole; await userStore.UpdateAsync(user); await userStore.Context.SaveChangesAsync(); return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { success = false, message = "Hata oluştu" }, JsonRequestBehavior.AllowGet)); } }
public OperatorController(IRepoIdentity userRoleRepo, MembershipTools membershipTools, Operator_Repo operatorRepo, IHostingEnvironment hostingEnvironment) { _userRoleRepo = userRoleRepo; _membershipTools = membershipTools; _operatorRepo = operatorRepo; _hostingEnvironment = hostingEnvironment; }
public ActionResult AnketDetay(int?id) { if (id == null) { return(RedirectToAction("AnketYonetimi")); } var anket = new AnketRepo().GetByID(id.Value); if (anket == null) { return(RedirectToAction("AnketYonetimi")); } var userManager = MembershipTools.NewUserManager(); var Kullanici = userManager.FindById(anket.KullaniciID); var Teknisyen = userManager.FindById(anket.TeknikerID); var model = new AnketViewModel() { ID = anket.ID, Aciklama = anket.Aciklama, ArizaID = anket.ArizaID, KullaniciID = Kullanici.Name, Puan = anket.Puan, TeknikerID = Teknisyen.Name }; return(View(model)); }
public async Task <ActionResult> ChangePassword(ProfileViewModel model) { if (!ModelState.IsValid) { return(RedirectToAction("Profile")); } var userStore = MembershipTools.NewUserStore(); var userManager = new UserManager <ApplicationUser>(userStore); var user = userManager.FindById(HttpContext.User.Identity.GetUserId()); var checkuser = userManager.Find(user.UserName, model.OldPassword); if (checkuser == null) { ModelState.AddModelError(string.Empty, "Mevcut şifreniz yanlış"); return(RedirectToAction("Profile")); } await userStore.SetPasswordHashAsync(user, userManager.PasswordHasher.HashPassword(model.ConfirmPassword)); await userStore.UpdateAsync(user); await userStore.Context.SaveChangesAsync(); await SiteSettings.SendMail(new MailModel() { Message = $"Merhaba {user.UserName}, </br> Şifreniz Panelden değiştirilmiştir.", Subject = "Şifreniz Değişti!", To = user.Email }); return(RedirectToAction("Logout")); }
public List <UserViewModel> GetAllUsers() { var UserList = new List <UserViewModel>(); var userManager = MembershipTools.NewUserManager(); List <ApplicationUser> list = userManager.Users.ToList(); foreach (var item in list) { UserList.Add(new UserViewModel() { Name = item.Name, SurName = item.SurName, Email = item.Email, UserName = item.UserName, ID = item.Id, RoleID = item.Roles.First()?.RoleId, EmailConfirmed = item.EmailConfirmed, PhoneNumber = item.PhoneNumber, RegisterDate = item.RegisterDate, RoleName = MembershipTools.GetRoleName(item.Roles.First()?.RoleId) }); } return(UserList); }
public async Task <ActionResult> Profile(ProfilePasswordViewModel model) { if (!ModelState.IsValid) { return(View(model)); } try { var userStore = MembershipTools.NewUserStore(); var userManager = new UserManager <ApplicationUser>(userStore); var user = userManager.FindById(model.ProfileModel.Id); user.Name = model.ProfileModel.Name; user.Surname = model.ProfileModel.Surname; if (user.Email != model.ProfileModel.Email) { user.Email = model.ProfileModel.Email; if (HttpContext.User.IsInRole("Admin")) { userManager.RemoveFromRole(user.Id, "Admin"); } else if (HttpContext.User.IsInRole("User")) { userManager.RemoveFromRole(user.Id, "User"); } userManager.AddToRole(user.Id, "Passive"); user.ActivationCode = Guid.NewGuid().ToString().Replace("-", ""); string siteUrl = Request.Url.Scheme + Uri.SchemeDelimiter + Request.Url.Host + (Request.Url.IsDefaultPort ? "" : ":" + Request.Url.Port); await SiteSettings.SendMail(new MailModel { To = user.Email, Subject = "Personel Yönetimi - Aktivasyon", Message = $"Merhaba {user.Name} {user.Surname} <br/>Email adresinizi <b>değiştirdiğiniz</b> için hesabınızı tekrar aktif etmelisiniz. <a href='{siteUrl}/Account/Activation?code={user.ActivationCode}'>Aktivasyon Kodu</a>" }); } await userStore.UpdateAsync(user); await userStore.Context.SaveChangesAsync(); var model1 = new ProfilePasswordViewModel() { ProfileModel = new ProfileViewModel { Id = user.Id, Email = user.Email, Name = user.Name, Surname = user.Surname, UserName = user.UserName } }; ViewBag.sonuc = "Bilgileriniz güncelleşmiştir"; return(View(model1)); } catch (Exception ex) { ViewBag.sonuc = ex.Message; return(View(model)); } }
public ActionResult Activation(string code) { try { var userStore = MembershipTools.NewUserStore(); var user = userStore.Users.FirstOrDefault(x => x.ActivationCode == code); if (user != null) { if (user.EmailConfirmed) { ViewBag.Message = $"<span class='alert alert-success'>Bu hesap daha önce aktive edilmiştir.</span>"; } else { user.EmailConfirmed = true; userStore.Context.SaveChanges(); ViewBag.Message = $"<span class='alert alert-success'>Aktivasyon işleminiz başarılı</span>"; } } else { ViewBag.Message = $"<span class='alert alert-danger'>Aktivasyon başarısız</span>"; } } catch (Exception ex) { ViewBag.Message = "<span class='alert alert-danger'>Aktivasyon işleminde bir hata oluştu</span>"; } return(View()); }
public async Task <ActionResult> ChangePassword(ProfilePasswordMultiViewModel model) { if (!ModelState.IsValid) { return(RedirectToAction("Profile", "Account")); } try { var userStore = MembershipTools.NewUserStore(); var userManager = new UserManager <ApplicationUser>(userStore); var user = await userManager.FindByIdAsync(HttpContext.User.Identity.GetUserId()); user = await userManager.FindAsync(user.UserName, model.ChangePasswordViewModel.OldPassword); if (user == null) { ModelState.AddModelError("OldPassword", "Mevcut şifreniz hatalı"); return(View("Profile")); } await userStore.SetPasswordHashAsync(user, userManager.PasswordHasher.HashPassword(model.ChangePasswordViewModel.Password)); await userStore.UpdateAsync(user); await userStore.Context.SaveChangesAsync(); HttpContext.GetOwinContext().Authentication.SignOut(); return(RedirectToAction("Profile")); } catch (Exception ex) { ModelState.AddModelError("", $"Güncelleme işleminde bir hata oluştu.{ex.Message}"); return(View("Profile")); } }
public AdminController(MembershipTools membershipTools, IHostingEnvironment hostingEnvironment, IRepository <Issue, string> issueRepo, IRepository <Survey, string> surveyRepo) : base(membershipTools) { _membershipTools = membershipTools; _hostingEnvironment = hostingEnvironment; _issueRepo = issueRepo; _surveyRepo = surveyRepo; }
public async Task <ActionResult> EditUser(UsersViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var roles = MembershipTools.NewRoleManager().Roles.ToList(); var userStore = MembershipTools.NewUserStore(); var userManager = new UserManager <ApplicationUser>(userStore); var user = userManager.FindById(model.UserId); if (user == null) { return(View("Index")); } user.UserName = model.UserName; user.Name = model.Name; user.SurName = model.Surname; user.Salary = model.Salary; user.Email = model.Email; if (model.RoleId != user.Roles.ToList().FirstOrDefault().RoleId) { var yenirol = roles.First(x => x.Id == model.RoleId).Name; userManager.AddToRole(model.UserId, yenirol); var eskirol = roles.First(x => x.Id == user.Roles.ToList().FirstOrDefault().RoleId).Name; userManager.RemoveFromRole(model.UserId, eskirol); } await userStore.UpdateAsync(user); await userStore.Context.SaveChangesAsync(); return(RedirectToAction("EditUser", new { id = model.UserId })); }
public ActionResult ArizaYonetimi() { var userManager = MembershipTools.NewUserManager(); var id = HttpContext.User.Identity.GetUserId(); var user = userManager.FindById(id); List <ArizaViewModel> arizalar = new ArizaRepo().GetAll().Where(z => z.TeknikerID == user.Id).OrderByDescending(y => y.EklemeTarihi).Select(x => new ArizaViewModel() { KullaniciID = x.KullaniciID, Aciklama = x.Aciklama, Adres = x.Adres, Baslik = x.Baslik, Boylam = x.Boylam, Enlem = x.Enlem, MarkaID = x.MarkaID, ModelID = x.ModelID, TeknikerID = x.TeknikerID, FotografYollari = (x.Fotograflari.Count > 0 ? x.Fotograflari.Select(y => y.Yol).ToList() : new List <string>()), ID = x.ID, OnaylamaTarihi = x.OnaylamaTarihi, OnaylandiMi = x.OnaylandiMi, ArizaYapildiMi = x.ArizaYapildiMi, EklemeTarihi = x.EklemeTarihi }).ToList(); return(View(arizalar)); }
public async Task <ActionResult> Activation(string code) { var userStore = MembershipTools.NewUserStore(); var userManager = new UserManager <ApplicationUser>(userStore); var sonuc = userStore.Context.Set <ApplicationUser>().FirstOrDefault(x => x.ActivationCode == code); if (sonuc == null) { ViewBag.sonuc = "Aktivasyon işlemi başarısız"; return(View()); } sonuc.EmailConfirmed = true; await userStore.UpdateAsync(sonuc); await userStore.Context.SaveChangesAsync(); userManager.RemoveFromRole(sonuc.Id, "Passive"); userManager.AddToRole(sonuc.Id, "User"); ViewBag.sonuc = $"Merhaba{sonuc.Name} {sonuc.SurName} kayıt aktivaston işleminiz başarılı olmuştur."; await SiteSettings.SendMail(new MailModel() { To = sonuc.Email, Message = ViewBag.sonuc.ToString(), Subject = "Aktivasyon", Bcc = "*****@*****.**" }); return(View()); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RouteConfig.RegisterRoutes(RouteTable.Routes); //bundleconfig ekledik ve içinde adres değişikliği yaptık. Şimdi onu bir yazalım burada. Aynı üsttekilerin yazıldığı gibi yazalım. BundleConfig.RegisterBundles(BundleTable.Bundles); var roleManager = MembershipTools.NewRoleManager(); //ilk uygulamanın çalışmasında applicationstart başlıyor. Mail method gibi. if (!roleManager.RoleExists("Admin")) //bu yazacaklarımızı rolleri oluşturması için kullanacağız. { roleManager.Create(new ApplicationRole() { //object initializer i açtık Name = "Admin", Description = "Site Yöneticisi" }); } if (!roleManager.RoleExists("Musteri")) { roleManager.Create(new ApplicationRole() { //object initializer i açtık Name = "Musteri", Description = "Uygulama Musterisi" }); } if (!roleManager.RoleExists("Firma")) { roleManager.Create(new ApplicationRole() { //object initializer i açtık Name = "Firma", Description = "Firma Sahibi Üye" }); } }
public async Task <ActionResult> UpdatePassword(ProfilePasswordViewModel model) { if (model.passwordModel.NewPassword != model.passwordModel.NewPasswordConfirm) { ModelState.AddModelError(string.Empty, "Şifreler uyuşmuyor"); return(View("Profile", model)); } try { var userStore = MembershipTools.NewUserStore(); var userManager = new UserManager <ApplicationUser>(userStore); var user = userManager.FindById(model.profileModel.Id); user = userManager.Find(user.UserName, model.passwordModel.OldPassword); if (user == null) { ModelState.AddModelError(string.Empty, "Şifrenizi yanlış girdiniz"); return(View("Profile", model)); } await userStore.SetPasswordHashAsync(user, userManager.PasswordHasher.HashPassword(model.passwordModel.NewPassword)); await userStore.UpdateAsync(user); await userStore.Context.SaveChangesAsync(); HttpContext.GetOwinContext().Authentication.SignOut(); return(RedirectToAction("Profile")); } catch (Exception ex) { ViewBag.sonuc = "günceleştirilemedi" + ex.Message; return(View("Profile", model)); } }
public async Task <ActionResult> UpdatePassword(ProfileViewModel model) { if (model.YeniSifre != model.YeniSifreTekrar) { ModelState.AddModelError(string.Empty, "Şifreler uyuşmuyor"); return(View("Profile")); } try { var userStore = MembershipTools.NewUserStore(); var userManager = new UserManager <ApplicationUser>(userStore); var user = userManager.FindById(HttpContext.User.Identity.GetUserId()); user = userManager.Find(user.UserName, model.EskiSifre); if (user == null) { ModelState.AddModelError(string.Empty, "Mevcut şifreniz yanlış girildi"); return(View("Profile")); } await userStore.SetPasswordHashAsync(user, userManager.PasswordHasher.HashPassword(model.YeniSifre)); await userStore.UpdateAsync(user); await userStore.Context.SaveChangesAsync(); HttpContext.GetOwinContext().Authentication.SignOut(); return(RedirectToAction("Profile")); } catch (Exception ex) { ViewBag.sonuc = "Güncelleştirme işleminde bir hata oluştu. " + ex.Message; throw; } }
public TechnicianController(MembershipTools membershipTools, IRepository <Issue, string> issueRepo, IRepository <IssueLog, string> issueLogRepo, IRepository <Survey, string> surveyRepo) : base(membershipTools, issueRepo) { _membershipTools = membershipTools; _issueRepo = issueRepo; _issueLogRepo = issueLogRepo; _surveyRepo = surveyRepo; }
public async Task <ActionResult> RecoverPassword(string email) { var userStore = MembershipTools.NewUserStore(); var userManager = new UserManager <ApplicationUser>(userStore); try { var sonuc = userStore.Context.Set <ApplicationUser>().FirstOrDefault(x => x.Email == email); if (sonuc == null) { ViewBag.sonuc = "E mail adresiniz sisteme kayıtlı değil"; return(View()); } var randomPass = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 6); await userStore.SetPasswordHashAsync(sonuc, userManager.PasswordHasher.HashPassword(randomPass)); await SiteSettings.SendMail(new MailModel() { To = sonuc.Email, Subject = "Şifreniz Değişti", Message = $"Merhaba {sonuc.Ad} {sonuc.Soyad} <br/>Yeni Şifreniz : <b>{randomPass}</b>" }); ViewBag.sonuc = "Email adresinize yeni şifreniz gönderilmiştir"; return(View()); } catch (Exception) { ViewBag.sonuc = "Sistemsel bir hata oluştu. Tekrar deneyiniz"; return(View()); } }
public JsonResult AdimDataKaydet(Guid id, string sonucData) { var isAtamaRepo = new IsAtamaRepo(); var baglayiciRepo = new BaglayiciRepo(); var isAtama = isAtamaRepo.Queryable().First(x => x.Id == id); var baglayici = baglayiciRepo.Queryable().FirstOrDefault(x => x.SemaId == isAtama.SemaId && x.Id == isAtama.SonAdimId); if (baglayici == null) { isAtama.TamamlandiMi = true; if (isAtamaRepo.Update() > 0) { var hubContext = GlobalHost.ConnectionManager.GetHubContext <WorkflowHub>(); var user = MembershipTools.NewUserManager().FindById(isAtama.AtananKullaniciId); hubContext.Clients.User(user.UserName).endCurrentTask(); return(Json(true)); } else { return(Json(false)); } } isAtama.SonAdimId = baglayici.Id2; isAtama.SonucDataJson = sonucData; var result = isAtamaRepo.Update() > 0; return(Json(result)); }
public ActionResult KullaniciDuzenle(KullaniciDuzenleViewModel model) { if (!ModelState.IsValid) { return(RedirectToAction("Index")); } var userManager = MembershipTools.NewUserManager(); var seciliUser = userManager.Users.Where(x => x.Id == model.ID).FirstOrDefault(); // var checkUser = userManager.FindByName(model.Username); //if (checkUser!=null) //{ // ModelState.AddModelError(string.Empty, "Bu kullanıcı adı daha önceden kayıt edilmiş!"); // return RedirectToAction("KullaniciDuzenle",new { id=model.ID}); //} var eskirol = MembershipTools.NewRoleManager().FindById(seciliUser.Roles.FirstOrDefault().RoleId).Name; var yenirol = MembershipTools.NewRoleManager().FindById(model.RoleID).Name; userManager.RemoveFromRole(model.ID, eskirol); //eskirol silindi userManager.AddToRole(model.ID, yenirol); // rol eklendi //if (model.Password!=null) //{ // userManager.RemovePassword(model.ID); // userManager.AddPassword(model.ID, model.Password); //} seciliUser.Name = model.Name; seciliUser.SurName = model.Surname; seciliUser.UserName = model.Username; seciliUser.PhoneNumber = model.Telefon; seciliUser.FirmaAdi = model.FirmaAdi; seciliUser.Email = model.Email; userManager.Update(seciliUser); return(RedirectToAction("KullaniciListele", "Admin")); }
public async Task <ActionResult> Login(LoginViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var userManager = MembershipTools.NewUserManager(); var user = await userManager.FindAsync(model.UserName, model.Password); if (user == null) { ModelState.AddModelError(string.Empty, "Böyle bir kullanıcı bulunmamaktadır!"); return(View(model)); } var authManager = HttpContext.GetOwinContext().Authentication; var userIdentity = await userManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie); authManager.SignIn(new AuthenticationProperties { IsPersistent = true }, userIdentity); return(RedirectToAction("Index", "Home")); }
public ActionResult ArizaEkle() { var userManager = MembershipTools.NewUserManager(); var user = userManager.FindById(HttpContext.User.Identity.GetUserId()); if (userManager.IsInRole(user.Id, "Passive") || userManager.IsInRole(user.Id, "Banned")) { ModelState.AddModelError(string.Empty, "Profiliniz Yeni ilan açmak için uygun değildir."); return(RedirectToAction("Profile", "Account")); } var model = new ArizaViewModel(); var markalar = new List <SelectListItem>(); new PcMarkaRepo().GetAll().OrderBy(x => x.MarkaAdi).ToList().ForEach(x => markalar.Add(new SelectListItem() { Text = x.MarkaAdi, Value = x.ID.ToString() })); var modeller = new List <SelectListItem>(); new PcModelRepo().GetAll().OrderBy(x => x.ModelAdi).ToList().ForEach(x => modeller.Add(new SelectListItem() { Text = x.ModelAdi, Value = x.ID.ToString() })); ViewBag.modelleri = modeller; ViewBag.markalari = markalar; return(View(model)); }