示例#1
0
        public async Task Create()
        {
            if (string.IsNullOrWhiteSpace(this.Value) ||
                string.IsNullOrWhiteSpace(this.BarCode) ||
                string.IsNullOrWhiteSpace(this.Alias))
            {
                await _messageService.DisplayAlert("Existem campos que não foram preenchidos.");
            }
            else
            {
                var idApp = App.Current.Properties["IdApp"] as string;

                var tz          = (System.DateTime.UtcNow - System.DateTime.Now.ToLocalTime()).Hours + 1;
                var horaEnviada = System.DateTime.Now.AddHours(tz).ToString("yyyyMMddHHmmss");
                var res         = await _apiService.CadastraPassclock("EstiveAqui", "Teste", this.BarCode, this.Value, horaEnviada, System.DateTime.Now.ToString("yyyyMMddHHmmss"), "0", "0");

                if (res.ValidadoOk)
                {
                    var res2 = await _apiService.CadastraPassclock2(idApp, this.BarCode, this.Value, this.Alias, horaEnviada, res.HashCode);

                    if (res2.ValidadoOk)
                    {
                        _passclockRepository.Save(new ApiSerialize.PassClock
                        {
                            Ap = res2.Pco.Ap,
                            Cv = res2.Pco.Cv,
                            Pc = res2.Pco.Pc,
                            St = res2.Pco.St
                        });
                        await _messageService.DisplayAlert("PassClock cadastrado com sucesso.");

                        await _navigationService.PopAsync();
                    }
                    else
                    {
                        await _messageService.DisplayAlert("Ocorreu um erro ao registrar seu Passclock.");
                    }
                }
                else
                {
                    await _messageService.DisplayAlert("Código inválido!");
                }
            }
        }