public async Task CreateCommandItem(CommandItem item) { // TODO check if there is a better way of doing this if (item == null) { throw new ArgumentNullException(nameof(item)); } var channel = await _context.Channel.SingleOrDefaultAsync(x => x.ChannelId == item.Channel.ChannelId); var guild = await _context.Guild.SingleOrDefaultAsync(x => x.GuildId == item.Guild.GuildId); var user = await _context.User.SingleOrDefaultAsync(x => x.UserId == item.User.UserId); if (channel != null) { item.Channel = channel; } if (guild != null) { item.Guild = guild; } if (user != null) { item.User = user; } _context.Add(item); }
public void CreateUser(User item) { // TODO check if there is a better way of doing this if (item == null) { throw new ArgumentNullException(nameof(item)); } _context.Add(item); }