public LayerResult <ChangePasswordViewModel> ChangePasswordByViewModel(ChangePasswordViewModel model) { LayerResult <ChangePasswordViewModel> layerResult = new LayerResult <ChangePasswordViewModel>(); layerResult.Result = model; if (model.NewPassword != model.NewRePassword) { layerResult.AddError("Girilen parolalar eşleşmemektedir!"); return(layerResult); } var isExists = AdminIsExistsByUsernameAndPassword(model.Username, model.LastPassword); if (!isExists) { layerResult.AddError("Geçersiz kullanıcı adı veya parola!"); return(layerResult); } model.LastPassword = _hashGeneratorService.GenerateHash(model.LastPassword); model.NewPassword = _hashGeneratorService.GenerateHash(model.NewPassword); var count = _adminDal.ChangePasswordByViewModel(model); if (count == 0) { layerResult.AddError("Güncelleme işlemi başarısız!"); } return(layerResult); }
public ActionResult UserActivate(Guid Id) { LayerResult <NoteUser> res = um.ActivateUser(Id); if (res.Errors.Count > 0) { ErrorViewModel evm = new ErrorViewModel() { Title = "Geçersiz İşlem", RedirectingTimeOut = 3000, Items = res.Errors, }; return(View("Error", evm)); //return RedirectToView("~/Views/Shared/Error", evm); } OkViewModel ovm = new OkViewModel() { Title = "Hesap Aktifleştirildi...", RedirectingUrl = "/Home/Login", RedirectingTimeOut = 3000, }; ovm.Items.Add("Hesabnız aktifleştriildi.Artık paylaşabilirisiniz."); return(View("Ok", ovm)); }
public LayerResult <NoteUser> UpdateProfile(NoteUser data) { NoteUser db_user = Find(x => x.UserName == data.UserName || x.Email == data.Email); LayerResult <NoteUser> res = new LayerResult <NoteUser>(); if (db_user != null && db_user.Id != data.Id) { if (db_user.UserName == data.UserName) { res.AddError(ErrorMessageCode.UsernameAlreadyExists, "Kullanıcı Adı Kayıtlı."); } if (db_user.Email == data.Email) { res.AddError(ErrorMessageCode.EmailAlreadyExists, "Kullanıcı E-mail kayıtlı"); } return(res); } res.Result = Find(x => x.Id == data.Id); res.Result.Email = data.Email; res.Result.Name = data.Name; res.Result.SurName = data.SurName; res.Result.UserName = data.UserName; res.Result.Password = data.Password; if (string.IsNullOrEmpty(data.ProfileImageFilename) == false) { res.Result.ProfileImageFilename = data.ProfileImageFilename; } if (base.Update(res.Result) == 0) { res.AddError(ErrorMessageCode.ProfileCouldNotUpdated, "Profil Güncellenmedi."); } return(res); }
public new LayerResult <NoteUser> Update(NoteUser data) { NoteUser db_user = Find(x => x.UserName == data.UserName || x.Email == data.Email); LayerResult <NoteUser> res = new LayerResult <NoteUser>(); res.Result = data; if (db_user != null && db_user.Id != data.Id) { if (db_user.UserName == data.UserName) { res.AddError(ErrorMessageCode.UsernameAlreadyExists, "Kullanıcı Adı Kayıtlı."); } if (db_user.Email == data.Email) { res.AddError(ErrorMessageCode.EmailAlreadyExists, "Kullanıcı E-mail kayıtlı"); } return(res); } res.Result = Find(x => x.Id == data.Id); res.Result.Email = data.Email; res.Result.Name = data.Name; res.Result.SurName = data.SurName; res.Result.UserName = data.UserName; res.Result.Password = data.Password; res.Result.IsActive = data.IsActive; res.Result.IsAdmin = data.IsAdmin; if (base.Update(res.Result) == 0) { res.AddError(ErrorMessageCode.UserCouldNotUpdated, "Kullanıcı Güncellenmedi."); } return(res); }
//Method hiding public new LayerResult <NoteUser> Insert(NoteUser data) { NoteUser noteUser = Find(x => x.UserName == data.UserName || x.Email == data.Email); LayerResult <NoteUser> res = new LayerResult <NoteUser>(); res.Result = data; if (noteUser != null) { if (noteUser.UserName == data.UserName) { res.AddError(ErrorMessageCode.UsernameAlreadyExists, "Kullanıcı Adı Kayıtlı."); } if (noteUser.Email == data.Email) { res.AddError(ErrorMessageCode.EmailAlreadyExists, "Kullanıcı E-mail kayıtlı"); } } else { res.Result.ProfileImageFilename = "user_default.png"; res.Result.ActiveGuid = Guid.NewGuid(); if (base.Insert(res.Result) == 0) { res.AddError(ErrorMessageCode.UserCouldNotInserted, "Kullanıcı kayıt edilemdi."); } } return(res); }
public LayerResult <Family> UpdateByFatherTCNo(Family family) { var layerResult = new LayerResult <Family>() { Result = family }; if (family.FatherNo.Length != 11) { layerResult.AddError("T.C numarası 11 karakter olmalıdır!"); return(layerResult); } if (String.IsNullOrEmpty(family.Address)) { layerResult.AddError("Adres boş olmamalıdır!!"); return(layerResult); } int count = _familyDal.UpdateByFatherTCNo(family); if (count == 0) { layerResult.AddError("Güncelleme işlemi gerçekleştirilemedi, girdiğiniz değerleri kontrol ediniz!"); } return(layerResult); }
public ActionResult EditProfile(NoteUser model, HttpPostedFileBase ProfileImage) { ModelState.Remove("ModifiedUsername");//istemediğimiz özelliği kaldırabiliriz. if (ModelState.IsValid) { if (ProfileImage != null && (ProfileImage.ContentType == "image/jpeg" || ProfileImage.ContentType == "image/jpg" || ProfileImage.ContentType == "image/png")) { string fileName = $"user_{model.Id}.{ProfileImage.ContentType.Split('/')[1]}"; ProfileImage.SaveAs(Server.MapPath($"~/img/{fileName}")); model.ProfileImageFilename = fileName; } LayerResult <NoteUser> res = um.UpdateProfile(model); if (res.Errors.Count > 0) { ErrorViewModel evm = new ErrorViewModel() { Title = "Hata oluştu..", Items = res.Errors, RedirectingUrl = "/Home/EditProfile" }; return(View("Error", evm)); } CurrentSession.Set <NoteUser>("login", res.Result); return(RedirectToAction("ShowProfile")); } return(View(model)); }
public LayerResult <Person_Donation> Add(Person_Donation personDonation) { LayerResult <Person_Donation> layerResult = new LayerResult <Person_Donation>(); layerResult.Result = personDonation; if (String.IsNullOrEmpty(personDonation.Description)) { layerResult.AddError("Açıklama alanı boş bırakılamaz!"); } if (layerResult.HasError()) { return(layerResult); } int count = _personDonationDal.Add(personDonation); if (count == 0) { layerResult.AddError("Ekleme işlemi başarısız!"); } return(layerResult); }
public LayerResult <Person> Add(Person person) { LayerResult <Person> layerResult = new LayerResult <Person>(); layerResult.Result = person; if (string.IsNullOrEmpty(person.TC)) { layerResult.AddError("T.C kimlik numarası boş geçilemez!"); } if (person.TC.Length != 11) { layerResult.AddError("T.C kimlik numarası 11 karakter olmalıdır!"); } if (string.IsNullOrEmpty(person.Citizenship)) { layerResult.AddError("Uyruk boş geçilemez!"); } if (string.IsNullOrEmpty(person.Name)) { layerResult.AddError("İsim alanı boş geçilemez!"); } if (string.IsNullOrEmpty(person.Surname)) { layerResult.AddError("Soyisim alanı boş geçilemez!"); } if (person.BirthDate == null) { layerResult.AddError("Doğum Tarihi boş geçilemez!"); } if (string.IsNullOrEmpty(person.PlaceOfBirth)) { layerResult.AddError("Doğum yeri boş geçilemez!"); } if (string.IsNullOrEmpty(person.MotherName)) { layerResult.AddError("Anne adı boş geçilemez!"); } if (string.IsNullOrEmpty(person.FatherName)) { layerResult.AddError("Baba adı numarası boş geçilemez!"); } if (layerResult.HasError()) { return(layerResult); } int count = _personDal.Add(person); if (count == 0) { layerResult.AddError("Ekleme işlemi gerçekleştirilemedi!"); } return(layerResult); }
public LayerResult <NoteUser> GetUseryById(int Id) { LayerResult <NoteUser> res = new LayerResult <NoteUser>(); res.Result = Find(x => x.Id == Id); if (res.Result == null) { res.AddError(ErrorMessageCode.UserNotFound, "Kullanıcı Bulunamadı."); } return(res); }
private static void SendOkayResultForTestCheck() { NimatorResult nimatorResult = new NimatorResult(DateTime.Now); List <ICheckResult> checks = new List <ICheckResult>(); checks.Add(new CheckResult("testCheck", NotificationLevel.Okay)); ILayerResult layerResult = new LayerResult("firstLayer", checks); nimatorResult.LayerResults.Add(layerResult); _notifier.Notify(nimatorResult); }
public LayerResult <Person> RemoveByTCNo(string tcNo) { int count = _personDal.RemovePersonByTCNo(tcNo); LayerResult <Person> layerResult = new LayerResult <Person>(); if (count == 0) { layerResult.AddError("Kayıtlı kullanıcı silinemedi, lütfen ilişkileri kontrol ediniz!"); } return(layerResult); }
public ActionResult Edit(NoteUser noteUser) { ModelState.Remove("CreatedOn"); ModelState.Remove("ModifiedOn"); ModelState.Remove("ModifiedUsername"); if (ModelState.IsValid) { LayerResult <NoteUser> res = um.Update(noteUser); if (res.Errors.Count > 0) { res.Errors.ForEach(x => ModelState.AddModelError("", x.Message)); return(View(noteUser)); } return(RedirectToAction("Index")); } return(View(noteUser)); }
private static void SendMultipleChecksInLayer() { NimatorResult nimatorResult = new NimatorResult(DateTime.Now); List <ICheckResult> checks = new List <ICheckResult>(); checks.Add(new CheckResult("testCheck1", NotificationLevel.Okay)); checks.Add(new CheckResult("testCheck2", NotificationLevel.Warning)); checks.Add(new CheckResult("testCheck3", NotificationLevel.Error)); checks.Add(new CheckResult("testCheck4", NotificationLevel.Critical)); ILayerResult layerResult = new LayerResult("secondLayer", checks); nimatorResult.LayerResults.Add(layerResult); _notifier.Notify(nimatorResult); }
public ActionResult RemoveProfile() { LayerResult <NoteUser> res = um.RemoveUserById(CurrentSession.user.Id); if (res.Errors.Count > 0) { ErrorViewModel evm = new ErrorViewModel() { Title = "Profil Silenemedi..", Items = res.Errors, RedirectingUrl = "/Home/ShowProfile" }; return(View("Error", evm)); } CurrentSession.Clear(); return(RedirectToAction("Index")); }
public LayerResult <EducationalStatus> RemoveById(int Id) { var result = new LayerResult <EducationalStatus>(); if (!IsExistsById(Id)) { result.AddError("Böyle bir güvenlik kaydı bulunmamaktadır!"); return(result); } var count = _educationalStatusDal.RemoveById(Id); if (count == 0) { result.AddError("Kayıt silinemedi!"); } return(result); }
public LayerResult <SocialSecurity> RemoveById(int Id) { var result = new LayerResult <SocialSecurity>(); if (!IsExistsById(Id)) { result.AddError("Böyle bir güvenlik kaydı bulunmamaktadır!"); return(result); } var count = _socialSecurityDal.RemoveById(Id); if (count == 0) { result.AddError("Kayıt silinemedi!"); } return(result); }
public LayerResult <NoteUser> RemoveUserById(int Id) { LayerResult <NoteUser> res = new LayerResult <NoteUser>(); NoteUser db_user = Find(x => x.Id == Id); if (db_user != null) { if (Delete(db_user) == 0) { res.AddError(ErrorMessageCode.UserCouldNotRemove, "Kullanıcı silinemedi"); return(res); } } else { res.AddError(ErrorMessageCode.UserCouldNotFind, "Kullanıcı Bulunamadı"); } return(res); }
public ActionResult Login(LoginViewModel model) { if (ModelState.IsValid) { LayerResult <NoteUser> res = um.LoginUser(model); if (res.Errors.Count > 0) { if (res.Errors.Find(x => x.Code == ErrorMessageCode.UserIsNotActive) != null) { ViewBag.SetLink = "http://Home/Activate/1234-4567-78945"; } res.Errors.ForEach(x => ModelState.AddModelError("", x.Message)); return(View(model)); } CurrentSession.Set <NoteUser>("login", res.Result); return(RedirectToAction("Index")); } return(View(model)); }
public ActionResult EditProfile() { LayerResult <NoteUser> res = um.GetUseryById(CurrentSession.user.Id); if (res.Errors.Count > 0) { //TODO: Kullanıcıyı bir hata ekranınıa yönlendirmeliyiz. if (res.Errors.Count > 0) { ErrorViewModel evm = new ErrorViewModel() { Title = "Geçersiz İşlem", RedirectingTimeOut = 3000, Items = res.Errors, }; return(View("Error", evm)); } } return(View(res.Result)); }
public LayerResult <NoteUser> RegisterUser(RegisterModel data) { NoteUser noteUser = Find(x => x.UserName == data.Username || x.Email == data.Email); LayerResult <NoteUser> layerResult = new LayerResult <NoteUser>(); if (noteUser != null) { if (noteUser.UserName == data.Username) { layerResult.AddError(ErrorMessageCode.UsernameAlreadyExists, "Kullanıcı Adı Kayıtlı."); } if (noteUser.Email == data.Email) { layerResult.AddError(ErrorMessageCode.EmailAlreadyExists, "Kullanıcı E-mail kayıtlı"); } } else { int result = base.Insert(new NoteUser() { UserName = data.Username, Email = data.Email, ProfileImageFilename = "user_default.png", Password = data.Password, ActiveGuid = Guid.NewGuid(), IsActive = false, IsAdmin = false, }); if (result > 0) { layerResult.Result = Find(x => x.Email == data.Email && x.UserName == data.Username); string siteUrl = ConfigHelper.Get <string>("SiteRootUrl"); string activateUrl = $"{siteUrl}/Home/UserActivate/{layerResult.Result.ActiveGuid}"; string body = $"Merhaba {layerResult.Result.UserName} ;<br><br>Hesabınızı aktifleştirmek için <a href='{activateUrl}' target='_blank'>tıklayınız</a>"; MailHelper.SenMail(body, layerResult.Result.Email, "MyNoteSample Aktifleştirme"); //TODO:Aktivasyon Email'ı Alınacak //layerResult.Result.ActiveGuid } } return(layerResult); }
public LayerResult <Person_Donation> Update(Person_Donation personDonation) { LayerResult <Person_Donation> layerResult = new LayerResult <Person_Donation>(); layerResult.Result = personDonation; if (String.IsNullOrEmpty(personDonation.Description)) { layerResult.AddError("Bağış açıklaması boş geçilemez!"); return(layerResult); } int count = _personDonationDal.Update(personDonation); if (count == 0) { layerResult.AddError("Güncelleme işlemi gerçekleştirilemedi!"); } return(layerResult); }
public ActionResult Register(RegisterModel model) { if (ModelState.IsValid) { LayerResult <NoteUser> res = um.RegisterUser(model); if (res.Errors.Count > 0) { res.Errors.ForEach(x => ModelState.AddModelError("", x.Message)); return(View(model)); } OkViewModel ovm = new OkViewModel() { Title = "Kayıt Başarılı", RedirectingUrl = "/Home/Login", RedirectingTimeOut = 3000 }; ovm.Items.Add("Lütfen e-posta adresinize gönderdiğimiz aktivasyon linkine tıklayarak hesabınızı aktive ediniz.Hesabınızı aktive etmeden giriş yapamazsınız."); return(View("Ok", ovm)); } return(View(model)); }
public LayerResult <NoteUser> ActivateUser(Guid activatedId) { LayerResult <NoteUser> res = new LayerResult <NoteUser>(); res.Result = Find(x => x.ActiveGuid == activatedId); if (res.Result != null) { if (res.Result.IsActive) { res.AddError(ErrorMessageCode.UserAlreadyActivate, "Kullanıcı zaten aktif edilmiştir."); return(res); } res.Result.IsActive = true; Update(res.Result); } else { res.AddError(ErrorMessageCode.ActivateIdDoesNotExists, "Aktifleştirecek kullanıcı bulunamadı."); } return(res); }
public LayerResult <NoteUser> LoginUser(LoginViewModel data) { LayerResult <NoteUser> res = new LayerResult <NoteUser>(); res.Result = Find(x => x.UserName == data.UserName && x.Password == data.Password); if (res.Result != null) { if (!res.Result.IsActive) { res.AddError(ErrorMessageCode.UserIsNotActive, "Kullanıcı Aktifleştirlmemiştir"); res.AddError(ErrorMessageCode.CheckYourEmail, "Lütfen E -posta adresinizi kontrol edniniz."); } } else { res.AddError(ErrorMessageCode.UsernameOrPassWrong, "Kullanıcı adı veya şifre uyuşmuyor"); } return(res); }
public LayerResult <Donation> Add(Donation donation) { var result = new LayerResult <Donation>() { Result = donation }; if (string.IsNullOrEmpty(donation.Name)) { result.AddError("Lütfen geçerli değerler giriniz!"); return(result); } int count = _donationDal.Add(donation); if (count == 0) { result.AddError("Ekleme işlemi başarısız!"); } return(result); }
public LayerResult <Housing> Add(Housing housing) { var result = new LayerResult <Housing>() { Result = housing }; if (string.IsNullOrEmpty(housing.Name)) { result.AddError("Lütfen geçerli değerler giriniz!"); return(result); } int count = _housingDal.Add(housing); if (count == 0) { result.AddError("Ekleme işlemi başarısız!"); } return(result); }
public LayerResult <Housing> Update(Housing housing) { var result = new LayerResult <Housing> { Result = housing }; if (housing.Id <= 0 || string.IsNullOrEmpty(housing.Name)) { result.AddError("Lütfen geçerli değerler giriniz!"); return(result); } int count = _housingDal.Update(housing); if (count == 0) { result.AddError("Güncelleme işlemi başarısız!"); } return(result); }
public LayerResult <Donation> Update(Donation donation) { var result = new LayerResult <Donation> { Result = donation }; if (donation.Id <= 0 || donation.DonationID < 0 || string.IsNullOrEmpty(donation.Name)) { result.AddError("Lütfen geçerli değerler giriniz!"); return(result); } int count = _donationDal.Update(donation); if (count == 0) { result.AddError("Güncelleme işlemi başarısız!"); } return(result); }
public LayerResult <SocialSecurity> Add(SocialSecurity socialSecurity) { var result = new LayerResult <SocialSecurity>() { Result = socialSecurity }; if (string.IsNullOrEmpty(socialSecurity.Name)) { result.AddError("Lütfen geçerli değerler giriniz!"); return(result); } int count = _socialSecurityDal.Add(socialSecurity); if (count == 0) { result.AddError("Ekleme işlemi başarısız!"); } return(result); }