public ActionResult RegisterTercuman(RegisterViewModelTranslator model) { if (ModelState.IsValid) { BusinessLayerResult <Tercuman> res = tercumanManager.RegisterTercuman(model); DilTercumen dt = new DilTercumen(); //burada ana dil ekle string ana_dil = model.AnaDil; BusinessLayerResult <Dil> dil = dilManager.GetLanguageById(ana_dil); dt.Dil_isimler = dil.Result.Id; dt.Tercumanlar = res.Result.Id; BusinessLayerResult <DilTercumen> res2 = dilTercumenManager.RegisterTercuman(dt); if (res.Errors.Count > 0) { res.Errors.ForEach(x => ModelState.AddModelError("", x.Message)); return(View(model)); } OkViewModel notifyObj = new OkViewModel() { Title = "Kayıt Başarılı", RedirectingUrl = "/Home/Login", }; notifyObj.Items.Add("Lütfen e-posta adresinize gönderdiğimiz aktivasyon link'ine tıklayarak hesabınızı aktive ediniz. Hesabınızı aktive etmeden not ekleyemez ve beğenme yapamazsınız."); return(View("Ok", notifyObj)); } return(View(model)); }
public BusinessLayerResult <Tercuman> RegisterTercuman(RegisterViewModelTranslator data) { // Kullanıcı Name kontrolü.. // Kullanıcı e-posta kontrolü.. // Kayıt işlemi.. // Aktivasyon e-postası gönderimi. Tercuman user = Find(x => x.Email == data.EMail || x.Email == data.EMail); BusinessLayerResult <Tercuman> res = new BusinessLayerResult <Tercuman>(); if (user != null) { if (user.Email == data.EMail) { res.AddError(ErrorMessageCode.NameAlreadyExists, "Kullanıcı emaili kayıtlı."); } if (user.Email == data.EMail) { res.AddError(ErrorMessageCode.EmailAlreadyExists, "E-posta adresi kayıtlı."); } } else { int dbResult = base.Insert(new Tercuman() { Email = data.EMail, Name = data.Name, Create_on = DateTime.Now, ProfileImageFilename = "user_boy.png", Biyografi = data.Biyografi, Meslek = data.Meslek, Password = data.Password, ActivateGuid = Guid.NewGuid(), IsActive = false, }); if (dbResult > 0) { res.Result = Find(x => x.Email == data.EMail && x.Password == data.Password); string siteUri = ConfigHelper.Get <string>("SiteRootUri"); string activateUri = $"{siteUri}/Home/TercumanActivate/{res.Result.ActivateGuid}"; string body = $"Merhaba {res.Result.Name};<br><br>Hesabınızı aktifleştirmek için <a href='{activateUri}' target='_blank'>tıklayınız</a>."; MailHelper.SendMail(body, res.Result.Email, "Tercume Hesap Aktifleştirme"); } } return(res); }