public async Task Bet(string shortName, string price) { var user = Context.User as SocketGuildUser; var bet = await _betRepository.Getbet(shortName.ToLower().Trim()); if (bet == null) { await ReplyAsync($"Bet Doesn't exist"); return; } if (bet.Date < DateTimeOffset.Now) { await ReplyAsync($"Bet is already finished"); return; } if (bet.Locked < DateTimeOffset.Now) { await ReplyAsync($"Bet is locked"); return; } if (!int.TryParse(price.Trim(), out int priceDTO)) { await ReplyAsync($"Price is incorrect"); return; } var exists = await _placedUserBetRepository.PlacedBetExists(bet.BetId, user.Id); if (exists) { await ReplyAsync($"You can't bet twice"); return; } var userExists = await _betUserRepository.GetBetUser(user.Id); if (userExists == null) { await _betUserRepository.AddBetUser(new BetUser { BetUserId = user.Id, Name = user.Username, Points = 0 }); } var userBet = new PlacedBet { Price = priceDTO, Name = user.Username, BetId = bet.BetId, BetUserId = user.Id, BetPlaced = DateTimeOffset.Now }; await _placedUserBetRepository.AddPlacedBet(userBet); await ReplyAsync($"**{userBet.Name}** | Price: ${priceDTO:#,##0} at {bet.Date.ToString("dd/M/yyyy", CultureInfo.GetCultureInfo("nb-NO"))}"); }