public async Task <ApiResponse <TagDto> > Post([FromBody] string value) { TagDto asset = await _tagService.AddTag(UserId, value).ConfigureAwait(false); return(new ApiResponse <TagDto> { Data = asset }); }
public void TagService_AddTag_ThrowsDbUpdateException() { //Arrange TagService tagService = new TagService(_mockTagsRepository.Object, _mockMovieTagService.Object); _mockTagsRepository.Setup(x => x.Insert(It.IsAny <Tag>())).Throws(new DbUpdateException()); //Act var result = tagService.AddTag(_tagDomainModel).ConfigureAwait(false).GetAwaiter().GetResult(); }
// AddTag <tag> public string Execute(string[] data) { string tag = data[0].ValidateOrTransform(); if (tagService.IsTagExisting(tag)) { throw new ArgumentException($"Tag {tag} exists!"); } tagService.AddTag(tag); return("Tag" + tag + " was added successfully!"); }
public void TagService_AddTag_ReturnsInsertedTag() { //Arrange TagService tagService = new TagService(_mockTagsRepository.Object, _mockMovieTagService.Object); _mockTagsRepository.Setup(x => x.Insert(It.IsAny <Tag>())).Returns(_tag); //Act var result = tagService.AddTag(_tagDomainModel).ConfigureAwait(false).GetAwaiter().GetResult(); //Assert Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(TagsDomainModel)); Assert.AreEqual(result.Id, _tagDomainModel.Id); }
/// <summary> /// Adding a tag to a logged in artist /// </summary> /// <param name="tag"></param> /// <returns>tag's id</returns> public async Task <string> AddTag([FromBody] Tag tag) { HttpContext.Request.Cookies.TryGetValue("uid", out string user); HttpContext.Request.Cookies.TryGetValue("token", out string token); var auth = new Dictionary <string, string>() { { "uid", user }, { "token", token } }; var tagResponse = await _tagService.AddTag(new TagRequest() { Auth = auth, Tag = tag }); return(tagResponse); }
// AddTag <tag> public string Execute(string[] data) { string tag = data[0].ValidateOrTransform(); // 2. Extend Photo Share System if (!AuthenticationService.IsAuthenticated()) { throw new InvalidOperationException("Invalid credentials! You shoulld log in first."); } if (tagService.IsExistingTag(tag)) { throw new ArgumentException($"Tag {tag} exists!"); } tagService.AddTag(tag); return($"Tag {tag} was added successfully!"); }
public Host GetHost() { //handle new tags //get new tags List <Tag> newTags = GetNewTagList(); //save to db m_TagService.AddTag(newTags); //get all tags List <Tag> allTags = m_TagService.GetAllTags(); m_DictNameTag.Clear(); foreach (Tag tag in allTags) { m_DictNameTag[tag.Name] = tag; } //read new properties ReadData(); return(m_Host); }
public async Task AddTag(string tagName = "", [Remainder] string content = "") { if (IsInPermittedChannel() && UserCanEditTags()) { if (String.IsNullOrWhiteSpace(tagName)) { await ReplyAsync("You must specify a name for the tag!"); return; } if (String.IsNullOrWhiteSpace(content)) { await ReplyAsync("You must specify content for the tag!"); return; } await ReplyAsync(tagService.AddTag(tagName, content, Context.User)); } }
public static void Go() { RefluxStatsdConfig.Configure(); var logger = NLog.LogManager.GetCurrentClassLogger(); using (DogStatsd.StartTimer("RunRemindMe")) { try { var apiKey = ConfigurationManager.AppSettings["FlowdockAPIKey"]; var searchService = new SearchService(apiKey); var reminderService = new ReminderService(apiKey); var tagService = new TagService(apiKey); var searchResults = searchService.Search(Constants.RemindMe); searchResults = searchResults.Where(r => !r.Tags.Contains(Constants.RemindMeSent)).ToList(); DogStatsd.Gauge("RemindMe.SearchResults", searchResults.Count); logger.Info(searchResults.Count + " search results returned from " + searchResults.OrderBy(r => r.CreatedAt).FirstOrDefault()?.CreatedAtString + " onward."); List <Exception> errors = new List <Exception>(); foreach (var searchResult in searchResults) { try { var reminderDateTime = Parse.Time(searchResult.Content, searchResult.CreatedAt); if (reminderDateTime.HasValue) { tagService.AddTag(searchResult.Id, searchResult.OriginalFlowName, Constants.RemindMeWillSend); if (reminderDateTime.Value < DateTime.UtcNow) { var reminder = searchResult.ToReminder(reminderDateTime.Value); reminderService.SendReminder(reminder); } } } catch (Exception ex) { // Don't break for everyone if one reminder doesn't work. errors.Add(ex); } } DogStatsd.Gauge("RemindMe.Errors", errors.Count); if (errors.Count > 0) { var errorText = string.Join(Environment.NewLine, errors.Select(e => e.Message).ToList()); throw new Exception("The following errors were encountered while reminding: " + errorText); } } catch (Exception ex) { logger.Error(ex.Message + ex.StackTrace); } } }