/// <summary>
 /// Return status code of Http request
 /// </summary>
 /// <param name="email"></param>
 /// <param name="password"></param>
 /// <param name="registerModel"></param>
 /// <returns></returns>
 public string Register(RegistrationDTO registerModel)
 {
     using (var client = new HttpClient())
     {
         var response = client.PostAsJsonAsync(Host + Resources.RouteRegister, registerModel).Result;
         return response.StatusCode.ToString();
     }
 }
        private void Registration(object param)
        {
            Password = (param as PasswordBox)?.Password;
            string messageText;

            if (!userValidationService.ValidPassword(Password))
            {
                messageText = Resources.ToShortPassword;
            }
            else if (!userValidationService.ValidEmail(MailForRegistration))
            {
                messageText = Resources.IncorrectEmail;
            }
            else
            {
                RegistrationDTO regModel = new RegistrationDTO
                {
                    Email = MailForRegistration,
                    FirstName = Name,
                    LastName = Surname,
                    Password = Password,
                    ConfirmPassword = Password,
                    UserName = LoginForRegistration
                };

                if (authenticatorService.Register(regModel) != "BadRequest")
                {
                    friendsService.AddFriends(
                        userSerchingService.GetByEmail(MailForRegistration).ResultTask.Result.Id,
                        userSerchingService.GetByEmail("*****@*****.**").ResultTask.Result.Id);

                    CleanRegisterData(param);
                    messageText = Resources.SuccessfulRegistration;
                }
                else
                {
                    messageText = Resources.UserWithMailOrLoginExist;
                }
            }

            MessageBox.Show(messageText);
        }
        private void SignUp()
        {
            Logger.Debug(Resources.InfoStartedSignUp);

            IoService.Out.Write("Login:");
            string login = IoService.In.ReadLine();

            IoService.Out.Write(Resources.InfoFirstName);
            string firstName = IoService.In.ReadLine();

            IoService.Out.Write(Resources.InfoLastName);
            string lastName = IoService.In.ReadLine();

            string email = ReadAndValidateEmail();
            string password = ReadAndValidatePassword();

            try
            {
                RegistrationDTO regModel = new RegistrationDTO()
                {
                    Email = email,
                    LastName = lastName,
                    FirstName = firstName,
                    Password = password,
                    ConfirmPassword = password,
                    UserName = login
                };

                var result = authenticator.Register(regModel);
                IoService.Out.WriteLine(result);

                LoginDTO loginModel = new LoginDTO()
                {
                    UserName = login,
                    Password = password
                };

                Response<SessionInfo> response = authenticator.LogIn(loginModel);

                if (response.IsSuccessful)
                {
                    Session = response.ResultTask.Result;
                }

                Logger.Info(Resources.InfoEndedSignUp);
            }
            catch (Exception ex)
            {
                IoService.Out.WriteLine(ex.Message);
            }
        }