Beispiel #1
0
        private AnnualPlanCostTypeModel GetAnnualPlanCostTypeModel(CostType costType,
                                                                   IList <CostPlanDto> previousMarketingYearCostPlans, IList <CostPlanDto> currentMarketingYearCostPlans)
        {
            var annualPlanCostTypeModel = new AnnualPlanCostTypeModel
            {
                CostType     = costType,
                CostTypeName = TypeName.GetFodderTypeName((int)costType),
                PreviousPlan = previousMarketingYearCostPlans.FirstOrDefault(x => x.Type == (int)costType)?.Cost / 1000.0 ?? 0,
                CurrentState = 0, // TODO: How to determine it?
                FutureState  = currentMarketingYearCostPlans.FirstOrDefault(x => x.Type == (int)costType)?.Cost / 1000.0 ?? 0
            };

            switch (costType)
            {
            case CostType.Cost:
                IList <ExpenseDto> previousMarketingYearExpenses = _expenseDao.GetByMarketingYear(PreviousMarketingYearId);
                annualPlanCostTypeModel.Execution = previousMarketingYearExpenses.Sum(x => x.Cost) / 1000.0;
                break;

            case CostType.Revenue:
                IList <CarcassRevenueDto> previousMarketingYearCarcassRevenues = _carcassRevenueDao.GetByMarketingYear(PreviousMarketingYearId);
                annualPlanCostTypeModel.Execution = previousMarketingYearCarcassRevenues.Sum(x => x.Revenue) / 1000.0;
                break;

            default:
                break;
            }

            return(annualPlanCostTypeModel);
        }
Beispiel #2
0
        public CarcassRevenueBaseViewModel GetCarcassRevenueViewModel(int marketingYearId)
        {
            MarketingYearModel marketingYearModel = _marketingYearService.GetMarketingYearModel(marketingYearId);

            IList <CarcassRevenueDto> carcassRevenueDtos = _carcassRevenueDao.GetByMarketingYear(marketingYearId);
            IList <HuntDto>           huntDtos           = _huntDao.GetByMarketingYear(marketingYearId);
            IList <HuntedGameDto>     huntedGameDtos     = _huntedGameDao.GetByMarketingYear(marketingYearId);
            IList <GameDto>           gameDtos           = _gameDao.GetAll();
            IList <GameClassDto>      gameClassDtos      = _gameClassDao.GetAll();

            List <CarcassRevenueViewModel> carcassRevenueViewModels =
                (
                    from carcassRevenue in carcassRevenueDtos
                    join huntedGame in huntedGameDtos on carcassRevenue.HuntedGameId equals huntedGame.Id
                    join hunt in huntDtos on huntedGame.Id equals hunt.HuntedGameId
                    join game in gameDtos on huntedGame.GameId equals game.Id
                    where hunt.Date >= marketingYearModel.Start && hunt.Date <= marketingYearModel.End
                    select new CarcassRevenueViewModel
            {
                Id = carcassRevenue.Id,
                HuntedGameId = huntedGame.Id,
                GameKind = game.Kind,
                GameKindName = game.KindName,
                GameSubKind = game.SubKind,
                GameSubKindName = game.SubKindName,
                Class = huntedGame.GameClass,
                ClassName = huntedGame.GameClass.HasValue ? gameClassDtos.Single(x => x.Id == huntedGame.GameClass).ClassName : "",
                Revenue = carcassRevenue.Revenue,
                CarcassWeight = carcassRevenue.CarcassWeight,
                HuntDate = hunt.Date
            }
                ).ToList();

            AnnualPlanStatusModel annualPlanStatusModel = _annualPlanStatusService.GetByMarketingYearId(marketingYearId);

            var carcassRevenueBaseViewModel = new CarcassRevenueBaseViewModel
            {
                CarcassRevenueViewModels = carcassRevenueViewModels,
                MarketingYearModel       = marketingYearModel,
                AnnualPlanStatusModel    = annualPlanStatusModel
            };

            return(carcassRevenueBaseViewModel);
        }