예제 #1
0
        /// <summary>
        /// Total summary
        /// Get only 10 lasted years
        /// Line chart
        /// </summary>
        /// <param name="userID">The user identifier</param>
        /// <returns>List<ReportCollectionByYearModel></returns>
        public async Task <List <CollectionByYearModel> > Summary(Guid userID)
        {
            Task <List <CollectionByYearModel> > _return = Task.Run(() =>
            {
                try
                {
                    List <CollectionByYearModel> _listResult = new List <CollectionByYearModel>();
                    using (var _context = new TDHEntities())
                    {
                        var _list = (from m in _context.FNC_MN_REPORT_SUMMARY()
                                     orderby m.year ascending
                                     select m).Take(10).ToList();
                        foreach (var item in _list)
                        {
                            _listResult.Add(new CollectionByYearModel()
                            {
                                Year = item.year, Income = item.input, Payment = item.output, Total = item.final
                            });
                        }
                    }
                    return(_listResult);
                }
                catch (Exception ex)
                {
                    throw new ServiceException(FILE_NAME, "Summary", userID, ex);
                }
            });
            await _return;

            return(_return.Result);
        }