private async void Delete()
        {
            try
            {
                if (IsLoadingData)
                {
                    return;
                }
                if (this.SelectedObservation.IdObsv == 0)
                {
                    Alert.Show(AlertMessages.Delete);
                    return;
                }
                bool result = await Confirm.Show("Desea eliminar la observación");

                if (result)
                {
                    IsLoadingData = true;
                    UserDialogs.Instance.ShowLoading(AlertMessages.Deleting, MaskType.Black);
                    if (!TokenValidator.IsValid(TokenGet))
                    {
                        if (!await ApiIsOnline())
                        {
                            UserDialogs.Instance.HideLoading();
                            Toast.ShowError(AlertMessages.Error);
                            return;
                        }
                        else
                        {
                            if (!await GetTokenSuccess())
                            {
                                UserDialogs.Instance.HideLoading();
                                Toast.ShowError(AlertMessages.Error);
                                return;
                            }
                        }
                    }
                    ObservationDelQueryValues QueryValuesDel = new ObservationDelQueryValues()
                    {
                        IdObsv = this.SelectedObservation.IdObsv
                    };
                    Response resultObservationsDel = await ApiSrv.DelObservations(TokenGet.Key, QueryValuesDel);

                    if (!resultObservationsDel.IsSuccess)
                    {
                        UserDialogs.Instance.HideLoading();
                        Toast.ShowError(AlertMessages.Error);
                        return;
                    }
                    else
                    {
                        ObservationDel = JsonConvert.DeserializeObject <List <ObservationDel> >(Crypto.DecodeString(resultObservationsDel.Data));
                        if (!ObservationDel[0].Result)
                        {
                            UserDialogs.Instance.HideLoading();
                            Toast.ShowError(AlertMessages.NoSuccess);
                        }
                        else
                        {
                            UserDialogs.Instance.HideLoading();
                            UserDialogs.Instance.ShowLoading(AlertMessages.UpdatingList, MaskType.Black);
                            ObservationGetQueryValues QueryValuesGet;
                            if (this.LotAndCommandData.HasData)
                            {
                                QueryValuesGet = new ObservationGetQueryValues()
                                {
                                    IdLog      = this.LogItem.IdLog,
                                    IdUser     = PbUser.IdUser,
                                    IdInstance = this.LotAndCommandData.IdInstance,
                                    IdLot      = this.LotAndCommandData.IdLot,
                                    IdCommand  = this.LotAndCommandData.IdCommand
                                };
                            }
                            else
                            {
                                QueryValuesGet = new ObservationGetQueryValues()
                                {
                                    IdLog      = this.LogItem.IdLog,
                                    IdUser     = PbUser.IdUser,
                                    IdInstance = 0,
                                    IdLot      = 0,
                                    IdCommand  = 0
                                };
                            }
                            Response resultObservationsGet = await ApiSrv.GetObservations(TokenGet.Key, QueryValuesGet);

                            if (!resultObservationsGet.IsSuccess)
                            {
                                UserDialogs.Instance.HideLoading();
                                Toast.ShowError(AlertMessages.Error);
                                return;
                            }
                            else
                            {
                                Observations = JsonConvert.DeserializeObject <List <ObservationGet> >(Crypto.DecodeString(resultObservationsGet.Data));
                                ObservationItems.Clear();
                                foreach (ObservationGet observationGet in Observations)
                                {
                                    ObservationItems.Add(new ObservationItem()
                                    {
                                        IdObsv         = observationGet.IdObsv,
                                        DateObsv       = observationGet.DateObsv,
                                        NameObsv       = observationGet.NameObsv,
                                        IdUser         = observationGet.IdUser,
                                        DetailObsv     = observationGet.DetailObsv,
                                        DateObsvString = observationGet.DateObsv.ToString(DateTimeFormatString.LatinDate)
                                    });
                                }
                                UserDialogs.Instance.HideLoading();
                            }

                            Toast.ShowSuccess(AlertMessages.Success);
                            this.Name                = string.Empty;
                            this.Details             = string.Empty;
                            this.SelectedObservation = new ObservationItem();
                        }
                    }
                    IsLoadingData = false;
                }
            }
            catch //(Exception ex)
            {
                UserDialogs.Instance.HideLoading();
                Toast.ShowError(AlertMessages.Error);
            }
        }
        private async void Save()
        {
            try
            {
                if (IsLoadingData)
                {
                    return;
                }
                if (String.IsNullOrWhiteSpace(this.Name))
                {
                    Alert.Show("Debe ingresar un nombre para la observación");
                    return;
                }

                if (String.IsNullOrWhiteSpace(this.Details))
                {
                    Alert.Show("Debe ingresar un detalle para la observación");
                    return;
                }

                bool result = await Confirm.Show("Desea guardar los cambios de la observación");

                if (result)
                {
                    IsLoadingData = true;
                    if (this.SelectedObservation.IdObsv != 0)
                    {
                        UserDialogs.Instance.ShowLoading(AlertMessages.Updating, MaskType.Black);
                        if (!TokenValidator.IsValid(TokenGet))
                        {
                            if (!await ApiIsOnline())
                            {
                                UserDialogs.Instance.HideLoading();
                                Toast.ShowError(AlertMessages.Error);
                                return;
                            }
                            else
                            {
                                if (!await GetTokenSuccess())
                                {
                                    UserDialogs.Instance.HideLoading();
                                    Toast.ShowError(AlertMessages.Error);
                                    return;
                                }
                            }
                        }
                        ObservationModQueryValues QueryValuesMod;
                        if (this.LotAndCommandData.HasData)
                        {
                            QueryValuesMod = new ObservationModQueryValues()
                            {
                                IdObsv     = this.SelectedObservation.IdObsv,
                                IdLog      = this.LogItem.IdLog,
                                IdUser     = PbUser.IdUser,
                                IdInstance = this.LotAndCommandData.IdInstance,
                                IdLot      = this.LotAndCommandData.IdLot,
                                IdCommand  = this.LotAndCommandData.IdCommand,
                                NameObsv   = this.Name,
                                DetailObsv = this.Details
                            };
                        }
                        else
                        {
                            QueryValuesMod = new ObservationModQueryValues()
                            {
                                IdObsv     = this.SelectedObservation.IdObsv,
                                IdLog      = this.LogItem.IdLog,
                                IdUser     = PbUser.IdUser,
                                IdInstance = 0,
                                IdLot      = 0,
                                IdCommand  = 0,
                                NameObsv   = this.Name,
                                DetailObsv = this.Details
                            };
                        }

                        Response resultObservationsMod = await ApiSrv.ModObservations(TokenGet.Key, QueryValuesMod);

                        if (!resultObservationsMod.IsSuccess)
                        {
                            UserDialogs.Instance.HideLoading();
                            Toast.ShowError(AlertMessages.Error);
                            return;
                        }
                        else
                        {
                            ObservationMod = JsonConvert.DeserializeObject <List <ObservationMod> >(Crypto.DecodeString(resultObservationsMod.Data));
                            switch (ObservationMod[0].ResultModObservation)
                            {
                            case AddOrModResult.OK:
                                UserDialogs.Instance.HideLoading();
                                UserDialogs.Instance.ShowLoading(AlertMessages.UpdatingList, MaskType.Black);
                                ObservationGetQueryValues QueryValuesGet;
                                if (this.LotAndCommandData.HasData)
                                {
                                    QueryValuesGet = new ObservationGetQueryValues()
                                    {
                                        IdLog      = this.LogItem.IdLog,
                                        IdUser     = PbUser.IdUser,
                                        IdInstance = this.LotAndCommandData.IdInstance,
                                        IdLot      = this.LotAndCommandData.IdLot,
                                        IdCommand  = this.LotAndCommandData.IdCommand
                                    };
                                }
                                else
                                {
                                    QueryValuesGet = new ObservationGetQueryValues()
                                    {
                                        IdLog      = this.LogItem.IdLog,
                                        IdUser     = PbUser.IdUser,
                                        IdInstance = 0,
                                        IdLot      = 0,
                                        IdCommand  = 0
                                    };
                                }
                                Response resultObservationsGet = await ApiSrv.GetObservations(TokenGet.Key, QueryValuesGet);

                                if (!resultObservationsGet.IsSuccess)
                                {
                                    UserDialogs.Instance.HideLoading();
                                    Toast.ShowError(AlertMessages.Error);
                                    return;
                                }
                                else
                                {
                                    Observations = JsonConvert.DeserializeObject <List <ObservationGet> >(Crypto.DecodeString(resultObservationsGet.Data));
                                    ObservationItems.Clear();
                                    foreach (ObservationGet observationGet in Observations)
                                    {
                                        ObservationItems.Add(new ObservationItem()
                                        {
                                            IdObsv         = observationGet.IdObsv,
                                            DateObsv       = observationGet.DateObsv,
                                            NameObsv       = observationGet.NameObsv,
                                            IdUser         = observationGet.IdUser,
                                            DetailObsv     = observationGet.DetailObsv,
                                            DateObsvString = observationGet.DateObsv.ToString(DateTimeFormatString.LatinDate)
                                        });
                                    }
                                    UserDialogs.Instance.HideLoading();
                                }

                                Toast.ShowSuccess(AlertMessages.Success);
                                this.SelectedObservation = new ObservationItem();
                                this.Name    = string.Empty;
                                this.Details = string.Empty;
                                break;

                            case AddOrModResult.ERROR:
                                UserDialogs.Instance.HideLoading();
                                Toast.ShowError(AlertMessages.NoSuccess);
                                break;

                            case AddOrModResult.EXISTING_DATA:
                                UserDialogs.Instance.HideLoading();
                                Alert.Show(AlertMessages.Existing);
                                break;
                            }
                        }
                    }
                    else
                    {
                        UserDialogs.Instance.ShowLoading(AlertMessages.Adding, MaskType.Black);
                        if (!TokenValidator.IsValid(TokenGet))
                        {
                            if (!await ApiIsOnline())
                            {
                                UserDialogs.Instance.HideLoading();
                                Toast.ShowError(AlertMessages.Error);
                                return;
                            }
                            else
                            {
                                if (!await GetTokenSuccess())
                                {
                                    UserDialogs.Instance.HideLoading();
                                    Toast.ShowError(AlertMessages.Error);
                                    return;
                                }
                            }
                        }
                        ObservationAddQueryValues QueryValuesAdd;
                        if (this.LotAndCommandData.HasData)
                        {
                            QueryValuesAdd = new ObservationAddQueryValues()
                            {
                                IdLog      = this.LogItem.IdLog,
                                IdUser     = PbUser.IdUser,
                                IdInstance = this.LotAndCommandData.IdInstance,
                                IdLot      = this.LotAndCommandData.IdLot,
                                IdCommand  = this.LotAndCommandData.IdCommand,
                                NameObsv   = this.Name,
                                DetailObsv = this.Details
                            };
                        }
                        else
                        {
                            QueryValuesAdd = new ObservationAddQueryValues()
                            {
                                IdLog      = this.LogItem.IdLog,
                                IdUser     = PbUser.IdUser,
                                IdInstance = 0,
                                IdLot      = 0,
                                IdCommand  = 0,
                                NameObsv   = this.Name,
                                DetailObsv = this.Details
                            };
                        }
                        Response resultObservationsAdd = await ApiSrv.AddObservations(TokenGet.Key, QueryValuesAdd);

                        if (!resultObservationsAdd.IsSuccess)
                        {
                            UserDialogs.Instance.HideLoading();
                            Toast.ShowError(AlertMessages.Error);
                            return;
                        }
                        else
                        {
                            ObservationAdd = JsonConvert.DeserializeObject <List <ObservationAdd> >(Crypto.DecodeString(resultObservationsAdd.Data));
                            switch (ObservationAdd[0].ResultAddObservation)
                            {
                            case AddOrModResult.OK:
                                UserDialogs.Instance.HideLoading();
                                UserDialogs.Instance.ShowLoading(AlertMessages.UpdatingList, MaskType.Black);
                                ObservationGetQueryValues QueryValuesGet;
                                if (this.LotAndCommandData.HasData)
                                {
                                    QueryValuesGet = new ObservationGetQueryValues()
                                    {
                                        IdLog      = this.LogItem.IdLog,
                                        IdUser     = PbUser.IdUser,
                                        IdInstance = this.LotAndCommandData.IdInstance,
                                        IdLot      = this.LotAndCommandData.IdLot,
                                        IdCommand  = this.LotAndCommandData.IdCommand
                                    };
                                }
                                else
                                {
                                    QueryValuesGet = new ObservationGetQueryValues()
                                    {
                                        IdLog      = this.LogItem.IdLog,
                                        IdUser     = PbUser.IdUser,
                                        IdInstance = 0,
                                        IdLot      = 0,
                                        IdCommand  = 0
                                    };
                                }
                                Response resultObservationsGet = await ApiSrv.GetObservations(TokenGet.Key, QueryValuesGet);

                                if (!resultObservationsGet.IsSuccess)
                                {
                                    UserDialogs.Instance.HideLoading();
                                    Toast.ShowError(AlertMessages.Error);
                                    return;
                                }
                                else
                                {
                                    Observations = JsonConvert.DeserializeObject <List <ObservationGet> >(Crypto.DecodeString(resultObservationsGet.Data));
                                    ObservationItems.Clear();
                                    foreach (ObservationGet observationGet in Observations)
                                    {
                                        ObservationItems.Add(new ObservationItem()
                                        {
                                            IdObsv         = observationGet.IdObsv,
                                            DateObsv       = observationGet.DateObsv,
                                            NameObsv       = observationGet.NameObsv,
                                            IdUser         = observationGet.IdUser,
                                            DetailObsv     = observationGet.DetailObsv,
                                            DateObsvString = observationGet.DateObsv.ToString(DateTimeFormatString.LatinDate)
                                        });
                                    }
                                    UserDialogs.Instance.HideLoading();
                                }

                                Toast.ShowSuccess(AlertMessages.Success);
                                this.Name    = string.Empty;
                                this.Details = string.Empty;
                                break;

                            case AddOrModResult.ERROR:
                                UserDialogs.Instance.HideLoading();
                                Toast.ShowError(AlertMessages.NoSuccess);
                                break;

                            case AddOrModResult.EXISTING_DATA:
                                UserDialogs.Instance.HideLoading();
                                Alert.Show(AlertMessages.Existing);
                                break;
                            }
                        }
                    }
                    IsLoadingData = false;
                }
            }
            catch //(Exception ex)
            {
                UserDialogs.Instance.HideLoading();
                Toast.ShowError(AlertMessages.Error);
            }
        }