Ejemplo n.º 1
0
        public Tag doestagexist(string tagname, int blogId)
        {
            var repo        = TagFactory.CreateTagRepository();
            var tagtoreturn = new Tag();
            var oldTags     = repo.GetAllTags();

            var isTagThere = oldTags.Exists(t => t.Name == tagname);


            if (isTagThere == true)
            {
                var tag = oldTags.FirstOrDefault(t => t.Name == tagname);
                tagtoreturn = tag;
            }

            else     //if(isTagThere ==  false)
            {
                var newtag = new Tag();
                newtag.Name = tagname;
                repo.AddTag(newtag, blogId);

                tagtoreturn = newtag;
            }

            return(tagtoreturn);
        }
Ejemplo n.º 2
0
        public List <Tag> GetAllTags()
        {
            var repo = TagFactory.CreateTagRepository();
            var post = repo.GetAllTags();

            return(post);
        }
Ejemplo n.º 3
0
        public List <Tag> GetTopTenTags()
        {
            var repo = TagFactory.CreateTagRepository();

            var tenTags = repo.GetAllTags().Take(10);

            return(tenTags.ToList());

            //This is the test method!!! not the PRod method will
            //write when DB is finished... need the SQL List
        }
Ejemplo n.º 4
0
        public Tag GetTagById(int id)
        {
            TagResponse response = new TagResponse();

            var repo = TagFactory.CreateTagRepository();
            var tag  = repo.GetTagById(id);

            if (tag != null)
            {
                response.Success = true;
                response.Message = "It worked!";
                response.Tag     = tag;
            }
            else
            {
                response.Success = false;
                response.Message = "Tag not found!";
            }
            return(tag);
        }
Ejemplo n.º 5
0
        public void RemoveTag(Tag tagToRemove)
        {
            var repo = TagFactory.CreateTagRepository();

            repo.RemoveTag(tagToRemove);
        }
Ejemplo n.º 6
0
        public void AddTag(Tag tagToAdd, int blogId)
        {
            var repo = TagFactory.CreateTagRepository();

            repo.AddTag(tagToAdd, blogId);
        }