Inheritance: System.InvalidOperationException
        /// <summary>
        /// Executes a request and transforms a 412 and 409 response to respective exception type.
        /// </summary>
        private async Task <JToken> TransformHttpException(Func <Task <JToken> > action)
        {
            MobileServiceInvalidOperationException error = null;

            try
            {
                return(await action());
            }
            catch (MobileServiceInvalidOperationException ex)
            {
                if (ex.Response != null &&
                    ex.Response.StatusCode != HttpStatusCode.PreconditionFailed &&
                    ex.Response.StatusCode != HttpStatusCode.Conflict)
                {
                    throw;
                }

                error = ex;
            }

            Tuple <string, JToken> responseContent = await this.ParseContent(error.Response);

            JObject value = responseContent.Item2.ValidItemOrNull();

            if (error.Response.StatusCode == HttpStatusCode.Conflict)
            {
                error = new MobileServiceConflictException(error, value);
            }
            else if (error.Response.StatusCode == HttpStatusCode.PreconditionFailed)
            {
                error = new MobileServicePreconditionFailedException(error, value);
            }
            throw error;
        }
Exemple #2
0
        /// <summary>
        /// Updates an <paramref name="instance"/> in the table.
        /// </summary>
        /// <param name="instance">
        /// The instance to update in the table.
        /// </param>
        /// <param name="parameters">
        /// A dictionary of user-defined parameters and values to include in
        /// the request URI query string.
        /// </param>
        /// <returns>
        /// A task that will complete when the update finishes.
        /// </returns>
        public async Task <JToken> UpdateAsync(JObject instance, IDictionary <string, string> parameters)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }

            MobileServiceInvalidOperationException error = null;

            object id      = MobileServiceSerializer.GetId(instance);
            string version = null;

            if (!MobileServiceSerializer.IsIntegerId(id))
            {
                instance = RemoveSystemProperties(instance, out version);
            }
            parameters = AddSystemProperties(this.SystemProperties, parameters);

            try
            {
                Dictionary <string, string> headers = null;

                string content   = instance.ToString(Formatting.None);
                string uriString = GetUri(this.TableName, id, parameters);

                if (version != null)
                {
                    headers = new Dictionary <string, string>();
                    headers.Add("If-Match", GetEtagFromValue(version));
                }

                MobileServiceHttpResponse response = await this.MobileServiceClient.HttpClient.RequestAsync(patchHttpMethod, uriString, this.MobileServiceClient.CurrentUser, content, true, headers);

                return(GetJTokenFromResponse(response));
            }
            catch (MobileServiceInvalidOperationException ex)
            {
                if (ex.Response != null &&
                    ex.Response.StatusCode != HttpStatusCode.PreconditionFailed)
                {
                    throw;
                }

                error = ex;
            }

            JToken value = await this.ParseContent(error.Response);

            throw new MobileServicePreconditionFailedException(error, value);
        }
Exemple #3
0
        private async void button_Click(object sender, RoutedEventArgs e)
        {
            
            

            try
            {
                ProgressBarBefore();
                usuarios = await UsuarioTable
                    .Select(Usuarios => Usuarios)
                    .Where(Usuarios => Usuarios.id == textBoxUser.Text && Usuarios.contrasena == passwordBox.Password.ToString())
                    .ToCollectionAsync();
                ProgressBarAfter();                
                if(usuarios.Count >= 1)
                {
                    var rsUsuario = usuarios.First();
                    
                    if(rsUsuario.Tipo == "Tecnico")
                    {
                        Frame.Navigate(typeof(Administrador), "Tecnico");
                    }
                    else
                    {
                        Frame.Navigate(typeof(Administrador), "Administrador");
                    }
                }
                else
                {
                    MessageDialog mensaje = new MessageDialog("Usuario o contraseña incorrectos.", "Credenciales invalidas");
                    await mensaje.ShowAsync();
                }



            }
            catch (MobileServiceInvalidOperationException ex)
            {
                exception = ex;
            }

            if (exception != null)
            {
                await new MessageDialog(exception.Message, "Error!").ShowAsync();
            }


        }
Exemple #4
0
 /// <summary>
 /// Initializes a new instance of the
 /// <see cref="MobileServiceConflictException"/> class.
 /// </summary>
 /// <param name="source">
 /// The inner exception.
 /// </param>
 /// <param name="value">
 /// The current instance from the server that the conflict occurred for.
 /// </param>
 public MobileServiceConflictException(MobileServiceInvalidOperationException source, JObject value)
     : base(source.Message, source.Request, source.Response, value)
 {
 }
 /// <summary>
 /// Initializes a new instance of the
 /// <see cref="MobileServicePreconditionFailedException"/> class.
 /// </summary>
 /// <param name="innerException">
 /// The inner exception.
 /// </param>
 /// <param name="value">
 /// The current instance from the server that the precondition failed for.
 /// </param>
 public MobileServicePreconditionFailedException(MobileServiceInvalidOperationException innerException, JToken value) : base(innerException.Message, innerException.Request, innerException.Response)
 {
     this.Value = value;
 }
 private static bool ValidateExpectedError(ZumoTest test, MobileServiceInvalidOperationException exception, bool operationShouldSucceed)
 {
     if (operationShouldSucceed)
     {
         if (exception != null)
         {
             test.AddLog("Operation should have succeeded, but it failed: {0}", exception);
             return false;
         }
         else
         {
             return true;
         }
     }
     else
     {
         if (exception == null)
         {
             test.AddLog("Operation should have failed, but it succeeded.");
             return false;
         }
         else
         {
             if (exception.Response.StatusCode == HttpStatusCode.Unauthorized ||
                 exception.Response.StatusCode == HttpStatusCode.Forbidden)
             {
                 test.AddLog("Expected exception thrown, with expected status code.");
                 return true;
             }
             else
             {
                 test.AddLog("Expected exception was thrown, but with invalid status code: {0}", exception.Response.StatusCode);
                 return false;
             }
         }
     }
 }
        private async void comboBoxEstado_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
           
            //Verificar que combobox idDispositivo sea diferente de nulo 
            if (comboBoxIdDispositivo.SelectedItem != null)
            {
                GridDetalles.Visibility = Visibility.Collapsed;
                object selectedItemDispositivo = comboBoxIdDispositivo.SelectedValue.ToString();
                string idDispositivo = selectedItemDispositivo.ToString();
                DateTime date = dpFecha.Date.DateTime;

                //Verificar que radioBUtton esta activo Todo o Fecha 
                if (radioButtonTodo.IsChecked == true)
                {
                    //RadioButton Todo esta activo 

                    // index 0 en comboboxEstado = atendido, Index 1 en comboboxEstado = No atendido
                    // index 0 en comboboxIdDispositivo = Refrigerador, Index 1 en comboboxIdDispositivo = Deshidratadora
                    if (comboBoxEstado.SelectedIndex == 0 && comboBoxDispositivo.SelectedIndex == 0)
                    {
                        //Index de comboboxEstado esta en 0 y es Atendido 
                        //Se selecciono Refrigerador en combobox dispositivo 
                        try
                        {
                            //En la base de datos un 1 representa Atendido y un 0 Representa a No Atendido 
                            ProgressBarBefore();
                            fallaRefri = await FallaTableRefri
                                .Where(Falla => Falla.idRefrigerador == idDispositivo && Falla.Atendido == "1")
                                .ToCollectionAsync();
                            if (fallaRefri.Count >= 1)
                            {
                                listView.ItemsSource = fallaRefri;
                                ProgressBarAfter();
                                listView.Visibility = Visibility.Visible;
                            }
                            else
                            {
                                MessageDialog mensaje = new MessageDialog("No existe registro.", "No existe registro");
                                await mensaje.ShowAsync();
                                listView.Visibility = Visibility.Collapsed;
                                ProgressBarAfter();

                            }
                        }
                        catch (MobileServiceInvalidOperationException ex)
                        {
                            exception = ex;
                        }

                        if (exception != null)
                        {
                            await new MessageDialog(exception.Message, "Error al cargar!").ShowAsync();
                        }


                    }
                    else if (comboBoxEstado.SelectedIndex == 1 && comboBoxDispositivo.SelectedIndex == 0)
                    {
                        //Index de comboboxEstado esta en 1 y es No Atendido 
                        //Se selecciono Refrigerador en combobox dispositivo
                        try
                        {
                            //En la base de datos un 1 representa Atendido y un 0 Representa a No Atendido 
                            ProgressBarBefore();
                            fallaRefri = await FallaTableRefri
                                .Where(Falla => Falla.idRefrigerador == idDispositivo && Falla.Atendido == "0")
                                .ToCollectionAsync();
                            if (fallaRefri.Count >= 1)
                            {
                                listView.ItemsSource = fallaRefri;
                                ProgressBarAfter();
                                listView.Visibility = Visibility.Visible;
                            }
                            else
                            {
                                MessageDialog mensaje = new MessageDialog("No existe registro.", "No existe registro");
                                await mensaje.ShowAsync();
                                listView.Visibility = Visibility.Collapsed;
                                ProgressBarAfter();

                            }
                        }
                        catch (MobileServiceInvalidOperationException ex)
                        {
                            exception = ex;
                        }

                        if (exception != null)
                        {
                            await new MessageDialog(exception.Message, "Error al cargar!").ShowAsync();
                        }

                    }
                    else if (comboBoxEstado.SelectedIndex == 0 && comboBoxDispositivo.SelectedIndex == 1)
                    {
                        //Index de comboboxEstado esta en 0 y es Atendido 
                        //Se selecciono Deshidratadora en combobox dispositivo
                        try
                        {
                            //En la base de datos un 1 representa Atendido y un 0 Representa a No Atendido 
                            ProgressBarBefore();
                            fallaDesh = await FallaTableDesh
                                .Where(Falla => Falla.idDeshidratadora == idDispositivo && Falla.Atendido == "1")
                                .ToCollectionAsync();
                            if (fallaDesh.Count >= 1)
                            {
                                listView.ItemsSource = fallaDesh;
                                ProgressBarAfter();
                                listView.Visibility = Visibility.Visible;
                            }
                            else
                            {
                                MessageDialog mensaje = new MessageDialog("No existe registro.", "No existe registro");
                                await mensaje.ShowAsync();
                                listView.Visibility = Visibility.Collapsed;
                                ProgressBarAfter();

                            }
                        }
                        catch (MobileServiceInvalidOperationException ex)
                        {
                            exception = ex;
                        }

                        if (exception != null)
                        {
                            await new MessageDialog(exception.Message, "Error al cargar!").ShowAsync();
                        }

                    }
                    else if (comboBoxEstado.SelectedIndex == 1 && comboBoxDispositivo.SelectedIndex == 1)
                    {
                        //Index de comboboxEstado esta en 1 y es No Atendido 
                        //Se selecciono Deshidratadora en combobox dispositivo
                        try
                        {
                            //En la base de datos un 1 representa Atendido y un 0 Representa a No Atendido 
                            ProgressBarBefore();
                            fallaDesh = await FallaTableDesh
                                .Where(Falla => Falla.idDeshidratadora == idDispositivo && Falla.Atendido == "0")
                                .ToCollectionAsync();
                            if (fallaDesh.Count >= 1)
                            {
                                listView.ItemsSource = fallaDesh;
                                ProgressBarAfter();
                                listView.Visibility = Visibility.Visible;
                            }
                            else
                            {
                                MessageDialog mensaje = new MessageDialog("No existe registro.", "No existe registro");
                                await mensaje.ShowAsync();
                                listView.Visibility = Visibility.Collapsed;
                                ProgressBarAfter();


                            }
                        }
                        catch (MobileServiceInvalidOperationException ex)
                        {
                            exception = ex;
                        }

                        if (exception != null)
                        {
                            await new MessageDialog(exception.Message, "Error al cargar!").ShowAsync();
                        }

                    }


                }
                else
                {
                    //RadioButton Fecha esta activo 


                    // index 0 en comboboxEstado = atendido, Index 1 en comboboxEstado = No atendido
                    // index 0 en comboboxIdDispositivo = Refrigerador, Index 1 en comboboxIdDispositivo = Deshidratadora
                    if (comboBoxEstado.SelectedIndex == 0 && comboBoxDispositivo.SelectedIndex == 0)
                    {
                        //Index de comboboxEstado esta en 0 y es Atendido 
                        //Se selecciono Refrigerador en combobox dispositivo 
                        try
                        {
                            //En la base de datos un 1 representa Atendido y un 0 Representa a No Atendido 
                            ProgressBarBefore();
                            fallaRefri = await FallaTableRefri
                                .Where(Falla => Falla.idRefrigerador == idDispositivo && Falla.Atendido == "1" && Falla.Fecha == date.ToString("yyyy-MM-dd"))
                                .ToCollectionAsync();
                            if (fallaRefri.Count >= 1)
                            {
                                listView.ItemsSource = fallaRefri;
                                ProgressBarAfter();
                                listView.Visibility = Visibility.Visible;
                            }
                            else
                            {
                                MessageDialog mensaje = new MessageDialog("No existe registro para esta fecha", "No existe registro");
                                await mensaje.ShowAsync();
                                listView.Visibility = Visibility.Collapsed;
                                ProgressBarAfter();

                            }
                        }
                        catch (MobileServiceInvalidOperationException ex)
                        {
                            exception = ex;
                        }

                        if (exception != null)
                        {
                            await new MessageDialog(exception.Message, "Error al cargar!").ShowAsync();
                        }


                    }
                    else if (comboBoxEstado.SelectedIndex == 1 && comboBoxDispositivo.SelectedIndex == 0)
                    {
                        //Index de comboboxEstado esta en 1 y es No Atendido 
                        //Se selecciono Refrigerador en combobox dispositivo
                        try
                        {
                            //En la base de datos un 1 representa Atendido y un 0 Representa a No Atendido 
                            ProgressBarBefore();
                            fallaRefri = await FallaTableRefri
                                .Where(Falla => Falla.idRefrigerador == idDispositivo && Falla.Atendido == "0" && Falla.Fecha == date.ToString("yyyy-MM-dd"))
                                .ToCollectionAsync();
                            if (fallaRefri.Count >= 1)
                            {
                                listView.ItemsSource = fallaRefri;
                                ProgressBarAfter();
                                listView.Visibility = Visibility.Visible;
                            }
                            else
                            {
                                MessageDialog mensaje = new MessageDialog("No existe registro para esta fecha", "No existe registro");
                                await mensaje.ShowAsync();
                                listView.Visibility = Visibility.Collapsed;
                                ProgressBarAfter();

                            }
                        }
                        catch (MobileServiceInvalidOperationException ex)
                        {
                            exception = ex;
                        }

                        if (exception != null)
                        {
                            await new MessageDialog(exception.Message, "Error al cargar!").ShowAsync();
                        }

                    }
                    else if (comboBoxEstado.SelectedIndex == 0 && comboBoxDispositivo.SelectedIndex == 1)
                    {
                        //Index de comboboxEstado esta en 0 y es Atendido 
                        //Se selecciono Deshidratadora en combobox dispositivo
                        try
                        {
                            //En la base de datos un 1 representa Atendido y un 0 Representa a No Atendido 
                            ProgressBarBefore();
                            fallaDesh = await FallaTableDesh
                                .Where(Falla => Falla.idDeshidratadora == idDispositivo && Falla.Atendido == "1" && Falla.Fecha == date.ToString("yyyy-MM-dd"))
                                .ToCollectionAsync();
                            if (fallaDesh.Count >= 1)
                            {
                                listView.ItemsSource = fallaDesh;
                                ProgressBarAfter();
                                listView.Visibility = Visibility.Visible;
                            }
                            else
                            {
                                MessageDialog mensaje = new MessageDialog("No existe registro para esta fecha", "No existe registro");
                                await mensaje.ShowAsync();
                                listView.Visibility = Visibility.Collapsed;
                                ProgressBarAfter();

                            }
                        }
                        catch (MobileServiceInvalidOperationException ex)
                        {
                            exception = ex;
                        }

                        if (exception != null)
                        {
                            await new MessageDialog(exception.Message, "Error al cargar!").ShowAsync();
                        }

                    }
                    else if (comboBoxEstado.SelectedIndex == 1 && comboBoxDispositivo.SelectedIndex == 1)
                    {
                        //Index de comboboxEstado esta en 1 y es No Atendido 
                        //Se selecciono Deshidratadora en combobox dispositivo
                        try
                        {
                            //En la base de datos un 1 representa Atendido y un 0 Representa a No Atendido 
                            ProgressBarBefore();
                            fallaDesh = await FallaTableDesh
                                .Where(Falla => Falla.idDeshidratadora == idDispositivo && Falla.Atendido == "0" && Falla.Fecha == date.ToString("yyyy-MM-dd"))
                                .ToCollectionAsync();
                            if (fallaDesh.Count >= 1)
                            {
                                listView.ItemsSource = fallaDesh;
                                ProgressBarAfter();
                                listView.Visibility = Visibility.Visible;
                            }
                            else
                            {
                                MessageDialog mensaje = new MessageDialog("No existe registro para esta fecha", "No existe registro");
                                await mensaje.ShowAsync();
                                listView.Visibility = Visibility.Collapsed;
                                ProgressBarAfter();

                            }
                        }
                        catch (MobileServiceInvalidOperationException ex)
                        {
                            exception = ex;
                        }

                        if (exception != null)
                        {
                            await new MessageDialog(exception.Message, "Error al cargar!").ShowAsync();
                        }
                    }
                }
            }
        }
        private async void buttonGuardar_Click(object sender, RoutedEventArgs e)
        {
                      
            if(comboBoxDispositivo.SelectedIndex == 0)
            {
                string Atendido;
                string observacion = textBoxObservaciones.Text;
                if(comboBoxCambiarEstado.SelectedIndex == 0)
                {
                    Atendido = "1";
                }
                else
                {
                    Atendido = "0";
                }
                
                try
                {
                    string idFalla = textBlockIdFalla.Text;
                    IMobileServiceTableQuery<Falla_Refri> query = FallaTableRefri.Select(Falla => Falla).Where(Falla => Falla.idFalla == idFalla);
                    var res = await query.ToListAsync();
                    
                    if(res.Count() >= 1)
                    {
                        var falla = res.First();
                        string id = falla.id;
                        JObject jo = new JObject();
                        jo.Add("id", id);
                        jo.Add("idTecnico", comboBoxidTecnico.SelectedValue.ToString());
                        jo.Add("Atendido", Atendido);
                        jo.Add("Observacion", observacion);
                        var inserted = await FallaTableRefri.UpdateAsync(jo);
                    }
                    
                    

                }
                catch(MobileServiceInvalidOperationException ex)
                {
                    exception = ex;
                }

                if(exception!= null)
                {
                    await new MessageDialog(exception.Message, "Error!").ShowAsync();
                }
                else
                {
                    MessageDialog mensaje = new MessageDialog("Se actualizo la información correctamente.", "Actualización correcta");
                    await mensaje.ShowAsync();
                    // Recargar de nuevo 
                    checkBox.IsChecked = false;
                    if(comboBoxCambiarEstado.SelectedIndex == 0)
                    {
                        comboBoxEstado.SelectedIndex = 0;
                    }
                    else
                    {
                        comboBoxEstado.SelectedIndex = 1;
                    }
                }

            }
            else
            {
                string Atendido;
                string observacion = textBoxObservaciones.Text;
                if (comboBoxCambiarEstado.SelectedIndex == 0)
                {
                    Atendido = "1";
                }
                else
                {
                    Atendido = "0";
                }

                try
                {
                    string idFalla = textBlockIdFalla.Text;
                    IMobileServiceTableQuery<Falla_Desh> query = FallaTableDesh.Where(Falla => Falla.idFalla == idFalla);
                    var res = await query.ToListAsync();
                    if (res.Count() >= 1)
                    {
                        var falla = res.First();
                        string id = falla.id;
                        JObject jo = new JObject();
                        jo.Add("id", id);
                        jo.Add("idTecnico", comboBoxidTecnico.SelectedValue.ToString());
                        jo.Add("Atendido", Atendido);
                        jo.Add("Observacion", observacion);
                        var inserted = await FallaTableDesh.UpdateAsync(jo);

                    }
                    

                }
                catch (MobileServiceInvalidOperationException ex)
                {
                    exception = ex;
                }

                if (exception != null)
                {
                    await new MessageDialog(exception.Message, "Error!").ShowAsync();
                }
                else
                {
                    MessageDialog mensaje = new MessageDialog("Se actualizo la información correctamente.", "Actualización correcta");
                    await mensaje.ShowAsync();
                    // Recargar de nuevo 
                    checkBox.IsChecked = false;
                    if (comboBoxCambiarEstado.SelectedIndex == 0)
                    {
                        comboBoxEstado.SelectedIndex = 0;
                    }
                    else
                    {
                        comboBoxEstado.SelectedIndex = 1;
                    }
                }
            }
        }
        public async void LoadComboBox()
        {
            //Cargar el combobox idDipositivo 


            object selectedItemEstado = comboBoxEstado.SelectedValue.ToString();
            object selectedItemDispositivo = comboBoxDispositivo.SelectedValue.ToString();
            textBlock2.Text = "Refrigerador:";
            if (comboBoxDispositivo.SelectedIndex == 0) //comboBoxDispositivo == 0 -> Refrigerador
            {
                comboBoxIdDispositivo.DisplayMemberPath = "idRefrigerador";
                comboBoxIdDispositivo.SelectedValuePath = "idRefrigerador";

                try
                {
                    ProgressBarBefore();
                    refrigeradores = await RefriTable
                        .Select(Refri => Refri)
                        .ToCollectionAsync();
                    comboBoxIdDispositivo.ItemsSource = refrigeradores;
                    ProgressBarAfter();



                }
                catch (MobileServiceInvalidOperationException ex)
                {
                    exception = ex;
                }
                if (exception != null)
                {
                    await new MessageDialog(exception.Message, "Error al cargar!").ShowAsync();
                }

            }
            else
            {
                textBlock2.Text = "Deshidratadora:";
                comboBoxIdDispositivo.DisplayMemberPath = "idDeshidratadora";
                comboBoxIdDispositivo.SelectedValuePath = "idDeshidratadora";

                try
                {
                    ProgressBarBefore();
                    desidratadoras = await DeshTable
                        .Select(Refri => Refri)
                        .ToCollectionAsync();
                    comboBoxIdDispositivo.ItemsSource = desidratadoras;
                    ProgressBarAfter();
                }
                catch (MobileServiceInvalidOperationException ex)
                {
                    exception = ex;
                }

                if (exception != null)
                {
                    await new MessageDialog(exception.Message, "Error al cargar!").ShowAsync();
                }

            }

            if (comboBoxIdDispositivo.SelectedIndex != 0)
            {
                comboBoxIdDispositivo.SelectedIndex = 0;
            }



        }
        private async void checkBox_Checked(object sender, RoutedEventArgs e)
        {
            enableChangeStatus();
            gridDetallesTecnico.Visibility = Visibility.Visible;
            //Cargar combobox id tecnico 
            if(comboBoxIdDispositivo.SelectedItem != null)
            {
                try
                {
                    ProgressBarBefore();
                    usuarios = await UsuarioTable
                        .Select(Usuario => Usuario)
                        .Where(Usuario => Usuario.Tipo == "Tecnico")
                        .ToCollectionAsync();
                    comboBoxidTecnico.ItemsSource = usuarios;                  
                    ProgressBarAfter();
                    comboBoxidTecnico.DisplayMemberPath = "id";
                    comboBoxidTecnico.SelectedValuePath = "id";
                    comboBoxidTecnico.SelectedIndex = 0; 
                    if(comboBoxEstado.SelectedIndex == 0)
                    {
                        //Selecciono atendido 
                        comboBoxCambiarEstado.SelectedIndex = 0;
                    }
                    else
                    {
                        //Selecciono no atendido 
                        comboBoxCambiarEstado.SelectedIndex = 1; 
                    }
                    



                }
                catch (MobileServiceInvalidOperationException ex)
                {
                    exception = ex;
                }
                if (exception != null)
                {
                    await new MessageDialog(exception.Message, "Error al cargar a los Técnicos!").ShowAsync();
                }

            }

            if(comboBoxidTecnico.SelectedItem != null)
            {
                ProgressBarBefore();
                try
                {
                    usuarios = await UsuarioTable
                        .Select(Usuario => Usuario)
                        .Where(Usuario => Usuario.id == comboBoxidTecnico.SelectedValue.ToString())
                        .ToCollectionAsync();
                    ProgressBarAfter();

                    if (usuarios.Count() == 1)
                    {
                        var tecnico = usuarios.First();                        
                        textBlockNombre.Text = tecnico.Nombre;
                        textBlock15Apaterno.Text = tecnico.APaterno;
                        textBlock15Amaterno.Text = tecnico.AMaterno;
                        textBlock15Telefono.Text = tecnico.telefono;
                        textBlock15Correo.Text = tecnico.correo;
                        textBlock15Direccion.Text = tecnico.direccion;

                    }
                }catch(MobileServiceInvalidOperationException ex)
                {
                    exception = ex;
                }

                if(exception != null)
                {
                    await new MessageDialog(exception.Message, "Error!").ShowAsync();
                }
                
                
                gridDetallesTecnico.Visibility = Visibility.Visible;

            }
        }
        private async void comboBoxidTecnico_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (comboBoxidTecnico.SelectedItem != null)
            {
                ProgressBarBefore();
                try
                {
                    usuarios = await UsuarioTable
                        .Select(Usuario => Usuario)
                        .Where(Usuario => Usuario.id == comboBoxidTecnico.SelectedValue.ToString())
                        .ToCollectionAsync();
                    ProgressBarAfter();

                    if (usuarios.Count() == 1)
                    {
                        var tecnico = usuarios.First();
                        textBlockNombre.Text = tecnico.Nombre;
                        textBlock15Apaterno.Text = tecnico.APaterno;
                        textBlock15Amaterno.Text = tecnico.AMaterno;
                        textBlock15Telefono.Text = tecnico.telefono;
                        textBlock15Correo.Text = tecnico.correo;
                        textBlock15Direccion.Text = tecnico.direccion;

                    }
                }
                catch (MobileServiceInvalidOperationException ex)
                {
                    exception = ex;
                }

                if (exception != null)
                {
                    await new MessageDialog(exception.Message, "Error!").ShowAsync();
                }


                gridDetallesTecnico.Visibility = Visibility.Visible;
            }
        }
 private void HandleError(MobileServiceInvalidOperationException ex)
 {
     if (ex.Response.StatusCode == HttpStatusCode.NotFound)
     {
         // Mobile services table itself does not exist. Unrecoverable error. 
         // Customer can't do anything about it. 
         // App developer must make sure that the backend tables have been created 
         ShowError("An unexpected error occurred.");
     }
     else
     {
         ShowError("An unexpected error occurred. Please try again later.");
     } 
 }
 /// <summary>
 /// Initializes a new instance of the
 /// <see cref="MobileServicePreconditionFailedException"/> class.
 /// </summary>
 /// <param name="innerException">
 /// The inner exception.
 /// </param>
 /// <param name="value">
 /// The current instance from the server that the precondition failed for.
 /// </param>
 public MobileServicePreconditionFailedException(MobileServiceInvalidOperationException innerException, JToken value): base(innerException.Message, innerException.Request, innerException.Response)
 {
     this.Value = value;
 }
 /// <summary>
 /// Initializes a new instance of the
 /// <see cref="MobileServicePreconditionFailedException"/> class.
 /// </summary>
 /// <param name="source">
 /// The inner exception.
 /// </param>
 /// <param name="value">
 /// The current instance from the server that the precondition failed for.
 /// </param>
 public MobileServicePreconditionFailedException(MobileServiceInvalidOperationException source, JObject value)
     : base(source.Message, source.Request, source.Response, value)
 {
 }
 /// <summary>
 /// Initializes a new instance of the
 /// <see cref="MobileServicePreconditionFailedException"/> class.
 /// </summary>
 /// <param name="source">
 /// The inner exception.
 /// </param>
 /// <param name="value">
 /// The current instance from the server that the precondition failed for.
 /// </param>
 public MobileServicePreconditionFailedException(MobileServiceInvalidOperationException source, JObject value)
     : base(source.Message, source.Request, source.Response, value)
 {
 }
 /// <summary>
 /// Initializes a new instance of the
 /// <see cref="MobileServiceConflictException"/> class.
 /// </summary>
 /// <param name="source">
 /// The inner exception.
 /// </param>
 /// <param name="value">
 /// The current instance from the server that the conflict occurred for.
 /// </param>
 public MobileServiceConflictException(MobileServiceInvalidOperationException source, JObject value)
     : base(source.Message, source.Request, source.Response, value)
 {
 }