예제 #1
0
        public void AddGameHuntPlan(GameCountPlanViewModel 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 <GameCountFor10MarchDto> existingGameCountPlanDto = _gameCountFor10MarchDao.GetByMarketingYear(marketingYearId);

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

            var dto = new GameCountFor10MarchDto
            {
                GameId          = gameId,
                Class           = model.Class,
                Count           = model.Count,
                MarketingYearId = marketingYearId
            };

            _gameCountFor10MarchDao.Insert(dto);
        }
예제 #2
0
        public void GetByMarketingYearTest()
        {
            int marketingYearId = 2;

            IList <GameCountFor10MarchDto> results = _countFor10MarchDao.GetByMarketingYear(marketingYearId);

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