예제 #1
0
        public async Task <long> CreateAsync(Class user)
        {
            var savedClass = _context.Classes.Add(user);
            await _context.SaveChangesAsync();

            return(savedClass.Entity.Id);
        }
예제 #2
0
        public async Task <long> CreateAsync(ItemAction action)
        {
            var savedAction = _context.ItemActions.Add(action);
            await _context.SaveChangesAsync();

            return(savedAction.Entity.Id);
        }
        public async Task <long> CreateAsync(Item item)
        {
            var savedItem = _context.Items.Add(item);
            await _context.SaveChangesAsync();

            return(savedItem.Entity.Id);
        }
예제 #4
0
        public async Task <long> CreateAsync(Race user)
        {
            var savedRace = _context.Races.Add(user);
            await _context.SaveChangesAsync();

            return(savedRace.Entity.Id);
        }
예제 #5
0
        public async Task <long> CreateAsync(PlayerCharacter pc)
        {
            var addedPC = _context.PlayerCharacters.Add(pc);

            await _context.SaveChangesAsync();

            return(addedPC.Entity.Id);
        }
        public async Task AddCharacterToUserAsync(long userId, PlayerCharacter pc)
        {
            var user = await _context.Users.FindAsync(userId);

            if (user != null)
            {
                if (user.Characters != null)
                {
                    user.Characters.Add(pc);
                }
                else
                {
                    user.Characters = new[] { pc };
                }

                await SetActiveCharacterAsync(userId, pc.Id);

                await _context.SaveChangesAsync();
            }
            else
            {
                throw new Exception("User not found when adding character to user!");
            }
        }