public async Task <ActionResult> Create(TipodeIdentificacion tipodeIdentificacion)
        {
            ApiCall api = new ApiCall(Session);

            if (ModelState.IsValid)
            {
                var result = await api.PostAsync("/api/TipoIdentificacion", tipodeIdentificacion);

                if (result.IsSuccessStatusCode)
                {
                    return(RedirectToAction("Index"));
                }
            }
            bitacora.AgregarBitacora("TipoIdentificacion", "Create", "No se creo", Session["US"].ToString(), 2);
            return(View(tipodeIdentificacion));
        }
        // GET: TipoIdentificacion/Edit/5
        public async Task <ActionResult> Edit(int id)
        {
            ApiCall api    = new ApiCall(Session);
            var     result = await api.GetAsync("/api/TipoIdentificacion/" + id);

            TipodeIdentificacion tipoIdentificacion = null;

            if (result.IsSuccessStatusCode)
            {
                var datastring = result.Content.ReadAsStringAsync().Result;
                tipoIdentificacion = JsonConvert.DeserializeObject <TipodeIdentificacion>(datastring);
            }
            if (tipoIdentificacion == null)
            {
                bitacora.AgregarBitacora("TipoIdentificacion", "Edit", "No se encontro", Session["US"].ToString(), 2);
                return(HttpNotFound());
            }
            return(View(tipoIdentificacion));
        }
Esempio n. 3
0
        public IHttpActionResult PostTipoIdentificacion(TipodeIdentificacion tipoIdentificacion)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                if (db.AgregarTipoIdentificacion(tipoIdentificacion.TipoIdentificacion))
                {
                    return(Created(Url.Request.RequestUri, tipoIdentificacion));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
            return(NotFound());
        }
Esempio n. 4
0
        public IHttpActionResult PutTipoIdentificacion(int id, TipodeIdentificacion tipoIdentificacion)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tipoIdentificacion.IdTipoIdentificacion)
            {
                return(BadRequest());
            }
            bool result;

            try
            {
                result = db.ActualizarTipoIdentificacion(tipoIdentificacion.IdTipoIdentificacion, tipoIdentificacion.TipoIdentificacion);
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }

            return(Ok(result));
        }