Пример #1
0
        private async void SignBtn_OnClicked(object sender, EventArgs e)
        {
            if (String.IsNullOrWhiteSpace(SignNickName.Text))
            {
                SignError.IsVisible = true;
                return;
            }

            var bearer = new BearerInEntity
            {
                Nickname = SignNickName.Text,
                Password = SignPassword.Text
            };
            var answerId = await HttpService.Post <int, BearerInEntity>(bearer, Links.BearerLink + "auth");

            if (answerId == 0)
            {
                SignError.IsVisible = true;
                return;
            }

            _bearerId             = answerId;
            CurrentUser.CurrentId = _bearerId;
            CurrentUser.IsSigned  = true;
            Update();

            overlaySign.IsVisible     = false;
            overlayRegister.IsVisible = false;
            overlayWelcome.IsVisible  = false;
        }
Пример #2
0
 public Bearer BearerEntityToModel(BearerInEntity entity)
 {
     return(new Bearer()
     {
         Nickname = entity.Nickname,
         Phone = entity.Phone,
         Password = entity.Password
     });
 }
Пример #3
0
        private async void RegBtn_OnClicked(object sender, EventArgs e)
        {
            RegNicknameError.IsVisible = false;
            RegPasswordError.IsVisible = false;
            RegPhoneError.IsVisible    = false;

            if (String.IsNullOrWhiteSpace(RegNickname.Text) ||
                RegNickname.Text.Contains(" ") ||
                RegNickname.Text.Contains("/"))
            {
                RegNicknameError.IsVisible = true;
                return;
            }

            var isFree = HttpService.Get <bool>(Links.BearerLink + $"is-free/{RegNickname.Text}");

            if (!isFree)
            {
                RegNicknameError.IsVisible = true;
                return;
            }

            if (String.IsNullOrWhiteSpace(RegPassword.Text) ||
                String.IsNullOrWhiteSpace(RegPasswordConfirmation.Text) ||
                RegPassword.Text != RegPasswordConfirmation.Text)
            {
                RegPasswordError.IsVisible = true;
                return;
            }

            if (string.IsNullOrWhiteSpace(RegPhone.Text) ||
                RegPhone.Text.Contains(" ") ||
                RegPhone.Text.Contains("/"))
            {
                RegPhoneError.IsVisible = true;
                return;
            }

            var bearerIn = new BearerInEntity
            {
                Nickname = RegNickname.Text,
                Password = RegPassword.Text,
                Phone    = RegPhone.Text
            };
            var answerId = await HttpService.Post <int, BearerInEntity>(bearerIn, Links.BearerLink + "add-bearer");

            _bearerId = answerId;

            CurrentUser.CurrentId = _bearerId;
            CurrentUser.IsSigned  = true;
            Update();

            overlaySign.IsVisible     = false;
            overlayRegister.IsVisible = false;
            overlayWelcome.IsVisible  = false;
        }
Пример #4
0
        public int RegisterBearer(BearerInEntity bearer)
        {
            try
            {
                var bearerModel = _mapper.BearerEntityToModel(bearer);

                return(_bearerRepository.RegisterNewBearer(bearerModel));
            }
            catch (Exception e)
            {
                return(0);
            }
        }
Пример #5
0
 public int Authenticate(BearerInEntity bearer)
 {
     return(_bearerService.AutheticateBearer(bearer));
 }
Пример #6
0
 public int RegisterBearer(BearerInEntity bearer)
 {
     return(_bearerService.RegisterBearer(bearer));
 }
Пример #7
0
 public int AutheticateBearer(BearerInEntity bearer)
 {
     return(_bearerRepository.Authorize(_mapper.BearerEntityToModel(bearer)));
 }