コード例 #1
0
 public JsonResult Rate(int id, int rateValue)
 {
     RecommendationHelper helper = new RecommendationHelper();
     if (id != 0)
     {
         using (BlondsCookingContext context = new BlondsCookingContext())
         {
             context.UserRatings.Add(new UserRating()
             {
                 RecipeId = id,
                 Rate = rateValue,
                 UserId = User.Identity.GetUserId()
             });
             context.SaveChanges();
         }
     }
     if (helper.CanRecalculateUserParameters(User.Identity.GetUserId()))
     {
         RecommendationHelper recommendationHelper = new RecommendationHelper();
         var ratesAndParametersOfDishesRatedByUser =
             recommendationHelper.GetRatesAndParametersOfDishesRatedByUser(User.Identity.GetUserId());
         UserParametersHelper userParametersHelper = new UserParametersHelper();
         userParametersHelper.CalculateParametersForUser(ratesAndParametersOfDishesRatedByUser);
     }
     return Json(id);
 }
コード例 #2
0
 public ActionResult Recommendation()
 {
     RecommendationHelper helper = new RecommendationHelper();
     if (helper.CanGetRecommendation(User.Identity.GetUserId()))
     {
         IEnumerable<Recipe> model = helper.GetRecommendedRecipesForUser(User.Identity.GetUserId());
         return View(model);
     }
     return View("NotEnoughRates");
 }