Esempio n. 1
0
        public async Task <IHttpActionResult> Putusuapp(int id, usuapp usuapp)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != usuapp.id)
            {
                return(BadRequest());
            }

            db.Entry(usuapp).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!usuappExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 2
0
        public async Task <IHttpActionResult> Getusuapp(int id)
        {
            usuapp usuapp = await db.usuapp.FindAsync(id);

            if (usuapp == null)
            {
                return(NotFound());
            }

            return(Ok(usuapp));
        }
Esempio n. 3
0
        public async Task <IHttpActionResult> Postusuapp(usuapp usuapp)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.usuapp.Add(usuapp);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = usuapp.id }, usuapp));
        }
Esempio n. 4
0
        public async Task <IHttpActionResult> Deleteusuapp(int id)
        {
            usuapp usuapp = await db.usuapp.FindAsync(id);

            if (usuapp == null)
            {
                return(NotFound());
            }

            db.usuapp.Remove(usuapp);
            await db.SaveChangesAsync();

            return(Ok(usuapp));
        }
Esempio n. 5
0
        public async void AgregarUsuApp()
        {
            if (this.nomproperty == null || this.usuproperty == null || this.emailproperty == null || this.passproperty == null)
            {
                await App.Current.MainPage.DisplayAlert("Mensaje", "Debe ingresar todos los datos", "Ok");
            }
            else
            {
                try
                {
                    IsBusy = true;
                    usuapp newuser = new usuapp()
                    {
                        nombre   = nomproperty,
                        usuario  = usuproperty,
                        emailusu = emailproperty,
                        passusu  = passproperty
                    };

                    var        json    = JsonConvert.SerializeObject(newuser);
                    var        content = new StringContent(json, Encoding.UTF8, "application/json");
                    HttpClient client  = new HttpClient();
                    var        result  = await client.PostAsync(Constantes.Base + "/api/usuapps/Postusuapp", content);

                    if (result.StatusCode == HttpStatusCode.Created)
                    {
                        await App.Current.MainPage.DisplayAlert("Genial!", " Tu registro se ha realizado con exito", "Ok");

                        await App.Current.MainPage.Navigation.PopAsync();
                    }
                }
                catch (Exception)
                {
                    await App.Current.MainPage.DisplayAlert("Mensaje", "No hay conexion a internet", "Ok");

                    return;
                }
                finally
                {
                    IsBusy = false;
                }
            }
        }
        public async void Actusu_Clicked(object sender, EventArgs e)
        {
            indicatordu.IsRunning = true;
            try
            {
                usuapp actualizarusu = new usuapp
                {
                    id       = Convert.ToInt32(idusu.Text),
                    nombre   = usuappnom.Text,
                    usuario  = usuarioapp.Text,
                    emailusu = correous.Text,
                    passusu  = paswords.Text,
                };

                var        json    = JsonConvert.SerializeObject(actualizarusu);
                var        connusu = new StringContent(json, Encoding.UTF8, "application/json");
                HttpClient cli     = new HttpClient();
                var        result  = await cli.PutAsync(string.Concat(Constantes.Base + "/api/usuapps/Putusuapp/", idusu.Text), connusu);

                if (result.IsSuccessStatusCode)
                {
                    await DisplayAlert("Mensaje", "Datos actualizados con exito", "OK");

                    await App.Current.MainPage.Navigation.PushAsync(new MasterMenu());

                    //await App.Current.MainPage.Navigation.PopAsync();
                }
                actusu.IsEnabled = true;
            }

            catch (Exception)
            {
                await App.Current.MainPage.DisplayAlert("Mesanje", "No hay conexion a internet", "Ok");

                actusu.IsEnabled      = true;
                indicatordu.IsRunning = false;
                return;
            }

            indicatordu.IsEnabled = true;
        }