private OfferedGameDto OfferedGameParse(OfferedGameResult offeredGameResult) { OfferedGameDto offeredGameDto = new OfferedGameDto { Description = offeredGameResult.OfferedGameForm.Description, Duration = int.Parse(offeredGameResult.OfferedGameForm.Duration), LanguageId = _languageService.GetLanguageByCode(offeredGameResult.OfferedGameForm.LanguageCode).Id, MinSize = int.Parse(offeredGameResult.OfferedGameForm.MinSize), MaxSize = int.Parse(offeredGameResult.OfferedGameForm.MaxSize), Title = offeredGameResult.OfferedGameForm.Title, GameType = offeredGameResult.OfferedGameForm.GameType }; if (!string.IsNullOrEmpty(offeredGameResult.OfferedGameForm.Id)) { offeredGameDto.Id = int.Parse(offeredGameResult.OfferedGameForm.Id); } var tempOfferedGame = _offeredGameRepository.GetById(offeredGameDto.Id); if (tempOfferedGame != null) { offeredGameDto.UserOnOfferedGame = _offeredGameRepository.GetById(offeredGameDto.Id).UserOnOfferedGame; offeredGameDto.OfferedGameOnTag = _offeredGameRepository.GetById(offeredGameDto.Id).OfferedGameOnTag; } return(offeredGameDto); }
private void AddGm(string gameMasterCode, OfferedGameDto offeredGameDto) { UserOnOfferedGameDto newMapping = new UserOnOfferedGameDto { OfferedGameId = offeredGameDto.Id, UserType = UserType.GameMaster, UserId = _userRepository.GetByCode(gameMasterCode).Id }; offeredGameDto.UserOnOfferedGame.Add(newMapping); }
public OfferedGameResult GetOfferedGame(int id) { if (id == 0) { throw new ArgumentException("Empty id", nameof(id)); } OfferedGameDto offeredGameDto = _offeredGameRepository.GetById(id); if (offeredGameDto == null) { throw new ArgumentException("Invalid offeredGame id", nameof(id)); } return(OfferedGameParse(offeredGameDto)); }
private OfferedGameResult OfferedGameParse(OfferedGameDto offeredGameDto) { OfferedGameResult result = new OfferedGameResult { OfferedGameForm = new OfferedGameForm { Id = offeredGameDto.Id.ToString(), Description = offeredGameDto.Description, Duration = offeredGameDto.Duration.ToString(), MinSize = offeredGameDto.MinSize.ToString(), MaxSize = offeredGameDto.MinSize.ToString(), Title = offeredGameDto.Title, GameType = offeredGameDto.GameType } }; var offeredGameTempDto = _offeredGameRepository.GetById(offeredGameDto.Id); if (offeredGameTempDto.UserOnOfferedGame.Any()) { UserOnOfferedGameDto mapping = offeredGameTempDto.UserOnOfferedGame .FirstOrDefault(t => t.UserType == UserType.GameMaster); if (mapping != null && mapping.User != null) { result.OfferedGameForm.GameMasterCode = mapping.User.Code; } } if (offeredGameDto.Language != null) { result.OfferedGameForm.LanguageCode = offeredGameDto.Language.TwoDigitSeoCode; } if (offeredGameDto.OfferedGameOnTag.Any()) { result.OfferedGameForm.Tags = new Dictionary <string, string>(); foreach (var tag in offeredGameDto.OfferedGameOnTag) { result.OfferedGameForm.Tags.Add(_tagPrefix + tag.TagId, "on"); } } return(result); }
private void AddTags(IDictionary <string, string> tags, OfferedGameDto offeredGame) { foreach (var tag in tags) { OfferedGameOnTagDto offeredGameOnTagDto = new OfferedGameOnTagDto { OfferedGameId = offeredGame.Id }; //GetFrom Setting string tagstring = tag.Key.Replace(_tagPrefix, ""); if (int.TryParse(tagstring, out int tagId)) { offeredGameOnTagDto.TagId = tagId; } offeredGame.OfferedGameOnTag.Add(offeredGameOnTagDto); } }