using System.Collections.Generic;
public static void Main()
var gName = GetTotalPoints();
public static List<Feedback> GetCalculatedFeedback()
""Date"": ""02.07.2019 00:00:00"",
""FeedbackType"": ""Very Negative"",
""Date"": ""02.07.2019 00:00:00"",
""FeedbackType"": ""Negative"",
""Date"": ""01.07.2019 00:00:00"",
""FeedbackType"": ""Positive"",
""Date"": ""01.07.2019 00:00:00"",
""FeedbackType"": ""Very Positive"",
""Date"": ""01.07.2019 00:00:00"",
""FeedbackType"": ""Very Negative"",
""Date"": ""01.07.2019 00:00:00"",
""FeedbackType"": ""Negative"",
""Date"": ""01.07.2019 00:00:00"",
""FeedbackType"": ""Positive"",
""Date"": ""01.07.2019 00:00:00"",
""FeedbackType"": ""Very Positive"",
return JsonConvert.DeserializeObject<List<Feedback>>(input);
public static List<FeedbackSummary> GetTotalPoints(){
var data = GetCalculatedFeedback();
var feedbackValue = new string[] { "Very Negative", "Negative", "Positive", "Very Positive" };
data.GroupBy(x => new {x.Name, x.Date})
.Select(gN => new FeedbackSummary
StationName = gN.Key.Name,
TotalScore = gN.Sum(x =>x.Count * Array.IndexOf(feedbackValue, x.FeedbackType)),
VotesCount = gN.Sum(x =>x.Count),
foreach(var station in gName){
var bestPossibleScore = station.VotesCount*(feedbackValue.Count()-1);
station.PercentScore = (decimal)station.TotalScore / bestPossibleScore * 100;
public class FeedbackSummary{
public string StationName { get; set; }
public int TotalScore { get; set; }
public int VotesCount { get; set; }
public decimal PercentScore { get; set; }
public DateTime Date {get;set;}
public string Name { get; set; }
public DateTime Date { get; set; }
public string FeedbackType { get; set; }
public int Count { get; set; }