/// <summary> /// This uses fahrenheit values to determine recommendations /// </summary> public void SetRecommendations() { IList <string> recommendations = new List <string>(); if (Forecast == "snow") { Recommendations.Add("Pack some snow shoes."); } if (Forecast == "rain") { Recommendations.Add("Pack rain gear and wear waterproof shoes."); } if (Forecast == "thunderstorms") { Recommendations.Add("Seek shelter and avoid hiking on exposed ridges."); } if (Forecast == "sun") { Recommendations.Add("Don't forget to wear sunblock."); } if (High > 75) { Recommendations.Add("Bring an extra gallon of water."); } if (High - Low > 20) { Recommendations.Add("Wear breathable layers."); } if (Low < 20) { Recommendations.Add("Garry says to stay home - it's cold out there."); } }
public void LoadRecommendations() { User = loader.LoadFollowings(settings.Username); IsBusy = true; var readItems = ServiceLocator.Current.GetInstance <IReadManager>() .GetReadRecommendations(); Recommendations.Clear(); var context = TaskScheduler.FromCurrentSynchronizationContext(); var task = Task.Factory.StartNew(() => { var timeLine = ServiceLocator.Current.GetInstance <ITimelineService>() .GetTimeLineForToday(User.Username); var token = Task.Factory.CancellationToken; foreach (var recommendation in timeLine) { var local = recommendation; Task.Factory.StartNew(() => AddModel(local, readItems.Contains(local.Id)), token, TaskCreationOptions.None, context); } }).ContinueWith(_ => IsBusy = false, context); }
public static async Task <Recommendations> GetRecommendations(NetworkCredential credentials) { await CheckForToken(); Recommendations recommendations = new Recommendations(); HttpWebResponse response = null; try { response = await SendHttpWebGETRequest(credentials, MAL_URL, ContentType.HTML); if (EnsureStatusCode(response)) { StreamReader responseStream = new StreamReader(response.GetResponseStream()); string responseAsString = responseStream.ReadToEnd(); recommendations.AnimeRecommendations = HTMLConverter.GetAnimeRecommendations(responseAsString); recommendations.MangaRecommendations = HTMLConverter.GetMangaRecommendations(responseAsString); } } catch (WebException ex) { Debug.Write("GetRecommendations: WebException response: " + ex.Status); } finally { if (response != null) { response.Dispose(); } } return(recommendations); }
public IEnumerable <Recommendations> Get() { Recommendations r1 = new Recommendations(); r1.ProductId = "10023"; r1.ProductDescription = "Women's Triblend T-Shirt"; r1.ProductImage = "https://cdn.shopify.com/s/files/1/0692/5669/products/charcoal_pivotal_grande_43987370-6045-4abf-b81c-b444e4c481bc_1024x1024.png?v=1503505687"; Recommendations r2 = new Recommendations(); r2.ProductId = "10040"; r2.ProductDescription = "Men's Bring Back Your Weekend T-Shirt"; r2.ProductImage = "https://cdn.shopify.com/s/files/1/0692/5669/products/m2_1024x1024.png?v=1503525900"; Recommendations r3 = new Recommendations(); r3.ProductId = "10057"; r3.ProductDescription = "H2Go Force Water Bottle"; r3.ProductImage = "https://cdn.shopify.com/s/files/1/0692/5669/products/Pivotal-Black-Water-Bottle_1024x1024.png?v=1442486197"; Recommendations r4 = new Recommendations(); r4.ProductId = "10059"; r4.ProductDescription = "Migrating to Cloud Native Application Architectures by Matt Stine"; r4.ProductImage = "https://cdn.shopify.com/s/files/1/0692/5669/products/migrating_1024x1024.png?v=1458083725"; return(new Recommendations[] { r1, r2, r3, r4 }); }
private IDockContent GetContentFromPersistString(string persistString) { if (persistString == typeof(RiskClinicFamilyHistoryView).ToString()) { rcfhv = new RiskClinicFamilyHistoryView(); return(rcfhv); } if (persistString == typeof(AdditionalCancerRiskFactorsView).ToString()) { acrf = new AdditionalCancerRiskFactorsView(); return(acrf); } else if (persistString == typeof(CancerRiskView).ToString()) { crv = new CancerRiskView(); return(crv); } else if (persistString == typeof(SimpleRiskModelView).ToString()) { srmv = new SimpleRiskModelView(); return(srmv); } //else if (persistString == typeof(RiskClinicNotesView).ToString()) //{ // rcnv = new RiskClinicNotesView(); // rcnv.PatientHeaderVisible = false; // return rcnv; //} else if (persistString == typeof(PatientCommunicationView).ToString()) { pcv = new PatientCommunicationView(); pcv.PatientHeaderVisible = false; return(pcv); } else if (persistString == typeof(Recommendations).ToString()) { brecs = new Recommendations(); return(brecs); } else if (persistString == typeof(TestsView).ToString()) { tv = new TestsView(); //drv.PatientHeaderVisible = false; return(tv); } else if (persistString == typeof(OrdersView).ToString()) { ov = new OrdersView(); return(ov); } else if (persistString == typeof(PediatricRecsView).ToString()) { prv = new PediatricRecsView(); return(prv); } else { return(null); } }
public async Task <IActionResult> Edit(int id, [Bind("RecID,UserID")] Recommendations recommendations) { if (id != recommendations.RecID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(recommendations); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RecommendationsExists(recommendations.RecID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(recommendations)); }
public List <RecommendedItem> recommend(long userID, int howMany, IDRescorer rescorer) { lock (this.maxHowMany) { if (howMany > this.maxHowMany[0]) { this.maxHowMany[0] = howMany; } } if (userID == -9223372036854775808L) { return(this.recommendationsRetriever.get(-9223372036854775808L).getItems()); } this.setCurrentRescorer(rescorer); Recommendations recommendations = this.recommendationCache.get(userID); if ((recommendations.getItems().Count < howMany) && !recommendations.isNoMoreRecommendableItems()) { this.clear(userID); recommendations = this.recommendationCache.get(userID); if (recommendations.getItems().Count < howMany) { recommendations.setNoMoreRecommendableItems(true); } } List <RecommendedItem> list = recommendations.getItems(); return((list.Count > howMany) ? list.GetRange(0, howMany) : list); }
public async Task <IActionResult> PutRecommendations([FromRoute] int id, [FromBody] Recommendations recommendations) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != recommendations.RecommendationId) { return(BadRequest()); } _context.Entry(recommendations).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RecommendationsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public Recommendations GetRecommendations(CustomToken token, string trackId, string artistId) { SpotifyWebAPI api = new SpotifyWebAPI() { AccessToken = token.AccessToken, UseAuth = true, TokenType = token.TokenType }; Recommendations recommendations = null; try { recommendations = api.GetRecommendations( artistId.Split(',').ToList(), null , trackId.Split(',').ToList() ); } catch (System.Exception ex) { log.Error( string.Format("GetRecommendations() => trackId {0}, artistId {1}", trackId, artistId) , ex); } return(recommendations); }
private void AddToFlatFile(Namespace @namespace, NamespaceRecommendations recommendations) { var currentNamespace = EnsureNamespace(@namespace, recommendations); if (@namespace.Actions != null && @namespace.Actions.Count > 0) { RecommendedActions recommendation = new RecommendedActions() { Source = "Amazon", Preferred = "Yes", TargetFrameworks = targetFrameworks, Description = GetDescription(@namespace.Actions), Actions = @namespace.Actions }; Recommendations r = new Recommendations() { Type = "Namespace", Name = @namespace.@namespace, KeyType = "Name", Value = @namespace.@namespace, ContainingType = "", RecommendedActions = new List <RecommendedActions>() { recommendation } }; currentNamespace.Recommendations.Add(r); } }
public IList <IRecommendedItem> Recommend(long userID, int howMany, IDRescorer rescorer) { //Preconditions.checkArgument(howMany >= 1, "howMany must be at least 1"); lock (maxHowMany) { if (howMany > maxHowMany[0]) { maxHowMany[0] = howMany; } } // Special case, avoid caching an anonymous user if (userID == PlusAnonymousUserDataModel.TEMP_USER_ID) { return(recommendationsRetriever.Get(PlusAnonymousUserDataModel.TEMP_USER_ID).getItems()); } setCurrentRescorer(rescorer); Recommendations recommendations = recommendationCache.Get(userID); if (recommendations.getItems().Count < howMany && !recommendations.isNoMoreRecommendableItems()) { clear(userID); recommendations = recommendationCache.Get(userID); if (recommendations.getItems().Count < howMany) { recommendations.setNoMoreRecommendableItems(true); } } List <IRecommendedItem> recommendedItems = recommendations.getItems(); return(recommendedItems.Count > howMany?recommendedItems.GetRange(0, howMany) : recommendedItems); }
private void AddToFlatFile(Method method, Namespace @namespace, @Class @class, NamespaceRecommendations recommendations) { var currentNamespace = EnsureNamespace(@namespace, recommendations); RecommendedActions recommendation = new RecommendedActions() { Source = "Amazon", Preferred = "Yes", TargetFrameworks = targetFrameworks, Description = GetDescription(method.Actions), Actions = method.Actions }; Recommendations r = new Recommendations() { Type = "Method", Name = method.Key, KeyType = "Name", Value = method.FullKey, ContainingType = @class.Key, RecommendedActions = new List <RecommendedActions>() { recommendation } }; currentNamespace.Recommendations.Add(r); }
public static StockInfo Create( string ticker, string industry, string companyName, string logo, CurrentPrice currentPrice, PriceTarget priceTarget, Recommendations recommendationTrend ) { var stock = new StockInfo() { Ticker = ticker, Industry = industry, CompanyName = companyName, Logo = logo, CurrentPrice = currentPrice.C, TargetPriceHigh = priceTarget.High, TargetPriceMean = priceTarget.Mean, TargetPriceMedian = priceTarget.Median, TargetPriceLow = priceTarget.Low, StrongBuy = recommendationTrend.StrongBuy, Buy = recommendationTrend.Buy, Hold = recommendationTrend.Hold, Sell = recommendationTrend.Sell, StrongSell = recommendationTrend.StrongSell, }; return(stock); }
public async Task GetRecommendations(CommandContext ctx, [RemainingText] string title = "") { var isShort = await IsTitleShort(title, ctx); if (isShort == true) { return; } IJikan jikan = new Jikan(); var anime = await GetAnimeFromSearch(title); var id = anime.MalId; //uses id to fetch info Recommendations recommendations = await jikan.GetAnimeRecommendations(id); var resultEmbed = new DiscordEmbedBuilder { Title = $"If you liked {anime.Title} you might also like:", Color = DiscordColor.Azure, }; for (int i = 0; i <= 5; i++) { var recommendation = recommendations.RecommendationCollection.ElementAt(i); resultEmbed.AddField(recommendation.Title, recommendation.Url); } resultEmbed.WithFooter("source: MyAnimeList.net"); resultEmbed.WithThumbnail(anime.ImageURL); await ctx.Channel.SendMessageAsync(embed : resultEmbed); }
public void LoadRecommendations() { var context = TaskScheduler.FromCurrentSynchronizationContext(); IsBusy = true; Recommendations.Clear(); Task.Factory.StartNew(() => { var users = dataLoader.LoadFollowings(settings.Username); var token = Task.Factory.CancellationToken; foreach ( var recommendation in readLaterManager.GetReadLaterRecommendations().Select( recommendationId => dataLoader.GetRecommendationById(recommendationId))) { var current = recommendation; Task.Factory.StartNew(() => Recommendations.Add( RecommendationViewModel.FromModel( current, users.Followings.Single( c => c.Id == current.UserId), settings.Font)), token, TaskCreationOptions.None, context); } }).ContinueWith(_ => IsBusy = false, context); }
public async Task SetRecommendationsAsync(DateTime date, string ticker, Recommendations recommendations) { date = date.Date; using (var connection = new NpgsqlConnection(dbConnection)) { var query = "INSERT INTO recommendations(ticker_id, strong_buy, buy, hold, sell, strong_sell, date, date_added) " + "SELECT c.id, @strong_buy, @buy, @hold, @sell, @strong_sell, @date, now() " + "FROM companies c " + "WHERE c.ticker = @ticker; "; var param = new { ticker = ticker, strong_buy = recommendations.StrongBuy, buy = recommendations.Buy, hold = recommendations.Hold, sell = recommendations.Sell, strong_sell = recommendations.StrongSell, date = date }; await connection.ExecuteAsync(query, param); } }
public async Task <ActionResult <SearchItem> > GeneratePlaylist(string keyword = "") { //must be a user access token var accessToken = ""; //await GetAccessToken(); SpotifyWebAPI api = new SpotifyWebAPI { AccessToken = accessToken, TokenType = "Bearer" }; var randomOffset = random.Next(0, 1000); var randomSearch = keyword == "" ? GetRandomSearch() : keyword; TuneableTrack tar = new TuneableTrack { Popularity = random.NextDouble() >= 0.5 ? 80 : 100 }; var genre = GetGenreSeed(keyword); Recommendations rec = api.GetRecommendations(genreSeed: genre, target: tar, market: random.NextDouble() >= 0.5 ? "GB" : "US"); var newPlaylist = api.CreatePlaylist("rsacr1m9ge9ur5tdceead2ziy", "Wholeschool Playlist " + _nameGenerator.Generate(), true, false, $"Auto generated playlist for {keyword} on {DateTime.Now.ToShortDateString()}"); ErrorResponse response = api.ReplacePlaylistTracks(newPlaylist.Id, rec.Tracks.Select(s => s.Uri).ToList()); if (!response.HasError()) { Console.WriteLine("success"); } return(Ok(new { newPlaylist.Name, newPlaylist.Uri, newPlaylist.Href, newPlaylist.Id })); }
/// <summary> /// copy constructor /// </summary> /// <param name="n"></param> public Nanny(Nanny n) { ID = n.id; Floor = n.Floor; Address = n.Address; BirthDate = n.BirthDate; Elevator = n.Elevator; Expertise = n.Expertise; FirstName = n.FirstName; HourSalary = n.HourSalary; IsCostByHour = n.IsCostByHour; LastName = n.LastName; MaxAge = n.MaxAge; MaxChildren = n.MaxChildren; MinAge = n.MinAge; MonthSalary = n.MonthSalary; Phone = n.Phone; VacationByMinisterOfEducation = n.VacationByMinisterOfEducation; for (int i = 0; i < 6; i++) { WorkDays[i] = n.WorkDays[i]; WorkHours[0, i] = n.WorkHours[0, i]; WorkHours[1, i] = n.WorkHours[1, i]; } WorkDays[6] = n.WorkDays[6]; foreach (string str in n.Recommendations) { Recommendations.Add(str); } }
public ActionResult DeleteConfirmed(int id) { Recommendations I = db.recommendations.Find(id); db.recommendations.Remove(I); db.SaveChanges(); return(RedirectToAction("ViewReccomendations")); }
public void OnRecommendationsUpdate(Recommendations recommend) { if (recommend != null) { _recommendations = recommend; Invoke(new UpdateRecommendationsDelegate(OnUpdateRecomendationsInternal)); } }
public virtual void RemoveFromQueue(Book book) { Queue.Remove(book); // if it was on the queue, it probably means that the user // might want to read it again, so let us recommend it Recommendations.Add(book); // add any other business logic related to removing book from queue }
public void UpdateBid(Guid id, UpdateBid product) { Product productToUpdate = _repository.GetByFilter <Product>(p => p.Id == id); if (productToUpdate == null) { return; } productToUpdate.FinalPrice = product.FinalPrice; productToUpdate.WinnerId = product.WinnerId; if (product.Deadline >= DateTime.Today) { productToUpdate.Deadline = product.Deadline; } _repository.Update(productToUpdate); _repository.Save(); Wishlist wishlist = _repository.GetByFilter <Wishlist>(p => p.ProductId == id.ToString() && p.UserId == product.WinnerId); if (wishlist == null) { var newWish = new Wishlist { Id = Guid.NewGuid(), UserId = product.WinnerId, ProductId = id.ToString() }; _repository.Insert(newWish); _repository.Save(); } Recommendations recommendations = _repository.GetByFilter <Recommendations>(p => p.UserId == product.WinnerId && p.CategoryId == productToUpdate.CategoryId); if (recommendations == null) { var newBid = new Recommendations { Id = Guid.NewGuid(), CategoryId = productToUpdate.CategoryId, UserId = product.WinnerId, Bids = 0 }; _repository.Insert(newBid); _repository.Save(); } else { recommendations.Bids++; _repository.Update(recommendations); _repository.Save(); } }
public async Task GetMangaRecommendation_BerserkId_ShouldParseBerserkRecommendations() { Recommendations berserk = await jikan.GetMangaRecommendations(2); //Claymore Assert.Equal(583, berserk.RecommendationCollection.First().MalId); Assert.True(berserk.RecommendationCollection.First().RecommendationCount > 25); Assert.True(berserk.RecommendationCollection.Count > 90); }
private void RecommendHighNumberOfThreads() { if (Threads.Count > 200) { Recommendations.Add(new HighNumberOfThreads { Count = Threads.Count }); } }
public virtual void AddToQueue(Book book) { if (Queue.Contains(book) == false) { Queue.Add(book); } Recommendations.Remove(book); // add any other business logic related to adding a book to the queue }
public IList <RecommendedItem> Recommend(Object userID, int howMany) { if (userID == null) { throw new ArgumentNullException("user ID is null"); } if (howMany < 1) { throw new ArgumentException("howMany must be at least 1"); } lock (maxHowMany) { if (howMany > maxHowMany.Value) { maxHowMany.Set(howMany); } } Recommendations recommendations = recommendationCache[userID]; IList <RecommendedItem> items = recommendations.Items; if (items.Count < howMany && !recommendations.NoMoreRecommendableItems) { Clear(userID); recommendations = recommendationCache[userID]; items = recommendations.Items; if (items.Count < howMany) { recommendations.NoMoreRecommendableItems = true; } } if (items.Count <= howMany) { return(items); } if (items is List <RecommendedItem> ) { List <RecommendedItem> temp = (List <RecommendedItem>)items; return(temp.GetRange(0, howMany)); } else { List <RecommendedItem> temp = new List <RecommendedItem>(howMany); foreach (RecommendedItem item in items) { temp.Add(item); if (--howMany == 0) { break; } } return(temp); } }
public async Task GetAnimeRecommendation_BebopId_ShouldParseCowboyBebopRecommendations() { Recommendations bebop = await _jikan.GetAnimeRecommendations(1); //Samurai Champloo Assert.Equal(205, bebop.RecommendationCollection.First().MalId); Assert.True(bebop.RecommendationCollection.First().RecommendationCount > 70); Assert.True(bebop.RecommendationCollection.Count > 100); }
public async Task <int> CreateRecommendation(Recommendations recommendation) { _context.Add(recommendation); var result = await _context.SaveChangesAsync(); var createdRecommendationEmail = (await _context.Recommendation.FirstAsync(s => s.RecommendationId == recommendation.RecommendationId)).RecommendationId; return(createdRecommendationEmail); }
public async Task <int> UpdateRecommendation(Recommendations recommendations) { _context.Recommendation.Update(recommendations); var result = await _context.SaveChangesAsync(); var updatedRecommendationEmail = recommendations.RecommendationId; return(updatedRecommendationEmail); }
public void MarkAsRead(RecommendationViewModel context) { if (context == null) { return; } readLaterManager.DeleteReadLaterEntry(context.Id); Recommendations.Remove(context); }
public ApplicationModel(IServiceBus bus) { this.bus = bus; Search = new Search(bus); MyQueue = new QueueManager(bus); SubscriptionDetails = new SubscriptionDetails(bus); Recommendations = new Recommendations(); PotentialBooks = Recommendations; MyBooks = new BindableCollection<BookModel>(); }