Exemplo n.º 1
0
        public IHttpActionResult GetCarreras(string id)
        {
            try
            {
                List <CarrerasModel> carreras = new List <CarrerasModel>();
                List <Carreras>      data     = db.obtenerCarrerasFiltrado(id);
                string resp = validaciones.validarcodigo(id.ToString());

                if (resp.Equals("1"))
                {
                    if (data.Count > 0)
                    {
                        foreach (Carreras carrera in data)
                        {
                            CarrerasModel temp = new CarrerasModel();
                            temp.Codigo = carrera.Codigo;
                            temp.Nombre = carrera.Nombre;

                            carreras.Add(temp);
                        }

                        return(Ok(carreras));
                    }
                    else
                    {
                        return(NotFound());
                    }
                }
                else
                {
                    throw new Exception(resp);
                }
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }