private static async Task <int> DoestheFirmProductExists(this IdapadDataAccess dataAccess, FirmProduct firmProduct) { int firmProductId = await dataAccess.QueryFirstOrDefaultAsync <int>( "select Id from FirmProducts where ProductId = @ProductId and FirmId = @FirmId", firmProduct); return(firmProductId); }
public static async Task <int> AddFirmProductAsync(this IdapadDataAccess dataAccess, FirmProduct firmProduct) { var firmProductId = await DoestheFirmProductExists(dataAccess, firmProduct); if (firmProductId < 1) { return(await dataAccess.ExecuteScalarAsync <int>( "Insert FirmProducts (ProductId, FirmId) output inserted.Id values(@ProductId, @FirmId)", firmProduct)); } return(firmProductId); }