Esempio n. 1
0
        /*
         * ====================
         * ||--((*[TODO]*))--||
         * ====================
         *
         * Implementar:
         *** El envio de datos para el control de acceso [DONE]
         *** Escribir la URL para el GET y POST          [DONE]
         */

        public async void Login()
        {
            this.IsRefreshing = true;
            var connection = await apiService.CheckConnection();

            if (!connection.IsSuccess)
            {
                this.IsRefreshing = false;
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    connection.Message,
                    "Accept");

                await Application.Current.MainPage.Navigation.PopAsync();

                return;
            }

            this.Url = "https://isoapi.azurewebsites.net/SISTEMA/Login/Acceso";

            var response = await apiService.AccessRegister(
                this.Url,
                this.Password,
                this.User,
                int.Parse(this.Company),
                DeviceInfo.Name);

            var obj = (JObject)JsonConvert.DeserializeObject(JsonConvert.SerializeObject(response));

            Console.WriteLine(obj);

            if (!response.IsSuccess)
            {
                this.IsRefreshing = false;
                await Application.Current.MainPage.DisplayAlert(
                    "Error",
                    response.Message,
                    "Accept");

                await Application.Current.MainPage.Navigation.PopAsync();

                return;
            }


            MainViewModel.GetInstance().Workspace = new WorkspaceViewModel();
            await Application.Current.MainPage.Navigation.PushAsync(new WorkspacePage());

            this.IsRunning = false;
            this.IsEnabled = true;

            this.Company  = string.Empty;
            this.User     = string.Empty;
            this.Password = string.Empty;
        }