public async Task PutAsyncTest() { // Arrange var mockSuggestionRepository = GetDefaultISuggestionRepositoryInstance(); var mockUserRepository = GetDefaultIUserRepositoryInstance(); var mockUnitOfWork = GetDefaultIUnitOfWorkInstance(); Suggestion suggestion = new Suggestion(); int suggestionId = 1; suggestion.Id = suggestionId; suggestion.Message = "mejorar"; Suggestion suggestionExpected = new Suggestion(); suggestionExpected.Message = "es bueno"; mockSuggestionRepository.Setup(r => r.FindById(suggestionId)) .Returns(Task.FromResult <Suggestion>(suggestion)); var service = new SuggestionService(mockSuggestionRepository.Object, mockUnitOfWork.Object, mockUserRepository.Object); // Act SuggestionResponse result = await service.UpdateASync(suggestionId, suggestionExpected); // Assert Assert.AreEqual(suggestionExpected.Message, result.Resource.Message); }
async Task SaveSuggestions() { try { if (Contribution.ContributionType.Value.Id.HasValue) { await SuggestionService.StoreContributionTypeSuggestionAsync(Contribution.ContributionType.Value.Id.Value); } if (Contribution.ContributionTechnology.Value.Id.HasValue) { await SuggestionService.StoreContributionTechnologySuggestionAsync(Contribution.ContributionTechnology.Value.Id.Value); } if (Contribution.AdditionalTechnologies.Any()) { await SuggestionService.StoreContributionTechnologySuggestionsAsync(Contribution.AdditionalTechnologies.Select(x => x.Id.Value).ToList()); } } catch (Exception ex) { // Non-essential so not reporting back to the user. AnalyticsService.Report(ex); } }
public void SuggestionSelected(string word) { var token = SuggestionService.GetTokenFromPosition(_tokens, _selectionStart); var text = Text; var startText = text.Substring(0, token.Pos); var endText = text .Substring(token.Pos + token.Length, text.Length - (token.Pos + token.Length)); switch (token.Type) { case SuggestionService.SuggestionToken.SuggestionTokenId.HashTag: text = startText + "#" + word + " " + endText; break; case SuggestionService.SuggestionToken.SuggestionTokenId.ScreenName: text = startText + "@" + word + " " + endText; break; case SuggestionService.SuggestionToken.SuggestionTokenId.Emoji: text = startText + word.Split('\t').First().Trim() + endText; break; default: text = startText + endText; break; } Text = text; SelectionStart = text.Length - endText.Length; }
public WordSuggestionHandlingService(string fileName) { using (var stream = File.OpenRead(fileName)) { var dictionary = DictionaryLoader.Load(new StreamReader(stream)); _suggestionService = new SuggestionService(dictionary); } }
public async Task <List <Suggestion> > Index() { var settings = ConnectionSettings.CreateBasicAuth(Neo4JClient.uri, Neo4JClient.user, Neo4JClient.password); using (var client = new Neo4JClient(settings)) { SuggestionService myService = new SuggestionService(client); return(await myService.getAllSuggestions()); } }
public async Task StartAsync(IDialogContext context) { await context.PostAsync("Please wait..."); var cc = context.MakeMessage(); cc.Type = "message"; cc.Attachments = new List <Attachment>(); var genre = _things.Item2.First().genre.First(); var currentlyOnChannel = new SuggestionService().Get(_things.Item2.First().channelid.ToString()).First(); var shows = new GenreService().Get(genre.genreid, currentlyOnChannel.subgenre.ToString()).Where(x => x.scheduleStatus != "PLAYING_NOW").ToList(); var output = $"You are currently watching **{currentlyOnChannel.title}**\n"; output += $"Here are some other programs currently showing of the same genre of **{genre.name}** \n"; if (shows.Count != 0) { for (int i = 0; i < (shows.Count >= 10 ? 10 : shows.Count); i++) { var tvShow = shows[i]; var poster = new PosterService().Get(tvShow.title); var imgUrl = poster != null && poster.poster != null ? poster.poster : "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcRj0YzDMrnC8kqGjvTH3tQ_VpVY4HbtcpGCNcJ_tR4WdiMKvjYc"; var plCard = new ThumbnailCard() { Title = tvShow.title, Subtitle = tvShow.channel.title + " (" + tvShow.channel.channelno + ") - " + tvShow.startAsDateTime.ToString(), Text = $"{tvShow.shortDesc} - {tvShow.startAsDateTime.ToString()}", Images = new List <CardImage> { new CardImage(url: imgUrl) } }; Attachment plAttachment = plCard.ToAttachment(); cc.Attachments.Add(plAttachment); //output += $"{shows[i].channel.channelno}. {shows[i].channel.title} {shows[i].title} \n"; //output += $"**Short Desc** {shows[i].shortDesc} *{shows[i].startAsDateTime}*\n"; } } else { output += "*Sorry no matches found."; } cc.Text = output; await context.PostAsync(cc); //context.Reset(); context.Wait(HandleSuggestionResponse); }
public TestSetup() { var dataContext = new FakeDataContext(); Repository = new Repository <Suggestion>(dataContext); CacheMock = new TestCacheManager().CacheMock; TestLoggerFactory = new TestLoggerFactory(); SuggestionService = new SuggestionService(CacheMock.Object, Repository, TestLoggerFactory); FakeSuggestions = dataContext.EntitySet <Suggestion>() as FakeSuggestions; }
public ActionResult AddSuggestion(Recommendation recommendation) { if (ModelState.IsValid) { SuggestionService.createSuggestion(recommendation); return(RedirectToAction("ShowSuggestions")); } else { return(View()); } }
public async Task StartAsync(IDialogContext context) { await context.PostAsync("Please wait..."); var cc = context.MakeMessage(); cc.Text = "Here are some of the shows that everyone is talking about?"; await context.PostAsync(cc); var replyToConversation = context.MakeMessage(); replyToConversation.Type = "message"; replyToConversation.Attachments = new List <Attachment>(); var sportSuggestions = new SuggestionService().GetUserSuggestions(); foreach (var suggestion in sportSuggestions) { List <CardImage> cardImages = new List <CardImage>(); cardImages.Add(new CardImage(url: suggestion.imageurl)); List <CardAction> cardButtons = new List <CardAction>(); CardAction plButton = new CardAction() { Value = "watch", Type = "postBack", Title = "Watch" }; cardButtons.Add(plButton); ThumbnailCard plCard = new ThumbnailCard() { Title = suggestion.title, Subtitle = suggestion.channel.title + " (" + suggestion.channel.channelid + ") - " + suggestion.startAsDateTime.ToString(), Text = $"{suggestion.shortDesc}", Images = cardImages, Buttons = cardButtons }; Attachment plAttachment = plCard.ToAttachment(); replyToConversation.Attachments.Add(plAttachment); } replyToConversation.AttachmentLayout = AttachmentLayoutTypes.Carousel; await context.PostAsync(replyToConversation); context.Wait(HandleSuggestionResponse); }
public async Task HandleProgramSelection(IDialogContext context, IAwaitable <IMessageActivity> argument) { var message = await argument; var cc = context.MakeMessage(); string eventid; if (context.UserData.TryGetValue("sp" + message.Text, out eventid)) { TVShow tvShow = new SuggestionService().GetById(eventid); cc.Type = "message"; cc.Attachments = new List <Attachment>(); var poster = new PosterService().Get(tvShow.title); var imgUrl = poster != null && poster.poster != null ? poster.poster : "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcRj0YzDMrnC8kqGjvTH3tQ_VpVY4HbtcpGCNcJ_tR4WdiMKvjYc"; var plCard = new ThumbnailCard() { Title = tvShow.title, Subtitle = tvShow.channel.title + " (" + tvShow.channel.channelid + ") - " + tvShow.startAsDateTime.ToString(), Text = $"{tvShow.shortDesc}", Images = new List <CardImage> { new CardImage(url: imgUrl) }, Buttons = new List <CardAction> { new CardAction() { Value = "watch", Type = "postBack", Title = "Watch" } } }; Attachment plAttachment = plCard.ToAttachment(); cc.Attachments.Add(plAttachment); await context.PostAsync(cc); context.Wait(HandleProgramChosen); } else { await HandleSuggestionResponse(context, argument); await context.PostAsync(cc); context.UserData.SetValue("welcomeMessageSeen", false); context.UserData.SetValue("success", true); context.Done("Success"); } }
public ActionResult Index(Suggestion objSuggestion) { int returnVal = new SuggestionService().Add(objSuggestion); if (returnVal > 0) { ViewBag.Success = "Thank you for sharing you suggestion."; } else { ViewBag.Success = "There is some error to add your suggestion, please try again."; } Suggestion objModel = new Suggestion(); return(View(objModel)); }
public async Task SaveAsyncWhenFacultiesReturnsSuccess() { var mockSuggestionRepository = GetDefaultISuggestionRepositoryInstance(); var mockUserRepository = GetDefaultIUserRepositoryInstance(); var mockUnitOfWork = GetDefaultIUnitOfWorkInstance(); Suggestion suggestion = new Suggestion(); mockSuggestionRepository.Setup(r => r.AddAsync(suggestion)) .Returns(Task.FromResult <Suggestion>(suggestion)); var service = new SuggestionService(mockSuggestionRepository.Object, mockUnitOfWork.Object, mockUserRepository.Object); SuggestionResponse result = await service.SaveAsync(suggestion); var message = result.Message; message.Should().Be(""); }
public async Task <IActionResult> GetSuggestion(string id) { var settings = ConnectionSettings.CreateBasicAuth(Neo4JClient.uri, Neo4JClient.user, Neo4JClient.password); using (var client = new Neo4JClient(settings)) { User user = new User { Id = id }; UserService aux = new UserService(client); aux.addUser(user); SuggestionService myService = new SuggestionService(client); List <SuggestionInfo> ans = await myService.getSuggestion(aux.Users); return(Ok(ans)); } }
private void SuggestionTokenize() { if (string.IsNullOrWhiteSpace(_text)) { _tokens = null; return; } try { _tokens = SuggestionService.Tokenize(_text); } catch { _tokens = null; } }
public async Task <IActionResult> Deactivate(Suggestion suggestion) { var settings = ConnectionSettings.CreateBasicAuth(Neo4JClient.uri, Neo4JClient.user, Neo4JClient.password); using (var client = new Neo4JClient(settings)) { SuggestionService myService = new SuggestionService(client); myService.addSuggestion(suggestion); string aux = await myService.ChangeIsActive(myService.Suggestions); Response ans = new Response() { Ans = aux }; return(Ok(ans)); } }
private async Task ShowProgrammeList(IDialogContext context, string typeOfChannel, string channels) { await context.PostAsync("Please wait..."); var cc = context.MakeMessage(); cc.Attachments = new List <Attachment>(); cc.Type = "message"; var suggestions = new SuggestionService().GetProgrammesOnChannels(channels); string text = "On the " + typeOfChannel + " channels now..."; int count = 1; foreach (var suggestion in suggestions) { context.UserData.SetValue("sp" + count, suggestion.eventid);//.EventId); var poster = new PosterService().Get(suggestion.title); var imgUrl = poster != null && poster.poster != null ? poster.poster : "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcRj0YzDMrnC8kqGjvTH3tQ_VpVY4HbtcpGCNcJ_tR4WdiMKvjYc"; var plCard = new ThumbnailCard() { Title = $"{count}. " + suggestion.title, Subtitle = suggestion.channel.title + " (" + suggestion.channel.channelno + ") - " + suggestion.startAsDateTime.ToString(), Text = $"{suggestion.shortDesc} - {suggestion.startAsDateTime.ToString()}", Images = new List <CardImage> { new CardImage(url: imgUrl) } }; Attachment plAttachment = plCard.ToAttachment(); cc.Attachments.Add(plAttachment); //text += "\n1. _" + suggestion.title;//.Name; //text += "_ on " + suggestion.channel.title;//.Channel; //+ " for the next ";// + (suggestion.EndTime - DateTime.Now).Minutes; count++; } //text += "\n\nWould you like more details of any of these? Enter the number for more details."; cc.Text = text; await context.PostAsync(cc); await context.PostAsync("\n\nWould you like more details of any of these? Enter the number for more details."); context.Wait(HandleProgramSelection); }
private static void Main(string[] args) { using (var stream = new StreamReader(Console.OpenStandardInput())) { var dictionary = DictionaryLoader.Load(stream); var suggestionService = new SuggestionService(dictionary); var suggestCount = Convert.ToInt32(stream.ReadLine()); using (var streamWriter = new StreamWriter(Console.OpenStandardOutput())) { for (var i = 0; i < suggestCount; i++) { var token = stream.ReadLine(); var result = suggestionService.Suggest(token); WriteSuggestions(result, streamWriter); } } } }
public async Task GetAsyncTestUnhappy() { // Arrange var mockSuggestionRepository = GetDefaultISuggestionRepositoryInstance(); var mockUserRepository = GetDefaultIUserRepositoryInstance(); var mockUnitOfWork = GetDefaultIUnitOfWorkInstance(); int suggestionId = 1; var service = new SuggestionService(mockSuggestionRepository.Object, mockUnitOfWork.Object, mockUserRepository.Object); // Act SuggestionResponse result = await service.GetByIdAsync(suggestionId); var message = result.Message; // Assert message.Should().Be("Suggestion not found"); }
/// <summary> /// Loads the contribution areas for the contribution. /// </summary> async Task LoadContributionAreas(bool force = false) { try { State = LayoutState.Loading; allCategories = await MvpApiService.GetContributionAreasAsync(force).ConfigureAwait(false); if (allCategories == null) { State = LayoutState.Error; return; } PopulateList(); // Gather suggestions var suggestions = await SuggestionService.GetContributionTechnologySuggestions(); var items = allCategories .SelectMany(x => x.Contributions) .SelectMany(y => y.ContributionArea) .Where(x => suggestions.Contains(x.Id ?? Guid.Empty)); Suggestions = new List <ContributionTechnologyViewModel>(items .Select(x => new ContributionTechnologyViewModel { ContributionTechnology = x })); } catch (Exception ex) { State = LayoutState.Error; AnalyticsService.Report(ex); } finally { if (State != LayoutState.Error) { State = GroupedContributionTechnologies.Count > 0 ? LayoutState.None : LayoutState.Empty; } } }
public async Task GetAsyncTestHappy() { // Arrange var mockSuggestionRepository = GetDefaultISuggestionRepositoryInstance(); var mockUserRepository = GetDefaultIUserRepositoryInstance(); var mockUnitOfWork = GetDefaultIUnitOfWorkInstance(); Suggestion suggestion = new Suggestion(); int suggestionId = 1; suggestion.Id = suggestionId; mockSuggestionRepository.Setup(r => r.FindById(suggestionId)) .Returns(Task.FromResult <Suggestion>(suggestion)); var service = new SuggestionService(mockSuggestionRepository.Object, mockUnitOfWork.Object, mockUserRepository.Object); // Act SuggestionResponse result = await service.GetByIdAsync(suggestionId); // Assert Assert.AreEqual(suggestion, result.Resource); }
public async Task <IList <SuggestionInfo> > CreateSuggest(User user) { var settings = ConnectionSettings.CreateBasicAuth(Neo4JClient.uri, Neo4JClient.user, Neo4JClient.password); using (var client = new Neo4JClient(settings)) { SuggestionService myService = new SuggestionService(client); UserService myService2 = new UserService(client); myService2.addUser(user); IList <SuggestionInfo> toReturn = await myService.CreateSuggestedRelation(myService2.Users); UserInfo metadata = new UserInfo { User = user, Suggestions = myService.Suggestions }; myService2.addMetadata(metadata); await myService2.CreateRelationSuggUser(myService2.UserInfos); return(toReturn); } }
public void should_faster_then_10_seconds([Values("input.txt")] string fileName) { var allStopwatch = new Stopwatch(); using (var stream = new StreamReader(fileName)) { allStopwatch.Start(); var stopWatchLoader = new Stopwatch(); stopWatchLoader.Start(); var dictionary = DictionaryLoader.Load(stream); var suggestionService = new SuggestionService(dictionary); stopWatchLoader.Stop(); var stopWatchSuggestion = new Stopwatch(); stopWatchSuggestion.Start(); var suggestCount = Convert.ToInt32(stream.ReadLine()); using (var outputStream = new StreamWriter("output.txt")) { for (var i = 0; i < suggestCount; i++) { var token = stream.ReadLine(); var result = suggestionService.Suggest(token); foreach (var suggestion in result) { outputStream.WriteLine(suggestion); } outputStream.WriteLine(); } } stopWatchSuggestion.Stop(); allStopwatch.Stop(); Console.WriteLine(string.Format("load seconds:{0}", stopWatchLoader.Elapsed.TotalSeconds)); Console.WriteLine(string.Format("suggestion seconds:{0}", stopWatchSuggestion.Elapsed.TotalSeconds)); Console.WriteLine(string.Format("total seconds:{0}", allStopwatch.Elapsed.TotalSeconds)); allStopwatch.Elapsed.TotalSeconds.Should().BeLessOrEqualTo(10); } }
public ActionResult ViewSuggestion() { List <Suggestion> model = new SuggestionService().GetAll(); return(View(model)); }
private void SuggestionCheck() { if (_tokens == null) { SuggestionMessenger.Raise(new SuggestionNotification { SuggestWords = null, IsOpen = false }); return; } try { var token = SuggestionService.GetTokenFromPosition(_tokens, _selectionStart); var words = new List <string>(); switch (token.Type) { case SuggestionService.SuggestionToken.SuggestionTokenId.HashTag: foreach (var userId in Connecter.Instance.TweetCollecter.Keys) { lock (Connecter.Instance.TweetCollecter[userId].EntitiesObjectsLock) { words.AddRange(Connecter.Instance.TweetCollecter[userId] .HashTagObjects.Where(x => x.StartsWith(token.Value)) .OrderBy(x => x)); } } break; case SuggestionService.SuggestionToken.SuggestionTokenId.ScreenName: if (!string.IsNullOrEmpty(token.Value)) { foreach (var userId in Connecter.Instance.TweetCollecter.Keys) { lock (Connecter.Instance.TweetCollecter[userId].EntitiesObjectsLock) { words.AddRange(Connecter.Instance.TweetCollecter[userId] .ScreenNameObjects.Where(x => x.StartsWith(token.Value)) .OrderBy(x => x)); } } } break; case SuggestionService.SuggestionToken.SuggestionTokenId.Emoji: if (!string.IsNullOrEmpty(token.Value)) { words.AddRange(EmojiPatterns.EmojiDictionary .Where(x => x.Key.StartsWith(token.Value)) .OrderBy(x => x.Key) .Select(x => x.Value + "\t" + x.Key)); } break; } SuggestionMessenger.Raise( new SuggestionNotification { SuggestWords = words, IsOpen = words.Count > 0 }); } catch { SuggestionMessenger.Raise(new SuggestionNotification { SuggestWords = null, IsOpen = false }); } }
public SuggestionServiceTest() { _service = new SuggestionService(); }
public SuggestionController(SuggestionService suggestionService) { _suggestionService = suggestionService; }
public SuggestionController(SuggestionService suggestionService, UserService userService) { _suggestionService = suggestionService; _userService = userService; }
public SuggestionMod(SuggestionService suggestionService) { _suggestionService = suggestionService; }
public void SetUp() { var words = new List <WordInfo>() { new WordInfo { Frequency = 10, Word = "kare" }, new WordInfo { Frequency = 10, Word = "kanojo" }, new WordInfo { Frequency = 1, Word = "karetachi" }, new WordInfo { Frequency = 7, Word = "korosu" }, new WordInfo { Frequency = 3, Word = "sekura" }, new WordInfo { Frequency = 3, Word = "sekura" }, new WordInfo { Frequency = 3, Word = "sekura" }, new WordInfo { Frequency = 3, Word = "sekura" }, new WordInfo { Frequency = 3, Word = "sekura" }, new WordInfo { Frequency = 3, Word = "sekura" }, new WordInfo { Frequency = 3, Word = "sekura" }, new WordInfo { Frequency = 3, Word = "sekura" }, new WordInfo { Frequency = 3, Word = "sekura" }, new WordInfo { Frequency = 3, Word = "sekura" }, new WordInfo { Frequency = 3, Word = "sekura" }, new WordInfo { Frequency = 3, Word = "sekura" }, new WordInfo { Frequency = 3, Word = "sekura" } }; var dictionary = new SuggestionHashTable(); foreach (var word in words) { dictionary.Add(word); } _suggestionService = new SuggestionService(dictionary); }
public SuggestionCommands(IOptionsMonitor <DiscordBotOptions> options, SuggestionService sugguestionService) { _options = options; _suggestionService = sugguestionService; }