Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- using System.Net;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Input;
- using telegram2._0.Services;
- using telegram2._0.Views;
- using Xamarin.Forms;
- namespace telegram2._0.ViewModels
- {
- class LoginViewModel
- {
- public string UserName { get; set; }
- public string Password { get; set; }
- public ICommand LoginCommand { get; set; }
- public ICommand RegisterCommand { get; set; }
- private Page _page;
- public LoginViewModel(Page page)
- {
- _page = page;
- LoginCommand = new Command(OpenContacts);
- RegisterCommand = new Command(OpenRegister);
- }
- private async void OpenContacts()
- {
- var dataService = DataService.GetInstance();
- var status = await dataService.LoginAsync(UserName, Password);
- if (status == HttpStatusCode.OK)
- {
- await _page.Navigation.PushAsync(new ContactsPage());
- Debug.WriteLine($"UserName: {UserName}, Password: {Password}");
- }
- else
- {
- await _page.DisplayAlert("Ошибка", "Не удалось выполнить вход", "Закрыть");
- }
- }
- private async void OpenRegister()
- {
- Debug.WriteLine($"UserName: {UserName}");
- await _page.Navigation.PushAsync(new RegisterPage());
- }
- }
- }
Add Comment
Please, Sign In to add comment