Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="contentId"></param>
        /// <param name="tagsList">tagsList is a list |1|2|3 where tags with tag id 1, 2 and 3 will be added to the given content.</param>
        public static void SetTagsForContent(int contentId, string tagsList)
        {
            if (string.IsNullOrEmpty(tagsList))
            {
                return;
            }

            var current = TagApi.SelectByContent(contentId).Select(t => t.Id);
            var newList = tagsList.Replace(">", "").Split('|');

            foreach (var tag in current)
            {
                if (!newList.Contains(tag.ToString()))
                {
                    TagApi.UnTag(contentId, tag);
                }
            }
            foreach (var tagId in newList)
            {
                if (!string.IsNullOrEmpty(tagId))
                {
                    TagApi.Tag(contentId, int.Parse(tagId));
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LastFmApi"/> class.
        /// </summary>
        /// <param name="config">The config.</param>
        public LastFmApi(ILastFmConfig config)
        {
            Config = config;

            Track  = new TrackApi(this);
            Tag    = new TagApi(this);
            Album  = new AlbumApi(this);
            Artist = new ArtistApi(this);
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LastFmApi"/> class.
        /// </summary>
        /// <param name="config">The config.</param>
        public LastFmApi(ILastFmConfig config)
        {
            Config = config;

            Track = new TrackApi(this);
            Tag = new TagApi(this);
            Album = new AlbumApi(this);
            Artist = new ArtistApi(this);
        }
        public IActionResult Ask(int?id)
        {
            if (id == null)
            {
                return(View(new ContentRequest {
                    Type = "question", AvailableTags = TagApi.SelectSuggestions()
                }));
            }

            var c = ContentApi.Select(id.Value);

            ViewData["Title"] = c.Title;
            return(View(c.AsRequest()));
        }
Esempio n. 5
0
        public void ApiV1ItemByAgencyByIdByVersionTagByTagAddGetAndDeleteTest()
        {
            ApiResponse <object> response;

            configuration = GetClientConfig();
            tagApiTest    = new TagApi(configuration);

            response = tagApiTest.ApiV1ItemByAgencyByIdByVersionTagByTagPutWithHttpInfo("int.example", new Guid("65B5D0A6-4367-4680-954E-03D64CC652DD"), 1L, "Test Tag");
            Assert.Equal(200, response.StatusCode);
            List <String> tagsApi = tagApiTest.ApiV1ItemByAgencyByIdByVersionTagGet("int.example", new Guid("65B5D0A6-4367-4680-954E-03D64CC652DD"), 1L);

            Assert.Contains("Test Tag", tagsApi);
            response = tagApiTest.ApiV1ItemByAgencyByIdByVersionTagByTagDeleteWithHttpInfo("int.example", new Guid("65B5D0A6-4367-4680-954E-03D64CC652DD"), 1L, "Test Tag");
            Assert.Equal(200, response.StatusCode);
        }
        public IActionResult SearchOld(int p, string o, string q, int t)
        {
            if (p == 0)
            {
                p = 1;
            }

            int?tagId = t;

            if (t == 0)
            {
                tagId = null;
            }

            if (o == null)
            {
                o = "created-desc";
            }

            var searchRequest = new SearchRequest();

            searchRequest.Text    = q;
            searchRequest.Page    = p;
            searchRequest.OrderBy = o;
            searchRequest.Type    = "question";
            searchRequest.TagId   = tagId;

            var manager    = new ContentManager();
            var results    = manager.Search(searchRequest);
            var resultPage = new SearchResultViewModel()
            {
                Results = results, Request = searchRequest
            };

            resultPage.ResultsCount = ContentApi.GetSearchResultCount("question", q, t);
            resultPage.MaxPages     = Math.Min(5, (int)Math.Floor((double)resultPage.ResultsCount / 10));

            if (resultPage.ResultsCount % 10 != 0)
            {
                resultPage.MaxPages++;
            }

            //move to Tag controller
            resultPage.Tags = TagApi.Select().OrderByDescending(tag => tag.Count).Take(8).ToList();

            return(View("Results", resultPage));
        }
Esempio n. 7
0
        public static Tuple <string, List <TagSuggestion> > GetTagStringForContentAndAvailable(int contentId)
        {
            var    available      = TagApi.SelectSuggestions();
            var    tags           = TagApi.SelectByContent(contentId);
            string tagsForContent = "";

            foreach (var tag in tags)
            {
                tagsForContent += "|" + tag.Id + ">";
                var availableItem = available.FirstOrDefault(t => t.Id == tag.Id);
                if (availableItem != null)
                {
                    availableItem.Accepted = true;
                }
            }

            return(new Tuple <string, List <TagSuggestion> >(tagsForContent, available));
        }
Esempio n. 8
0
        public IActionResult Search(int p, string o, string q, int t)
        {
            var db = new DbApi();

            if (p == 0)
            {
                p = 1;
            }

            int?tagId = t;

            if (t == 0)
            {
                tagId = null;
            }

            if (o == null)
            {
                o = "created-desc";
            }

            var content = ContentApi.Search(10, p, "question", q, o, tagId);

            var result = new ContentListModel();

            result.Content      = content;
            result.ResultsCount = ContentApi.GetSearchResultCount("question", q, t);

            result.MaxPages = Math.Min(5, (int)Math.Floor((double)result.ResultsCount / 10));

            if (result.ResultsCount % 10 != 0)
            {
                result.MaxPages++;
            }

            result.Page       = p;
            result.SearchText = q;
            result.OrderBy    = o;
            result.Tags       = TagApi.Select().OrderByDescending(tag => tag.Count).Take(8).ToList();

            return(View("Results", result));
        }
Esempio n. 9
0
        /// <summary>
        /// 初始化API Client属性
        /// </summary>
        private void Initialize()
        {
            if (string.IsNullOrEmpty(BaseUrl))
            {
                throw new ArgumentNullException("BaseUrl");
            }

            if (string.IsNullOrEmpty(CorpId))
            {
                throw new ArgumentNullException("CorpId");
            }

            if (string.IsNullOrEmpty(CorpSecret))
            {
                throw new ArgumentNullException("CorpSecret");
            }

            User       = new UserApi(this);
            Department = new DepartmentApi(this);
            Tag        = new TagApi(this);
            CheckIn    = new CheckInApi(this);
            Message    = new MessageApi(this);
            Agent      = new AgentApi(this);
        }
Esempio n. 10
0
 public void Init()
 {
     instance = new TagApi();
 }
Esempio n. 11
0
 public static ContentViewModel WithTags(this ContentViewModel i)
 {
     i.Tags = TagApi.SelectByContent(i.Id);
     return(i);
 }
Esempio n. 12
0
 public void OnCreateWithConfiguration()
 {
     configuration = GetClientConfig();
     tagApiTest    = new TagApi();
     Assert.NotNull(tagApiTest);
 }
Esempio n. 13
0
 public void OnCreateWithOutBasePath()
 {
     tagApiTest = new TagApi();
     Assert.NotNull(tagApiTest);
 }
Esempio n. 14
0
 public void OnCreate()
 {
     tagApiTest = new TagApi(this.basePath);
     Assert.NotNull(tagApiTest);
 }