public async Task <Maybe <PublisherGame> > GetPublisherGame(Guid publisherGameID) { var query = new { publisherGameID }; using (var connection = new MySqlConnection(_connectionString)) { PublisherGameEntity gameEntity = await connection.QueryFirstOrDefaultAsync <PublisherGameEntity>( "select * from tblpublishergame where tblpublishergame.PublisherGameID = @publisherGameID;", query); if (gameEntity is null) { return(Maybe <PublisherGame> .None); } var publisher = await GetPublisher(gameEntity.PublisherID); if (publisher.HasNoValue) { throw new Exception($"Publisher cannot be found: {gameEntity.PublisherID}"); } Maybe <MasterGameYear> masterGame = null; if (gameEntity.MasterGameID.HasValue) { masterGame = await GetMasterGameYear(gameEntity.MasterGameID.Value, publisher.Value.Year); } PublisherGame publisherGame = gameEntity.ToDomain(masterGame, publisher.Value.Year); return(publisherGame); } }
public async Task AddPublisherGame(Publisher publisher, PublisherGame publisherGame) { PublisherGameEntity entity = new PublisherGameEntity(publisher, publisherGame); using (var connection = new MySqlConnection(_connectionString)) { await connection.ExecuteAsync( "insert into tblpublishergame (PublisherGameID,PublisherID,GameName,Timestamp,CounterPick,ManualCriticScore,FantasyPoints,MasterGameID,DraftPosition,OverallDraftPosition) VALUES " + "(@PublisherGameID,@PublisherID,@GameName,@Timestamp,@CounterPick,@ManualCriticScore,@FantasyPoints,@MasterGameID,@DraftPosition,@OverallDraftPosition);", entity); } }