public ActionResult getLeaderboard(Models.leaderboardViewModel leaderboard) { List<Models.leaderboardViewModel> leaderBoardToPaint = new List<Models.leaderboardViewModel>(); Models.leaderboardViewModel aux = new Models.leaderboardViewModel(); aux.position = "1"; aux.username = "******"; aux.iconPath = "../Images/Avatars/coenomesque.png"; aux.rcrsDone = "10"; aux.score = "10.5"; aux.efficiency = "1.2"; leaderBoardToPaint.Add(aux); aux = new Models.leaderboardViewModel(); aux.position = "2"; aux.username = "******"; aux.iconPath = "../Images/Avatars/congaitan.png"; aux.rcrsDone = "1"; aux.score = "0.3"; aux.efficiency = "0.1"; leaderBoardToPaint.Add(aux); List<Models.leaderboardViewModel> leaderBoardToPaint1 = _dalFacde.getLeaderBoard(leaderboard.rcrTypes, leaderboard.dateStart, leaderboard.dateEnd); string json = JsonConvert.SerializeObject(leaderBoardToPaint1); return Json(json, JsonRequestBehavior.AllowGet); }
internal List<Models.leaderboardViewModel> getLeaderBoard(List<String> typesRCR, DateTime StartDate, DateTime EndDate) { /** * Primero flitrar por tipo * Despues por usuario * Despues por prioridad * Retornar */ //Crear la respuesta List<String> names = getUserNames(); List<Models.leaderboardViewModel> response = new List<Models.leaderboardViewModel>(); //Verificar si el tipo es Todos if (typesRCR.Count == 1 && typesRCR.ElementAt(0).Equals("Todos")) { foreach (String s in names) { List<RCR> temp = getRCRDoneByUser(s, StartDate, EndDate); double starsSum = 0; foreach (RCR r in temp) { if (r.Complejidad.Trim().Equals("Alta")) { starsSum += 3; } else if (r.Complejidad.Trim().Equals("Media")) { starsSum += 1; } else { starsSum += 0.5; } } Models.leaderboardViewModel tempRating = new Models.leaderboardViewModel(); tempRating.username = s; tempRating.rcrsDone = "" + temp.Count; tempRating.score = "" + starsSum; response.Add(tempRating); } } else { foreach (String s in names) { List<RCR> temp = getRCRDoneByUser(s, StartDate, EndDate, typesRCR); double starsSum = 0; foreach (RCR r in temp) { if (typesRCR.Contains(r.Tipo_RCR)) { if (r.Complejidad.Trim().Equals("Alta")) { starsSum += 3; } else if (r.Complejidad.Trim().Equals("Media")) { starsSum += 1; } else { starsSum += 0.5; } } } Models.leaderboardViewModel tempRating = new Models.leaderboardViewModel(); tempRating.username = s; tempRating.rcrsDone = "" + temp.Count; tempRating.score = "" + starsSum; response.Add(tempRating); } } return response; }