public void Create(HuntCreateModel model, int userId) { GameDto game = null; int? huntedGameId = null; if (model.GameType.HasValue & model.GameKind.HasValue) { game = _gameDao.Get(model.GameType.Value, model.GameKind.Value, model.GameSubKind).FirstOrDefault(); var huntGameDto = new HuntedGameDto { GameId = game.Id, GameClass = model.GameClass, GameWeight = model.GameWeight }; huntedGameId = _huntedGameDao.Insert(huntGameDto); } int regionId = _regionDao.GetRegionId(model.City, model.Circuit, model.District); UserDto user = _userDao.GetById(userId); var huntDto = new HuntDto { HuntsmanId = user.HuntsmanId, HuntedGameId = huntedGameId, RegionId = regionId, Shots = model.Shots, Date = model.Date }; _huntDao.Insert(huntDto); }
public void ReportLoss(GameLossModel model) { IList <GameDto> gameDtos = _gameDao.Get(model.Type, model.Kind, model.SubKind); GameDto gameDto = gameDtos.FirstOrDefault(); if (gameDto == null) { throw new Exception("Could not find specified game!"); } int regionId = _regionDao.GetRegionId(model.City, model.Circuit, model.District); var gameLoss = new LossGameDto { GameId = gameDto.Id, Class = model.Class }; var loss = new LossDto { RegionId = regionId, Description = model.Description, Date = model.Date, SanitaryLoss = model.SanitaryLoss }; _lossDao.Insert(gameLoss, loss); }
public void GetByTypeKindAndSubKindTest() { int type = (int)GameType.Big; int kind = (int)GameKind.Deer; int subKind = 3; IList <GameDto> results = _gameDao.Get(type, kind, subKind); Assert.That(results, Is.Not.Empty); }
public void Create(CatchCreateModel model, int userId) { GameDto game = _gameDao.Get(model.GameType, model.GameKind, model.GameSubKind).FirstOrDefault(); if (game == null) { throw new Exception($"Could not find game by specified parameters: Type={model.GameType}, Kind={model.GameKind}, SubKind={model.GameSubKind}"); } int regionId = _regionDao.GetRegionId(model.City, model.Circuit, model.District); UserDto user = _userDao.GetById(userId); var catchDto = new CatchDto { HuntsmanId = user.Id, GameId = game.Id, RegionId = regionId, Count = model.Count, Date = model.Date }; _catchDao.Insert(catchDto); }