/// <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); } } } }
public void Load(Mod mod) { CoinStatDisplay = ContentTags.Get <AdaptiveItemTags>(nameof(CoinStatDisplay)); CoinStatDisplay.Add(true, ItemID.CoinGun); IL.Terraria.Main.MouseText_DrawItemTooltip_GetLinesInfo += SwapCoinGun; }
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); } }
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); } }
public void CanTheContentTagsBeDeleted() { _testRepo.Remove(_testid); var ContentTags = _testRepo.FindByID(_testid); var expectedContentTags = new ContentTags(); Assert.IsNull(ContentTags); }
/// <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>"); } }
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); }
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); }
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); }
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); }
/// <summary> /// </summary> public void PushStartTableRow() { ContentTags.Add("<tr>"); }
public void DoesContentTagsClassExists() { ContentTags a = new ContentTags(); Assert.IsInstanceOfType(a, typeof(ContentTags)); }
public void Put(int id, [FromBody] ContentTags data) { ContentTagsRepo.Update(data); _log.LogInformation($"The ContentTags that was updated {JsonConvert.SerializeObject(data)}"); }
public void AddContentTags([FromBody] ContentTags data) { ContentTagsRepo.Add(data); _log.LogInformation($"The ContentTags that is added {JsonConvert.SerializeObject(data)}"); }
/// <summary> /// </summary> public void PushEndTableRow() { ContentTags.Add("</tr>"); }
/// <summary> /// </summary> public void PushStartTableColumn() { ContentTags.Add("<td>"); }
/// <summary> /// </summary> public void PushEndTableColumn() { ContentTags.Add("</td>"); }
/// <summary> /// </summary> /// <param name="data"></param> public void PushTextHeader(string data) { ContentTags.Add("<a href=\"#top\"><H2>" + data + "</H2></a>"); }
/// <summary> /// </summary> public void PushEndTable() { ContentTags.Add("</table>"); }
/// <summary> /// </summary> /// <param name="data"></param> public void PushLargeText(string data) { ContentTags.Add("<H2>" + data + "</H2>"); }
/// <summary> /// </summary> /// <param name="tag"></param> public void PushData(string tag) { ContentTags.Add(tag); }