public async Task AddItemAsync(string itemName, ulong sellPrice, string rarity) { _context.Add(new Item { ItemName = itemName, SellPrice = sellPrice, Rarity = rarity }); //change rarity to int await _context.SaveChangesAsync(); }
public async Task <UserProfile> GetOrCreateUserProfile(ulong serverId, ulong userId) { var userProfile = await _context.UserProfiles .Where(x => x.ServerId == serverId) .FirstOrDefaultAsync(x => x.UserId == userId); if (userProfile != null) { return(await Task.FromResult(userProfile)); } userProfile = new UserProfile { ServerId = serverId, UserId = userId, Level = 1, Exp = 0, EssentiCoins = 0 }; _context.Add(userProfile); await _context.SaveChangesAsync(); return(userProfile); }
public async Task AddRankAsync(ulong id, ulong roleId) { var server = await _context.Servers .FindAsync(id); if (server == null) { _context.Add(new Server { ServerId = id }); } _context.Add(new Rank { RoleId = roleId, ServerId = id }); await _context.SaveChangesAsync(); }
public async Task ModifyGuildPrefix(ulong id, string prefix) { var server = await _context.Servers .FindAsync(id); if (server == null) { _context.Add(new Server { Id = id, Prefix = prefix }); } else { server.Prefix = prefix; } await _context.SaveChangesAsync(); }