public BusinessErrorResult <TradeUser> UpdateProfil(TradeUser tradeUserEditProfile) { TradeUser tradeUser = find(x => x.UserName == tradeUserEditProfile.UserName || x.Email == tradeUserEditProfile.Email); BusinessErrorResult <TradeUser> businessErrorResult = new BusinessErrorResult <TradeUser>(); if (tradeUser != null && tradeUser.Id != tradeUserEditProfile.Id) { if (tradeUser.UserName == tradeUserEditProfile.UserName) { businessErrorResult.AddError(EnumErrorMessages.UserNameAlreadyExits, "Kullanıcı adı kayıtlı"); } if (tradeUser.Email == tradeUserEditProfile.Email) { businessErrorResult.AddError(EnumErrorMessages.EmailAlreadyExits, "E-posta adresi kayıtlı."); } return(businessErrorResult); } businessErrorResult.Result = find(x => x.Id == tradeUserEditProfile.Id); businessErrorResult.Result.Email = tradeUserEditProfile.Email; businessErrorResult.Result.Name = tradeUserEditProfile.Name; businessErrorResult.Result.Surname = tradeUserEditProfile.Surname; businessErrorResult.Result.Password = tradeUserEditProfile.Password; businessErrorResult.Result.UserName = tradeUserEditProfile.UserName; if (string.IsNullOrEmpty(tradeUserEditProfile.ProfileImageFileName) == false) { businessErrorResult.Result.ProfileImageFileName = tradeUserEditProfile.ProfileImageFileName; } if (base.Update(businessErrorResult.Result) == 0) { businessErrorResult.AddError(EnumErrorMessages.ProfileCouldNotUpdated, "Profil güncellenemedi."); } return(businessErrorResult); }
public new BusinessErrorResult <TradeUser> Update(TradeUser tradeUserEditUser) { TradeUser tradeUser = find(x => x.UserName == tradeUserEditUser.UserName || x.Email == tradeUserEditUser.Email); BusinessErrorResult <TradeUser> businessErrorResult = new BusinessErrorResult <TradeUser>(); businessErrorResult.Result = tradeUserEditUser; if (tradeUser != null && tradeUser.Id != tradeUserEditUser.Id) { if (tradeUser.UserName == tradeUserEditUser.UserName) { businessErrorResult.AddError(EnumErrorMessages.UserNameAlreadyExits, "Kullanıcı adı kayıtlı"); } if (tradeUser.Email == tradeUserEditUser.Email) { businessErrorResult.AddError(EnumErrorMessages.EmailAlreadyExits, "E-posta adresi kayıtlı."); } return(businessErrorResult); } businessErrorResult.Result = find(x => x.Id == tradeUserEditUser.Id); businessErrorResult.Result.Email = tradeUserEditUser.Email; businessErrorResult.Result.Name = tradeUserEditUser.Name; businessErrorResult.Result.Surname = tradeUserEditUser.Surname; businessErrorResult.Result.Password = tradeUserEditUser.Password; businessErrorResult.Result.UserName = tradeUserEditUser.UserName; businessErrorResult.Result.IsActive = tradeUserEditUser.IsActive; businessErrorResult.Result.IsAdmin = tradeUserEditUser.IsAdmin; if (base.Update(businessErrorResult.Result) == 0) { businessErrorResult.AddError(EnumErrorMessages.UserCouldNotUpdated, "Kullanıcı güncellenemedi."); } return(businessErrorResult); }
//Method hidding public new BusinessErrorResult <TradeUser> Insert(TradeUser registerViewModel) { BusinessErrorResult <TradeUser> businessErrorResult = new BusinessErrorResult <TradeUser>(); TradeUser tradeUser = find(p => p.UserName == registerViewModel.UserName || p.Email == registerViewModel.Email); businessErrorResult.Result = registerViewModel; if (tradeUser != null) { if (tradeUser.UserName == registerViewModel.UserName) { businessErrorResult.AddError(EnumErrorMessages.UserNameAlreadyExits, "Kullanıcı adı kayıtlı."); } if (tradeUser.Email == registerViewModel.Email) { businessErrorResult.AddError(EnumErrorMessages.EmailAlreadyExits, "E-Posta adresi kayıtlı."); } } else { businessErrorResult.Result.ProfileImageFileName = "profil.jpg"; businessErrorResult.Result.ActivateGuid = Guid.NewGuid(); if (base.Insert(businessErrorResult.Result) == 0) { businessErrorResult.AddError(EnumErrorMessages.UserCouldNotInserted, "Kullanıcı eklenemedi."); } } return(businessErrorResult); }
public BusinessErrorResult <TradeUser> GetUserById(int Id) { BusinessErrorResult <TradeUser> businessErrorResult = new BusinessErrorResult <TradeUser> { Result = find(p => p.Id == Id) }; if (businessErrorResult.Result == null) { businessErrorResult.AddError(EnumErrorMessages.UserNotFound, "Kullanıcı Bulunamadı."); } return(businessErrorResult); }
public ActionResult EditProfile() { BusinessErrorResult <TradeUser> businessErrorResult = tradeUserManager.GetUserById(CurrentSession.UserSession.Id); if (businessErrorResult.Errors.Count > 0) { ErrorViewModel errorNotifyObj = new ErrorViewModel() { Title = "Hata Oluştu", Items = businessErrorResult.Errors }; return(View("Error", errorNotifyObj)); } return(View(businessErrorResult.Result)); }
public ActionResult Login(loginViewModel loginViewModel) { if (ModelState.IsValid) { BusinessErrorResult <TradeUser> businessErrorResult = tradeUserManager.tradeUserLogin(loginViewModel); if (businessErrorResult.Errors.Count > 0) { businessErrorResult.Errors.ForEach(p => ModelState.AddModelError("", p.Messages + p.WrongCode.GetHashCode())); return(View(loginViewModel)); } CurrentSession.Set <TradeUser>("login", businessErrorResult.Result); return(RedirectToAction("Index")); } return(View(loginViewModel)); }
public ActionResult DeleteProfile() { BusinessErrorResult <TradeUser> businessErrorResult = tradeUserManager.RemoveUserById(CurrentSession.UserSession.Id); if (businessErrorResult.Errors.Count > 0) { ErrorViewModel errorNotifyObj = new ErrorViewModel() { Title = "Profil Silinemedi.", Items = businessErrorResult.Errors, RedirectingUrl = "/Home/ShowProfile" }; return(View("Error", errorNotifyObj)); } Session.Clear(); return(RedirectToAction("Index")); }
public ActionResult Edit(TradeUser tradeUser) { ModelState.Remove("CreateOn"); ModelState.Remove("ModifiedOn"); ModelState.Remove("ModifiedUserName"); if (ModelState.IsValid) { BusinessErrorResult <TradeUser> bussinesErrorResult = tradeUserManager.Update(tradeUser); if (bussinesErrorResult.Errors.Count > 0) { bussinesErrorResult.Errors.ForEach(x => ModelState.AddModelError("", x.Messages)); return(View(tradeUser)); } return(RedirectToAction("Index")); } return(View(tradeUser)); }
public BusinessErrorResult <TradeUser> RemoveUserById(int id) { BusinessErrorResult <TradeUser> businessErrorResult = new BusinessErrorResult <TradeUser>(); TradeUser tradeUser = find(x => x.Id == id); if (tradeUser != null) { if (Delete(tradeUser) == 0) { businessErrorResult.AddError(EnumErrorMessages.UserCouldNotRemove, "Kullanıcı silinemedi"); return(businessErrorResult); } } else { businessErrorResult.AddError(EnumErrorMessages.UserCouldNotFind, "Kullanıcı bulunamadı."); } return(businessErrorResult); }
public BusinessErrorResult <TradeUser> tradeUserRegister(registerViewModel registerViewModel) { BusinessErrorResult <TradeUser> businessErrorResult = new BusinessErrorResult <TradeUser>(); TradeUser tradeUser = find(p => p.UserName == registerViewModel.UserName || p.Email == registerViewModel.Email); if (tradeUser != null) { if (tradeUser.UserName == registerViewModel.UserName) { businessErrorResult.AddError(EnumErrorMessages.UserNameAlreadyExits, "Kullanıcı adı kayıtlı."); } if (tradeUser.Email == registerViewModel.Email) { businessErrorResult.AddError(EnumErrorMessages.EmailAlreadyExits, "E-Posta adresi kayıtlı."); } } else { int databaseResult = base.Insert(new TradeUser() { UserName = registerViewModel.UserName, ProfileImageFileName = "profil.jpg", Email = registerViewModel.Email, Password = registerViewModel.Password, ActivateGuid = Guid.NewGuid(), CreateOn = DateTime.Now, ModifiedOn = DateTime.Now, IsActive = false, IsAdmin = false, }); if (databaseResult > 0) { businessErrorResult.Result = find(p => p.Email == registerViewModel.Email && p.UserName == registerViewModel.UserName); string siteUrl = ConfigHelper.Get <string>("SiteRootUrl"); string activateUrl = $"{siteUrl}/Home/UserActivate/{businessErrorResult.Result.ActivateGuid}"; string body = $"Merhaba {businessErrorResult.Result.UserName};<br><br> Hesabınızı aktifleştirmek için <a href='{activateUrl}' target='_blank'>Tıklayınız</a> "; MailHelper.SendMail(body, businessErrorResult.Result.Email, "ETrade Hesap Aktifleştirme"); } } return(businessErrorResult); }
public BusinessErrorResult <TradeUser> tradeUserLogin(loginViewModel loginViewModel) { BusinessErrorResult <TradeUser> businessErrorResult = new BusinessErrorResult <TradeUser>(); businessErrorResult.Result = find(p => p.UserName == loginViewModel.UserName && p.Password == loginViewModel.Password); if (businessErrorResult.Result != null) { if (!businessErrorResult.Result.IsActive) { businessErrorResult.AddError(EnumErrorMessages.UserrIsActive, "Hesabınız aktifleştirilmemiştir."); businessErrorResult.AddError(EnumErrorMessages.CheckEmail, "Lütfen e-posta adresini kontrol ediniz."); } } else { businessErrorResult.AddError(EnumErrorMessages.UserNameOrPassWrong, "Kullanıcı adı ve şifre uyuşmamaktadır."); } return(businessErrorResult); }
public ActionResult Register(registerViewModel registerViewModel) { if (ModelState.IsValid) { BusinessErrorResult <TradeUser> businessErrorResult = tradeUserManager.tradeUserRegister(registerViewModel); if (businessErrorResult.Errors.Count > 0) { businessErrorResult.Errors.ForEach(p => ModelState.AddModelError("", p.Messages + p.WrongCode.GetHashCode())); return(View(registerViewModel)); } 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(registerViewModel)); }
public ActionResult UserActivate(Guid Id) { BusinessErrorResult <TradeUser> businessErrorResult = tradeUserManager.ActivateUser(Id); if (businessErrorResult.Errors.Count > 0) { ErrorViewModel errorNotifyObj = new ErrorViewModel() { Title = "Geçersiz İşlem!", Items = businessErrorResult.Errors }; return(View("Error", errorNotifyObj)); } OkViewModel okNotifyObj = new OkViewModel() { Title = "Hesap aktifleştirildi.", RedirectingUrl = "/Home/Login" }; okNotifyObj.Items.Add("Hesabınız Aktifleştirildi. Hesabınızda not paylaşabilir ve beğenme yapabilirsiniz."); return(View("Ok", okNotifyObj)); }
public BusinessErrorResult <TradeUser> ActivateUser(Guid activateGuid) { BusinessErrorResult <TradeUser> businessErrorResult = new BusinessErrorResult <TradeUser>(); businessErrorResult.Result = find(p => p.ActivateGuid == activateGuid); if (businessErrorResult != null) { if (businessErrorResult.Result.IsActive) { businessErrorResult.AddError(EnumErrorMessages.UserAlreadyActivate, "Kullanıcı zaten aktif edilmiştir."); } businessErrorResult.Result.IsActive = true; Update(businessErrorResult.Result); } else { businessErrorResult.AddError(EnumErrorMessages.ActivateIdDoesNotExits, "Aktifleştirilecek kullanıcı bulunamadı."); } return(businessErrorResult); }
public ActionResult EditProfile(TradeUser tradeUserEditProfile, HttpPostedFileBase ProfileImage) { ModelState.Remove("ModifiedUserName"); if (ModelState.IsValid) { if (ProfileImage != null && ( ProfileImage.ContentType == "image/jpeg" || ProfileImage.ContentType == "image/jpg" || ProfileImage.ContentType == "image/png" )) { string fileName = $"tradeUser_{tradeUserEditProfile}.{ProfileImage.ContentType.Split('/')[1]}"; ProfileImage.SaveAs(Server.MapPath($"~/Images/{fileName}")); tradeUserEditProfile.ProfileImageFileName = fileName; } BusinessErrorResult <TradeUser> businessErrorResult = tradeUserManager.UpdateProfil(tradeUserEditProfile); if (businessErrorResult.Errors.Count > 0) { ErrorViewModel errorNotifyObj = new ErrorViewModel() { Items = businessErrorResult.Errors, Title = "Profil Güncellenemedi.", RedirectingUrl = "/Home/EditProfile" }; return(View("Error", errorNotifyObj)); } CurrentSession.Set <TradeUser>("login", businessErrorResult.Result); return(RedirectToAction("ShowProfile")); } return(View(tradeUserEditProfile)); }