public BaseResponse <User> AddUser(User user) { try { if (UserDataControl.validatePassword(user.Password) && UserDataControl.validateName(user.Name) && UserDataControl.validateSurName(user.SurName) && UserDataControl.validateEmail(user.Email)) { user.Name = UserDataControl.updateName(user.Name); user.SurName = UserDataControl.updateSurName(user.SurName); userRepository.AddUser(user); unitOfWork.Complete(); return(new BaseResponse <User>(user)); } return(new BaseResponse <User>("kullanıcı eklenemedi")); } catch (Exception ex) { return(new BaseResponse <User>($"Kullanıcı eklenirken bir hata meydana geldi:{ex.Message}")); } }
public BaseResponse <User> UpdateUser(User user) { try { if (UserDataControl.validatePassword(user.Password) && UserDataControl.validateName(user.Name) && UserDataControl.validateSurName(user.SurName) && UserDataControl.validateEmail(user.Email)) { User response = this.userRepository.FindById(user.Id); if (response == null) { return(new BaseResponse <User>("güncellemek istediğiniz kullanıcı bulunamadı")); } user.Name = UserDataControl.updateName(user.Name); user.SurName = UserDataControl.updateSurName(user.SurName); response.Id = user.Id; response.Name = user.Name; response.SurName = user.SurName; response.Email = user.Email; response.Password = user.Password; this.userRepository.UpdateUser(response); this.unitOfWork.Complete(); return(new BaseResponse <User>(response)); } return(new BaseResponse <User>("kullanıcı güncellenemedi")); } catch (Exception ex) { return(new BaseResponse <User>($"ürün güncellenirken bir hata meydana geldi::{ex.Message}")); } }