public void Register() { Console.Write("Enter your name: "); var name = Console.ReadLine(); Console.Write("Enter your last name: "); var lastName = Console.ReadLine(); Console.Write("Enter your username: "******"Enter your password: "******"Confirm password: "); var confirmPassword = Console.ReadLine(); _regularUser = _register.CreateUser(name, lastName, username, password, confirmPassword); _register.SignUp(_regularUser); }
public bool CreateUser(RegisterViewModel vm) { IObjectPair <IRegisterUser, string> generatedUserPassPair = registerHandler.CreateUser(userRepo.GetAll(), vm.Firstname, vm.Lastname, vm.Email, vm.IsAdmin, vm.Phonenumber, vm.Country, vm.City, vm.Streetname, vm.Zip); try { userRepo.AddUser(generatedUserPassPair.Object1); ILoginUser user = userRepo.GetUserByName(generatedUserPassPair.Object1.UserName); if (vm.ProfilePicture != null) { pictureHandler.PictureCopy(vm.ProfilePicture, user.UserID); } EMailSender eMailer = new EMailSender(GlobalSettings.MailSettings.Client); IMessageSettableMail mail = new MessageMail(new System.Net.Mail.MailMessage()); mail.MakeMail(GlobalSettings.MailSettings.NewUserSubject, String.Format(GlobalSettings.MailSettings.NewUserContent, user.UserName, generatedUserPassPair.Object2), user.Email); eMailer.Send(mail, GlobalSettings.MailSettings.NoReplyAdress, GlobalSettings.MailSettings.NetworkCredentials, GlobalSettings.MailSettings.EnableSSL, GlobalSettings.MailSettings.Port); } catch { return(false); //throw new ArgumentException("Something went wrong with the registration. Check Inner Exception for specific information: /n" + excepton.InnerException.Message); } return(true); }
public object Register([FromBody] UserVm userVm) { try { _logger.LogInfo($"{MethodInfoHelper.GetCurrentMethodName()} started."); var userConfirmation = _registerService.CreateUser(userVm); if (!string.IsNullOrEmpty(userConfirmation.EmailAddress)) { return(Ok(new { message = "User was succesfully recorded!" })); } } catch (AppException ex) { _logger.LogError($"{MethodInfoHelper.GetCurrentMethodName()} failed.", ex); throw; } finally { _logger.LogInfo($"{MethodInfoHelper.GetCurrentMethodName()} ended."); } return(new { message = "Something went wrong please try again" }); }