예제 #1
0
        private async Task SetRecommendationsAsync()
        {
            try
            {
                var profile = await _userProfileContainer.GetAsync();

                var statusId = profile?.StatusId;
                if (statusId != null)
                {
                    IsBusy = true;

                    var recommendationsList =
                        await _recommendationsService.GetRecommendationsAsync(statusId.Value, LifecycleToken);

                    _models.Edit((innerList) =>
                    {
                        innerList.Clear();
                        innerList.AddRange(recommendationsList.Data);
                    });
                }
            }
            catch (Exception e)
            {
                await _errorHandler.HandleAsync(e);
            }
            finally
            {
                IsBusy = false;
            }
        }
        public async Task <ActionResult> Index(IList <string> preferedMusic, int energy)
        {
            if (preferedMusic == null || preferedMusic.Count == 0 || preferedMusic.Count > 5)
            {
                string errorMessage = "Choose a minimum of 1 and a maximum of 5 elements!";

                return(View("ValidationError/Index", new ValidationErrorViewModel(ErrorPageName, errorMessage)));
            }

            if (energy < 0 || energy > 100)
            {
                string errorMessage = "Energy percent must be between 0 and 100";

                return(View("ValidationError/Index", new ValidationErrorViewModel(ErrorPageName, errorMessage)));
            }

            RecommendationsViewModel recommendations = await _recommendationsService.GetRecommendationsAsync(preferedMusic, energy);

            return(View(recommendations));
        }
예제 #3
0
        public async Task <IHttpActionResult> GetRecommendations(RecommendationEvalContext context)
        {
            var result = await _recommendationsService.GetRecommendationsAsync(context);

            return(Ok(result));
        }