Пример #1
0
        private MonthlyReportKindGameModel GetKindMonthlyReportModel(IGrouping <int, GameDto> gamesByKind)
        {
            var monthlyReportSubKindGameModels = new List <MonthlyReportSubKindGameModel>();

            foreach (var subKind in gamesByKind.GroupBy(x => x.SubKind))
            {
                if (subKind.Key.HasValue)
                {
                    MonthlyReportSubKindGameModel subKindGameModel = GetSubKindMonthlyReportModel(gamesByKind.Key, subKind);

                    monthlyReportSubKindGameModels.Add(subKindGameModel);
                }
            }

            var monthlyReportKindGameModel = new MonthlyReportKindGameModel
            {
                Kind     = gamesByKind.Key,
                KindName = GamesByType.FirstOrDefault(x => x.Kind == gamesByKind.Key).KindName,
                MonthlyReportSubKindGameModels = monthlyReportSubKindGameModels
            };

            List <int> gameIds = GamesByType.Where(x => x.Kind == gamesByKind.Key).Select(x => x.Id).ToList();

            monthlyReportKindGameModel = SetPlans(monthlyReportKindGameModel, gameIds);

            return(monthlyReportKindGameModel);
        }
Пример #2
0
        private void SetFallowDeerAndMouflonData(MonthlyReportGameModel monthlyReportBigGameModel)
        {
            MonthlyReportKindGameModel mouflonReportModel    = monthlyReportBigGameModel.MonthlyReportKindGameModels.FirstOrDefault(x => x.Kind == (int)GameKind.Mouflon);
            MonthlyReportKindGameModel fallowDeerReportModel = monthlyReportBigGameModel.MonthlyReportKindGameModels.FirstOrDefault(x => x.Kind == (int)GameKind.FallowDeer);

            if (mouflonReportModel == null || fallowDeerReportModel == null)
            {
                return;
            }

            fallowDeerReportModel.KindName      += $"/{mouflonReportModel.KindName}";
            fallowDeerReportModel.Culls         += mouflonReportModel.Culls;
            fallowDeerReportModel.Catches       += mouflonReportModel.Catches;
            fallowDeerReportModel.Losses        += mouflonReportModel.Losses;
            fallowDeerReportModel.HuntPlanCulls += mouflonReportModel.HuntPlanCulls;
            for (int i = 0; i < fallowDeerReportModel.MonthlyReportSubKindGameModels.Count; i++)
            {
                fallowDeerReportModel.MonthlyReportSubKindGameModels[i].SubKindName   += $"/{mouflonReportModel.MonthlyReportSubKindGameModels[i].SubKindName}";
                fallowDeerReportModel.MonthlyReportSubKindGameModels[i].Culls         += mouflonReportModel.MonthlyReportSubKindGameModels[i].Culls;
                fallowDeerReportModel.MonthlyReportSubKindGameModels[i].Catches       += mouflonReportModel.MonthlyReportSubKindGameModels[i].Catches;
                fallowDeerReportModel.MonthlyReportSubKindGameModels[i].Losses        += mouflonReportModel.MonthlyReportSubKindGameModels[i].Losses;
                fallowDeerReportModel.MonthlyReportSubKindGameModels[i].HuntPlanCulls += mouflonReportModel.MonthlyReportSubKindGameModels[i].HuntPlanCulls;
            }

            monthlyReportBigGameModel.MonthlyReportKindGameModels.Remove(monthlyReportBigGameModel.MonthlyReportKindGameModels.FirstOrDefault(x => x.Kind == (int)GameKind.Mouflon));
            monthlyReportBigGameModel.MonthlyReportKindGameModels.Remove(monthlyReportBigGameModel.MonthlyReportKindGameModels.FirstOrDefault(x => x.Kind == (int)GameKind.FallowDeer));

            monthlyReportBigGameModel.MonthlyReportKindGameModels.Add(fallowDeerReportModel);
            monthlyReportBigGameModel.MonthlyReportKindGameModels = monthlyReportBigGameModel.MonthlyReportKindGameModels.OrderBy(x => x.Kind).ToList();
        }
Пример #3
0
        private MonthlyReportGameModel GetMonthlyReportData(GameType gameType)
        {
            ReportGameType = (int)gameType;

            var gamesByKind = GamesByType.GroupBy(x => x.Kind);
            var monthlyReportKindGameModels = new List <MonthlyReportKindGameModel>();

            foreach (var gameByKind in gamesByKind)
            {
                if (!HuntPlans.Any(x => x.GameId == gameByKind.FirstOrDefault().Id))
                {
                    continue;
                }

                if (ReportGameType == (int)GameType.Big && gameByKind.Key.IsIn(new List <GameKind> {
                    GameKind.Moose, GameKind.DeerSika
                }))
                {
                    continue;
                }

                MonthlyReportKindGameModel kindGameModel = GetKindMonthlyReportModel(gameByKind);

                monthlyReportKindGameModels.Add(kindGameModel);
            }

            var monthlyReportModel = new MonthlyReportGameModel
            {
                MonthlyReportKindGameModels = monthlyReportKindGameModels
            };

            return(monthlyReportModel);
        }