Example #1
0
 /// <summary>
 /// Lists the tags to the home page
 /// </summary>
 /// <returns></returns>
 public ActionResult GetTags()
 {
     var tim = new TagManager();
     return PartialView("_GetTags", tim.GetAllTag());
 }
Example #2
0
 /// <summary>
 /// Lists the tags
 /// </summary>
 /// <returns></returns>
 public ActionResult ListAllTags()
 {
     //Manager classes
     var tim = new TagManager();
     var qim = new QuestionManager();
     var tags = tim.GetAllTag();
     //We list the tags
     var retlist = new List<TagListModel>();
     foreach (var item in tags)
     {
         var add = new TagListModel();
         add.Tag = item;
         int count;
         qim.AllQuestionToOneTagToPagedList(item.Id, 1, 1, out count);
         add.Questions = count;
         retlist.Add(add);
     }
     return View(retlist.OrderByDescending(q => q.Questions).ToList());
 }
Example #3
0
        /// <summary>
        /// Function to list the tags
        /// </summary>
        /// <param name="prefix">Prefix</param>
        /// <returns></returns>
        public ActionResult FindTags(string prefix)
        {
            var manager = new TagManager();
            var tagList = manager.GetAllTag();

            //We create a list with the name of tags
            var tagName = new List<string>();
            foreach (var tag in tagList)
            {
                tagName.Add(tag.Name);
            }

            //We create a list with the tags and a temporary id for them
            var allTags = new List<KeyValuePair<int, string>>();
            int i = 1;
            foreach (var name in tagName)
            {
                allTags.Add(new KeyValuePair<int, string>(i, name));
                i++;
            }

            //We select the tags which contains the typed prefix
            var result = (from l in allTags
                      where l.Value.StartsWith(prefix, StringComparison.InvariantCultureIgnoreCase)
                      orderby l.Value
                      select l).ToList();

            return Json(result, JsonRequestBehavior.AllowGet);
        }