Esempio n. 1
0
        async Task ExecuteSaveCommand()
        {
            string token = await SecureStorage.GetAsync("token");

            if (!string.IsNullOrWhiteSpace(token))
            {
                BookEntry.Kind = IsNice ? 1 : 2;
                bool result = false;
                if (BookEntry.Id == Guid.Empty.ToString())
                {
                    BookEntry.Id = Guid.NewGuid().ToString();
                    result       = await PhonebookService.CreateEntry(token, BookEntry);
                }
                else
                {
                    result = await PhonebookService.UpdateEntry(token, BookEntry);
                }

                if (result)
                {
                    MessagingCenter.Send(this, "EditEntry", BookEntry);
                    await Navigation.PopModalAsync();
                }
            }
        }
        async Task ExecuteCheckEmailCommand()
        {
            if (PhonebookService != null)
            {
                IsBusy = true;
                // If password not visible, then confirm the user exists first
                if (!PasswordEnabled)
                {
                    var result = await PhonebookService.UserExists(EmailAddress);

                    if (result)
                    {
                        PasswordEnabled = true;
                    }
                }
                else
                {
                    // Try to login
                    var token = await PhonebookService.LoginUser(EmailAddress, Password);

                    if (!string.IsNullOrWhiteSpace(token))
                    {
                        await SecureStorage.SetAsync("token", token);

                        App.Current.MainPage = new PhonebookPage();
                    }
                }
                IsBusy = false;
            }
        }
Esempio n. 3
0
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                var token = await SecureStorage.GetAsync("token");

                Entries.Clear();
                var items = await PhonebookService.GetEntries(token);

                foreach (var item in items)
                {
                    Entries.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy       = false;
                IsRefreshing = false;
            }
        }
Esempio n. 4
0
 public void SetUp()
 {
     _client = new HttpClient();
     _client.DefaultRequestHeaders.Clear();
     _client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
     _service = new PhonebookService(_client, Baseurl);
 }
 public async Task StartAsync(CancellationToken cancellationToken)
 {
     logger.Info("Запуск сервера GRPC");
     server = new Server
     {
         Services =
         {
             NotificationService.BindService(this),
             PhonebookService.BindService(phonebookService)
         },
         Ports = { new ServerPort("0.0.0.0", Int32.Parse(configuration["MangoService:grps_client_port"]), ServerCredentials.Insecure) }
     };
     server.Start();
 }
Esempio n. 6
0
        async Task ExecuteDeleteCommand()
        {
            string token = await SecureStorage.GetAsync("token");

            if (!string.IsNullOrWhiteSpace(token))
            {
                bool result = await PhonebookService.DeleteEntry(token, BookEntry.Id);

                if (result)
                {
                    MessagingCenter.Send(this, "EditEntry", BookEntry);
                    await Navigation.PopModalAsync();
                }
            }
        }