示例#1
0
        public ReportDto GetTheMostProfitableAuthor()
        {
            AuthorDto theMostProfitableAuthor = BookStorage.Instance.GroupBy(book => book.Author)
                                                .Select(book => new { Author = book.Key, TotalProfit = book.Sum(b => b.TotalSoldPrice) })
                                                .OrderByDescending(book => book.TotalProfit)
                                                .FirstOrDefault()
                                                .Author;

            var report = new ReportDto
            {
                Name          = "TheMostProfitableAuthorReport",
                ReportContent = new List <string> {
                    theMostProfitableAuthor.ToString()
                }
            };

            return(report);
        }