コード例 #1
0
        /// <summary>
        /// Sets the Content-Tags relations for given Tags. If the tags are not there in the DB, they will be added.
        /// </summary>
        /// <param name="tagsString">Comma separated tags string</param>
        /// <param name="content">Content to which tags to be related</param>
        private void SetContentTags(string tagsString, Content content)
        {
            // Delete all existing tags which are not part of the new tags list.
            content.RemoveTags(tagsString);

            // Create Tags and relationships.
            if (!string.IsNullOrWhiteSpace(tagsString))
            {
                var tagsArray = tagsString.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(p => p.Trim());
                if (tagsArray != null && tagsArray.Count() > 0)
                {
                    var notExistingTags = from tag in tagsArray
                                          where Enumerable.FirstOrDefault(content.ContentTags, t => t.Tag.Name == tag) == null
                                          select tag;

                    foreach (var tag in notExistingTags)
                    {
                        var objTag = _tagRepository.GetItem((Tag t) => t.Name == tag);

                        if (objTag == null)
                        {
                            objTag      = new Tag();
                            objTag.Name = tag;
                        }

                        var contentTag = new ContentTags();
                        contentTag.Content = content;
                        contentTag.Tag     = objTag;

                        content.ContentTags.Add(contentTag);
                    }
                }
            }
        }
コード例 #2
0
        public void Load(Mod mod)
        {
            CoinStatDisplay = ContentTags.Get <AdaptiveItemTags>(nameof(CoinStatDisplay));
            CoinStatDisplay.Add(true, ItemID.CoinGun);

            IL.Terraria.Main.MouseText_DrawItemTooltip_GetLinesInfo += SwapCoinGun;
        }
コード例 #3
0
 public void Update(ContentTags item)
 {
     using (IDbConnection dbConnection = Connection)
     {
         dbConnection.Open();
         dbConnection.Query("UPDATE er.ContentTags SET url = @url, description = @description, tags = @tags WHERE contenttagid = @contenttagid", item);
     }
 }
コード例 #4
0
 public void Add(ContentTags item)
 {
     using (IDbConnection dbConnection = Connection)
     {
         dbConnection.Open();
         dbConnection.Execute(@"INSERT INTO er.contenttags(url, description, tags)
                             VALUES(@url,@description, @tags)", item);
     }
 }
コード例 #5
0
        public void CanTheContentTagsBeDeleted()
        {
            _testRepo.Remove(_testid);
            var ContentTags = _testRepo.FindByID(_testid);

            var expectedContentTags = new ContentTags();

            Assert.IsNull(ContentTags);
        }
コード例 #6
0
 /// <summary>
 ///     Starts a table with/without border.
 /// </summary>
 /// <param name="border">True for a border.  False for not.</param>
 public void PushStartTable(bool border)
 {
     if (border)
     {
         ContentTags.Add("<table border = 1>");
     }
     else
     {
         ContentTags.Add("<table>");
     }
 }
コード例 #7
0
        public void ShouldUpdateExistingContentTags()
        {
            //arrange
            var updatedItem = new ContentTags {
                contenttagid = 2, url = "test url from update ContentTags", description = "updated ContentTags from update", contentid = 2
            };

            //act
            _mockrepo.Update(updatedItem);
            var obj = _mockrepo.FindByID(2);

            //assert

            Assert.AreEqual("test url from update ContentTags", obj.url);
        }
コード例 #8
0
        public void ShouldAddANewContentTagsToList()
        {
            //arrange
            var newitem = new ContentTags {
                contenttagid = 11, url = "url slug for new tags 11",
                contentid    = 11, description = "slug-11"
            };

            //act
            _mockrepo.Add(newitem);
            var obj = _mockrepo.FindByID(11);

            //assert
            Assert.AreEqual("slug-11", obj.description);
        }
コード例 #9
0
        public void CanANewContentTagsBeCreated()
        {
            ContentTags a = new ContentTags()
            {
                contenttagid = 99,
                url          = "Some image from test",
                contentid    = 3,
                description  = "new-post-from-test",
                tags         = "some awesome tesx",
            };

            _testRepo.Add(a);

            var insertedContentTags = _testRepo.FindAll().Where(w => w.url == a.url).First();

            _testid = insertedContentTags.contenttagid;
            Assert.AreEqual(a.url, insertedContentTags.url);
        }
コード例 #10
0
        public void CanAContentTagsBeUpdated()
        {
            var         maxid = _testRepo.FindAll().Min(m => m.contenttagid);
            ContentTags a     = new ContentTags()
            {
                contenttagid = maxid,
                url          = $"Some image from test{maxid}",
                contentid    = 3,
                description  = "new-post-from-test",
                tags         = "some awesome tesx",
            };

            _testRepo.Update(a);


            var updatedContentTags = _testRepo.FindByID(maxid);

            Assert.AreEqual(a.url, updatedContentTags.url);
        }
コード例 #11
0
 /// <summary>
 /// </summary>
 public void PushStartTableRow()
 {
     ContentTags.Add("<tr>");
 }
コード例 #12
0
        public void DoesContentTagsClassExists()
        {
            ContentTags a = new ContentTags();

            Assert.IsInstanceOfType(a, typeof(ContentTags));
        }
コード例 #13
0
 public void Put(int id, [FromBody] ContentTags data)
 {
     ContentTagsRepo.Update(data);
     _log.LogInformation($"The ContentTags that was updated {JsonConvert.SerializeObject(data)}");
 }
コード例 #14
0
 public void AddContentTags([FromBody] ContentTags data)
 {
     ContentTagsRepo.Add(data);
     _log.LogInformation($"The ContentTags that is added {JsonConvert.SerializeObject(data)}");
 }
コード例 #15
0
 /// <summary>
 /// </summary>
 public void PushEndTableRow()
 {
     ContentTags.Add("</tr>");
 }
コード例 #16
0
 /// <summary>
 /// </summary>
 public void PushStartTableColumn()
 {
     ContentTags.Add("<td>");
 }
コード例 #17
0
 /// <summary>
 /// </summary>
 public void PushEndTableColumn()
 {
     ContentTags.Add("</td>");
 }
コード例 #18
0
 /// <summary>
 /// </summary>
 /// <param name="data"></param>
 public void PushTextHeader(string data)
 {
     ContentTags.Add("<a href=\"#top\"><H2>" + data + "</H2></a>");
 }
コード例 #19
0
 /// <summary>
 /// </summary>
 public void PushEndTable()
 {
     ContentTags.Add("</table>");
 }
コード例 #20
0
 /// <summary>
 /// </summary>
 /// <param name="data"></param>
 public void PushLargeText(string data)
 {
     ContentTags.Add("<H2>" + data + "</H2>");
 }
コード例 #21
0
 /// <summary>
 /// </summary>
 /// <param name="tag"></param>
 public void PushData(string tag)
 {
     ContentTags.Add(tag);
 }