Exemplo n.º 1
0
        //0 false , 1 true
        public List<Categorias> getAllCategories()
        {
            List<Categorias> ListCat = new List<Categorias>();
            String sql = "Select *From Category order by name_category";

            using (SqlConnection connection = BD.getConnection())
            {
                SqlCommand Comando = new SqlCommand(string.Format(sql), connection);

                SqlDataReader reader = Comando.ExecuteReader();
                while (reader.Read())
                {

                    Categorias cat = new Categorias();
                    cat.id_categoria = reader.GetInt32(0);
                    cat.name = reader.GetString(1);
                    cat.descripcion = reader.GetString(2);
                    cat.publico = reader.GetInt32(3);

                    ListCat.Add(cat);
                }
            }

            return ListCat;
        }
Exemplo n.º 2
0
        public ActionResult MakeTopic()
        {
            Session["UserIDG"] = Session["UserIDG"];
            Session["UserID"] = Session["UserID"];
            Session["User"] = Session["User"];
            int pub = 0;
            if (Request["TopicPub"] != null)
            {
                pub = 1;
            }
            Categorias cat = new Categorias();
            int id_cat = cat.getIDCatName((string)Request["Cat_name"]);
            int id_user = (int)Session["UserID"];
            string name = (string)Request["TopicName"];
            string des = (string)Request["TopicDes"];
            string msg = (string)Request["TopicMsg"];
            String sql = "Insert into Topic (id_catTopic,id_userTopic,nameTopic,desTopic,msgTopic,publico) "
            + "values  ('{0}','{1}','{2}','{3}','{4}','{5}')";
            int retorno = 0;
            using (SqlConnection connection = BD.getConnection())
            {
                SqlCommand Comando = new SqlCommand(string.Format(sql, id_cat, id_user, name, des, msg, pub), connection);

                retorno = Comando.ExecuteNonQuery();
                connection.Close();

            }
            if (retorno > 0)
            {
                MessageBox.Show("Topic Guardado Con Exito!!", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return RedirectToAction("GeneralCat", new { name = (string)Request["Cat_name"] });
            }
            else
            {
                MessageBox.Show("No se pudo guardar el Topic", "Fallo!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            return Redirect("NuevoTopic");
        }
Exemplo n.º 3
0
 public ActionResult NuevaCategoria()
 {
     Session["UserIDG"] = Session["UserIDG"];
     Session["UserID"] = Session["UserID"];
     Session["User"] = Session["User"];
     ViewBag.Message = "Nueva Categoria";
     Categorias cat = new Categorias();
     List<string> names = cat.getAllNamesCat();
     ViewBag.Items = names;
     ViewBag.Serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
     return View();
 }
Exemplo n.º 4
0
        public ActionResult GeneralCat(string name)
        {
            Session["UserIDG"] = Session["UserIDG"];
            Session["UserID"] = Session["UserID"];
            Session["User"] = Session["User"];
            Session["CatName"] = name;
            Categorias cat = new Categorias();
            int id = cat.getIDCatName(name);
            List<Topics> topics = new List<Topics>();
            Topics top = new Topics();
            List<string> items = new List<string>();
            topics = top.getAllTopicsByCatID(id);

            for (int i = 0; i < topics.Count; i++)
            {

                items.Add(topics[i].name);

            }
            ViewBag.Items = items;
            ViewData["TCount"] = topics.Count;
            return View();
        }