예제 #1
0
        public IHttpActionResult GetReceptor_Solicitudes(int id)
        {
            Receptor_Solicitudes receptor_Solicitudes = db.Receptor_Solicitudes.Find(id);

            if (receptor_Solicitudes == null)
            {
                return(NotFound());
            }
            Receptor_Solicitudes recept = db.sp_ver_receptorID(id).Select(x => new Receptor_Solicitudes()
            {
                Codigo_Receptor  = x.Codigo_Receptor,
                Primer_Nombre    = x.Primer_Nombre,
                Segundo_Nombre   = x.Segundo_Nombre,
                Primer_Apellido  = x.Primer_Apellido,
                Segundo_Apellido = x.Segundo_Apellido,
                Direccion        = x.Direccion,
                Fecha_Nacimiento = x.Fecha_Nacimiento,
                Correo           = x.Correo,
                DPI           = x.DPI,
                Codigo_Perfil = x.Codigo_Perfil,
                Pasword       = x.Pasword
            }).FirstOrDefault <Receptor_Solicitudes>();

            return(Ok(recept));
        }
예제 #2
0
        public IHttpActionResult PutReceptor_Solicitudes(int id, Receptor_Solicitudes receptor_Solicitudes)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            bool updaterecep = db.Receptor_Solicitudes.Count(f => f.Codigo_Receptor == id) > 0;

            int actualiza = db.sp_actualizar_receptor
                            (
                id,
                receptor_Solicitudes.Primer_Nombre,
                receptor_Solicitudes.Segundo_Nombre,
                receptor_Solicitudes.Primer_Apellido,
                receptor_Solicitudes.Segundo_Apellido,
                receptor_Solicitudes.Direccion,
                receptor_Solicitudes.Fecha_Nacimiento,
                receptor_Solicitudes.Correo,
                receptor_Solicitudes.DPI,
                receptor_Solicitudes.Codigo_Perfil,
                receptor_Solicitudes.Pasword
                            );

            return(Ok(actualiza));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Receptor_Solicitudes receptor_Solicitudes = db.Receptor_Solicitudes.Find(id);

            db.Receptor_Solicitudes.Remove(receptor_Solicitudes);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        // GET: Receptor_Solicitudes/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Receptor_Solicitudes receptor_Solicitudes = db.Receptor_Solicitudes.Find(id);

            if (receptor_Solicitudes == null)
            {
                return(HttpNotFound());
            }
            return(View(receptor_Solicitudes));
        }
        public ActionResult Edit(Receptor_Solicitudes receptor_Solicitudes)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(" https://aplicacionwebapirest100.azurewebsites.net");
                //HTTP POST
                var putTask = client.PutAsJsonAsync($"api/Receptor_Solicitudes/{receptor_Solicitudes.Codigo_Receptor}", receptor_Solicitudes);
                putTask.Wait();
                var result = putTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    return(RedirectToAction("Index"));
                }

                return(View(receptor_Solicitudes));
            }
        }
        public ActionResult create(Receptor_Solicitudes receptor_Solicitudes)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("https://aplicacionwebapirest100.azurewebsites.net/api/Receptor_Solicitudes");
                var postTask = client.PostAsJsonAsync <Receptor_Solicitudes>("Receptor_Solicitudes", receptor_Solicitudes);
                postTask.Wait();
                var result = postTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    return(RedirectToAction("Index"));
                }
            }
            ModelState.AddModelError(string.Empty, "Error, contacta al administrador");

            ViewBag.Codigo_Perfil = new SelectList(db.Perfiles, "Codigo_Perfil", "Descripcion_Perfil", receptor_Solicitudes.Codigo_Perfil);
            return(View(receptor_Solicitudes));
        }
예제 #7
0
        public IHttpActionResult PostReceptor_Solicitudes(Receptor_Solicitudes receptor_Solicitudes)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            int recept = db.sp_insert_receptor
                         (
                receptor_Solicitudes.Primer_Nombre,
                receptor_Solicitudes.Segundo_Nombre,
                receptor_Solicitudes.Primer_Apellido,
                receptor_Solicitudes.Segundo_Apellido,
                receptor_Solicitudes.Direccion,
                receptor_Solicitudes.Fecha_Nacimiento,
                receptor_Solicitudes.Correo,
                receptor_Solicitudes.DPI,
                receptor_Solicitudes.Codigo_Perfil,
                receptor_Solicitudes.Pasword);

            return(CreatedAtRoute("DefaultApi", new { id = receptor_Solicitudes.Codigo_Receptor }, receptor_Solicitudes));
        }
        // Metodo PUT Receptor de SOlicitudes
        public ActionResult Edit(int id)
        {
            //MODELS
            Receptor_Solicitudes receptor_Solicitudes = null;

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(" https://aplicacionwebapirest100.azurewebsites.net");
                //HTTP GET
                var responseTask = client.GetAsync("api/Receptor_Solicitudes/" + id.ToString());
                responseTask.Wait();

                var result = responseTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    var readTask = result.Content.ReadAsAsync <Receptor_Solicitudes>();
                    readTask.Wait();
                    receptor_Solicitudes = readTask.Result;
                }
            }
            ViewBag.Codigo_Perfil = new SelectList(db.Perfiles, "Codigo_Perfil", "Descripcion_Perfil", receptor_Solicitudes.Codigo_Perfil);
            return(View(receptor_Solicitudes));
        }