コード例 #1
0
        public void AddGameHuntPlan(GameHuntPlanViewModel model, int marketingYearId)
        {
            IList <GameDto> games = _gameDao.GetByKindName(model.GameKindName);

            if (!String.IsNullOrWhiteSpace(model.GameSubKindName))
            {
                games = games.Where(x => x.SubKindName == model.GameSubKindName).ToList();
            }

            int gameId = games.Select(x => x.Id).FirstOrDefault();
            IList <GameHuntPlanDto> existingHuntPlanDto = _gameHuntPlanDao.GetByMarketingYear(marketingYearId);

            if (existingHuntPlanDto.Any(x => x.GameId == gameId && x.Class == model.Class))
            {
                throw new Exception($"Plan pozyskania zwierzyny {model.GameKindName} - {model.GameSubKindName} - {model.ClassName} już istnieje! Proszę użyć opcji edycji istniejącego już planu.");
            }

            var dto = new GameHuntPlanDto
            {
                GameId          = gameId,
                Class           = model.Class,
                Cull            = model.Cull,
                Catch           = model.Catch,
                MarketingYearId = marketingYearId
            };

            _gameHuntPlanDao.Insert(dto);
        }
コード例 #2
0
ファイル: GameHuntPlanDaoTest.cs プロジェクト: Mrotas/Hoof
        public void GetByMarketingYearTest()
        {
            int marketingYearId = 3;

            IList <GameHuntPlanDto> results = _gameHuntPlanDao.GetByMarketingYear(marketingYearId);

            Assert.That(results, Is.Not.Empty);
        }