public void AddTrackPopularitySelect(PopularityModel model) { var success = true; try { var userId = GetUserId(model.UserEmail); using (var context = new sparrow_dbEntities()) { var select = new SPRW_TRACK_POPULAR_SELECT() { DISLIKE_DATE = DateTime.Now, TRACK_ID = model.TrackId, USER_ID = userId }; context.SPRW_TRACK_POPULAR_SELECT.Add(select); context.SaveChanges(); } UpdatePopIndex(model.TrackId); } catch (Exception e) { log.Error("method : AddTrackPopularityPlayThrough | exception : " + e.Message); } }
public void AddTrackPopularityLike(PopularityModel model) { var success = true; try { var userID = GetUserId(model.UserEmail); log.Info("method : AddTrackPopularityLike | action : starting db connection | message : liking track " + model.TrackId); using (var context = new sparrow_dbEntities()) { var like = new SPRW_TRACK_POPULAR_LIKE() { DISLIKE_DATE = DateTime.Now, TRACK_ID = model.TrackId, USER_ID = userID }; context.SPRW_TRACK_POPULAR_LIKE.Add(like); context.SaveChanges(); } UpdatePopIndex(model.TrackId); } catch (Exception e) { log.Error("method : AddTrackPopularityLike | exception : " + e.Message); } }
public HttpResponseMessage TrackPopularity([FromBody] PopularityModel model) { try { _artist.ModifyTrackPopularity(model); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (Exception e) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
public void ModifyTrackPopularity(PopularityModel model) { switch (model.Criteria) { case "playthrough": Repository.AddTrackPopularityPlayThrough(model); break; case "like": Repository.AddTrackPopularityLike(model); break; case "select": Repository.AddTrackPopularitySelect(model); break; } }
public async Task <IEnumerable <PopularityModel> > GetPopular(int top = 20) { var result = new PopularityModel[] { }; try { result = await _popularityService.Query(top); } catch (Exception ex) { Trace.TraceError(ex.Message); //NOTE: discuss with business whether to throw 500 or handle differently } return(result); }
private void Build(OrdersModel.Pizza pizza, string pizzaKey, ref Dictionary <string, PopularityModel> popularity) { if (popularity.ContainsKey(pizzaKey)) { popularity[pizzaKey].OrderCount += 1; } else { var popularityModel = new PopularityModel() { Toppings = pizza.toppings, OrderCount = 1 }; popularity[pizzaKey] = popularityModel; } }