Пример #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 List <GameModel> GetByKindName(string kindName)
        {
            IList <GameDto> games = _gameDao.GetByKindName(kindName);

            var gameModels = games.Select(x => new GameModel
            {
                Id          = x.Id,
                Type        = x.Type,
                Kind        = x.Kind,
                KindName    = x.KindName,
                SubKind     = x.SubKind,
                SubKindName = x.SubKindName
            }).ToList();

            return(gameModels);
        }