Пример #1
0
        public Registration()
        {
            _model = new Model.Registration();

            GoToLogin = new Command(() =>
            {
                Application.Current.MainPage = new View.Login();
            });

            Register = new Command(async() =>
            {
                Func <string, Task> mention_about_error = async(string message) => await Application.Current.MainPage.DisplayAlert("Ошибка!", message, "Ок");

                try
                {
                    Data.User data = await _model.Register(Application.Current.Resources["url"] as string);
                    if (data != null)
                    {
                        data.Bind(Application.Current.Properties);
                        await Application.Current.SavePropertiesAsync();
                        Application.Current.MainPage = new View.Master();
                    }
                }
                catch (Exception e)
                {
                    if (e is Exceptions.PasswordsMismatch)
                    {
                        await mention_about_error("Пароли не совпадают");
                    }
                    else if (e is Exceptions.EmptyField)
                    {
                        await mention_about_error("Одно или несколько полей пусты");
                    }
                    else if (e is Exceptions.EmailAlreadyTaken)
                    {
                        await mention_about_error("Пользвотель с данной почтой уже зарегестирован");
                    }
                    else if (e is Exceptions.NotEmail)
                    {
                        await mention_about_error("Пожалуйста, введите корректный email");
                    }
                    else
                    {
                        await mention_about_error($"Неизвестная ошибка - {e.Message}");
                    }
                }
            });
        }
Пример #2
0
        public void CrearUser()
        {
            Model.Registration reg = new Model.Registration();
            reg.FirstName        = "veeresh";
            reg.LastName         = "S";
            reg.OrganizationName = "fluke";
            reg.Email            = "*****@*****.**";
            reg.Password         = "******";
            reg.PhoneNumber      = "1234567890";
            var licserUserLogic = new LicenseServer.Logic.UserLogic();
            var obj             = licserUserLogic.GetUserByEmail(reg.Email);

            if (obj != null)
            {
                reg.ServerUserId = obj.UserId;
                var result = logic.CreateUser(reg);
                Assert.IsTrue(result);
            }
            else
            {
                Assert.Fail("Register user is not exist in License Server. WHich tracks the admin users");
            }
        }