public UserManagerResult HesapAktiveEt(Guid activeGuid) { UserManagerResult res = new UserManagerResult(); res.User = unitOfWork.Repository <VotedressUser>().Find(x => x.ActivateGuid == activeGuid); if (res.User != null) { if (res.User.IsActive) { res.AddError(ErrorMessageCode.UserAlreadyActive, "Bu hesap zaten aktif"); return(res); } else { res.User.IsActive = true; unitOfWork.Repository <VotedressUser>().Update(res.User); } } else { res.AddError(ErrorMessageCode.ActivateIdDoesNotExists, "Bu aktive kodu geçersiz"); } return(res); }
public ActionResult HesapAktive(Guid id) { VotedressUserManager userManager = new VotedressUserManager(); UserManagerResult res = userManager.HesapAktiveEt(id); if (res.Errors.Count > 0) { TempData["errors"] = res.Errors; return(RedirectToAction("AktifederkenHata")); } return(RedirectToAction("HesapAktifEdildi")); }
public async Task <UserManagerResult> FindAccountAndGetClaimAsync( string login, string password, string applicationCookie) { var identityUser = await FindAsync(login, password); if (identityUser == null) { return(UserManagerResult.Fail("Неверный логин или пароль.")); } var claim = await CreateIdentityAsync(identityUser, applicationCookie); return(UserManagerResult.Success(claim)); }
public ActionResult Giris(Giris GirisBilgileri) { if (ModelState.IsValid) { VotedressUserManager userManager = new VotedressUserManager(); UserManagerResult res = new UserManagerResult(); res = userManager.GirisKontrol(GirisBilgileri); if (res.Errors.Count > 0) { if (res.Errors.Find(x => x.Code == Entities.Messages.ErrorMessageCode.UserIsNotActive) != null) { ViewBag.SetLink = "Activasyon kodu gönder"; } for (int i = 0; i < res.Errors.Count; i++) { ModelState.AddModelError(res.HataNerece[i].ToString(), res.Errors[i].Message); } return(View(GirisBilgileri)); } Session["login"] = res.User; if (TempData["url"] == null) { if (res.User.Role != "kurumsal") { return(RedirectToAction("Index", "Oylama")); } return(RedirectToAction("Index", "Admin")); } else { string url = TempData["url"].ToString(); return(Redirect(url)); } } else { return(View(GirisBilgileri)); } }
public async Task <UserManagerResult> CreateAccountAndGetClaimAsync( Account account, string password, string applicationCookie) { var identityUser = new AppIdentityUser { UserName = account.UserName }; var result = await CreateAsync(identityUser, password); if (result.Succeeded) { await AddToRoleAsync(identityUser.Id, RoleNames.Expert); var claim = await CreateIdentityAsync(identityUser, applicationCookie); return(UserManagerResult.Success(claim)); } return(UserManagerResult.Fail(result.Errors)); }
public UserManagerResult GirisKontrol(Giris kullanici) { UserManagerResult res = new UserManagerResult(); res.User = unitOfWork.Repository <VotedressUser>().Find(x => x.Email == kullanici.Email && x.Password == kullanici.Password); List <VotedressUser> k = new List <VotedressUser>(); if (res.User != null) { if (res.User.IsActive != true) { res.AddError(ErrorMessageCode.UserIsNotActive, "Bu hesap aktifleştirlmemiş Lütfen mail adresinizi kontrol ediniz"); res.HataNerece.Add("yukarida"); } } else { res.AddError(ErrorMessageCode.UsernameOrPassWrong, "Kullanıcı adı veya şifre uyuşmuyor"); res.HataNerece.Add("yukarida"); } return(res); }
public UserManagerResult KurumsalKullaniciKayit(KurumsalHesapKayit kullanici) { UserManagerResult res = new UserManagerResult(); VotedressUser kayitli_kullanici = EmailKontrol(kullanici.Email); UserDetail kurumsal_kullanici = TcnoKontrol(kullanici.Tcno); int kontrol = 0; if (kayitli_kullanici != null) { res.AddError(ErrorMessageCode.UserNameAlreadyExists, "Bu email zaten kayıtlı."); // Daha farklı hatalarda olsaydı onuda listeye eklicegimiz için list türünde yaptık res.HataNerece.Add("KurumsalHesap.Email"); kontrol = 1; } if (kurumsal_kullanici != null) { res.AddError(ErrorMessageCode.TcnoAlreadyExists, "Bu TC numarası kayitli"); // Daha farklı hatalarda olsaydı onuda listeye eklicegimiz için list türünde yaptık res.HataNerece.Add("KurumsalHesap.Tcno"); kontrol = 1; } if (kontrol != 1) { Guid id = Guid.NewGuid(); VotedressUser user = new VotedressUser() { id = id, Email = kullanici.Email, ActivateGuid = Guid.NewGuid(), CreateDate = DateTime.Now, Password = kullanici.Sifre, Role = "kurumsal", ProfileImage = null, SocialId = null, SocialName = "votedress", IsActive = false, }; City il = new City(); int cityId = int.Parse(kullanici.Il); il = unitOfWork.Repository <City>().Find(x => x.CityID == cityId); County ilce = new County(); int countyID = int.Parse(kullanici.Ilce); ilce = unitOfWork.Repository <County>().Find(x => x.CountyID == countyID); Neighborhood mahalle = new Neighborhood(); int NeighborhoodID = int.Parse(kullanici.Mahalle); mahalle = unitOfWork.Repository <Neighborhood>().Find(x => x.NeighborhoodID == NeighborhoodID); UserDetail UserDetail = new UserDetail() { UserId = id, Name = kullanici.Ad, SurName = kullanici.Soyad, City = il, County = ilce, Neighborhood = mahalle, AdressDetail = kullanici.Adresdetayi, CommencialTitle = kullanici.Ticariunvan, LandPhone = kullanici.Sabitno, PhoneNumber = kullanici.Ceptelefonno, TcNo = kullanici.Tcno, TypeOfBusiness = kullanici.Isletmeturu, Birthday = null, Sex = null, User = user }; unitOfWork.Repository <VotedressUser>().Insert(user); int dbResult = unitOfWork.SaveChanges(); unitOfWork.Repository <UserDetail>().Insert(UserDetail); dbResult = +unitOfWork.SaveChanges(); if (dbResult > 2) { res.User = unitOfWork.Repository <VotedressUser>().Find(x => x.Email == kullanici.Email); res.UserDetail = unitOfWork.Repository <UserDetail>().Find(x => x.UserId == res.User.id); MailHelper MailGonder = new MailHelper(); string siteUri = ConfigHelper.Get <string>("SiteRootUri"); string activateGuid = $"{siteUri}/Account/HesapAktive/{res.User.ActivateGuid}"; string body = $"Hesabınızı aktifleştirmek için <a href='{activateGuid}' target='_blank'> tıklayınız.</a>"; MailGonder.SendMail(body, res.User.Email, "Votedress Hesap Aktifleştirme"); } } return(res); }
public UserManagerResult BireyselKullaniciKayit(BireyselHesapKayit kullanici) { UserManagerResult res = new UserManagerResult(); VotedressUser kayitli_kullanici = EmailKontrol(kullanici.Email); if (kayitli_kullanici != null) { res.AddError(ErrorMessageCode.UserNameAlreadyExists, "Bu email zaten kayıtlı."); // Daha farklı hatalarda olsaydı onuda listeye eklicegimiz için list türünde yaptık res.HataNerece.Add("BireyselHesap.Email"); } else { Guid id = Guid.NewGuid(); VotedressUser user = new VotedressUser() { id = id, Email = kullanici.Email, ActivateGuid = Guid.NewGuid(), CreateDate = DateTime.Now, Password = kullanici.Sifre, Role = "bireysel", ProfileImage = "/Content/img/profil_resmi.png", SocialId = null, SocialName = "votedress", IsActive = false, }; UserDetail UserDetail = new UserDetail() { UserId = id, Birthday = kullanici.DogumTarihi, Name = kullanici.Ad, SurName = kullanici.Soyad, Sex = kullanici.Cinsiyet, City = null, Neighborhood = null, County = null, User = user, }; unitOfWork.Repository <VotedressUser>().Insert(user); int dbResult = unitOfWork.SaveChanges(); unitOfWork.Repository <UserDetail>().Insert(UserDetail); dbResult = +unitOfWork.SaveChanges(); if (dbResult > 0) { res.User = unitOfWork.Repository <VotedressUser>().Find(x => x.Email == kullanici.Email); MailHelper MailGonder = new MailHelper(); string siteUri = ConfigHelper.Get <string>("SiteRootUri"); string activateGuid = $"{siteUri}/Account/HesapAktive/{res.User.ActivateGuid}"; string body = $"Hesabınızı aktifleştirmek için <a href='{activateGuid}' target='_blank'> tıklayınız.</a>"; MailGonder.SendMail(body, res.User.Email, "Votedress Hesap Aktifleştirme"); } } return(res); }
public ActionResult HesapOlustur(HesapOlusturViewModel veriler) { VotedressUserManager userManager = new VotedressUserManager(); if (veriler.BireyselHesap != null) { if (ModelState.IsValid) { UserManagerResult res = userManager.BireyselKullaniciKayit(veriler.BireyselHesap); if (res.Errors.Count > 0) { for (int i = 0; i < res.Errors.Count; i++) { ModelState.AddModelError(res.HataNerece[i].ToString(), res.Errors[i].Message); } return(PartialView("_BireyselHesapOlustur", veriler)); } return(Json(new { redirectTo = Url.Action("Giris", "Account") })); } else { PartialViewResult aa = new PartialViewResult(); aa = PartialView("_BireyselHesapOlustur"); var deneme = ConvertToString(aa, ControllerContext); return(Json(new { PartialView = deneme, Nereden = "Bireysel" })); } } else { veriler.BireyselHesap = new BireyselHesapKayit(); if (ModelState.IsValid) { UserManagerResult res = userManager.KurumsalKullaniciKayit(veriler.KurumsalHesap); if (res.Errors.Count > 0) { for (int i = 0; i < res.Errors.Count; i++) { ModelState.AddModelError(res.HataNerece[i].ToString(), res.Errors[i].Message); } return(PartialView("_KurumsalHesapOlustur", veriler)); } return(Json(new { redirectTo = Url.Action("Giris", "Account") })); } else { PartialViewResult aa = new PartialViewResult(); aa = PartialView("_KurumsalHesapOlustur"); var deneme = ConvertToString(aa, ControllerContext); return(Json(new { PartialView = deneme, Nereden = "Kurumsal" })); } } }