예제 #1
0
        public async Task <IActionResult> GetGuildBankItems([FromBody] GetGuildByIdModel model)
        {
            var context = _contextService.GetCharacterContext(model.RealmType);

            var guild = await context.Guilds.FirstOrDefaultAsync(x => x.Id == model.GuildId);

            if (guild == null)
            {
                return(RequestHandler.BadRequest($"No Guild with id {model.GuildId} exists"));
            }

            var guildBankItems = await context.GuildBankItems
                                 .Where(x => x.GuildId == guild.Id)
                                 .Join(context.ItemInstance, gItem => gItem.ItemGuid, item => item.Guid, (gItem, item) => new { gItem, item })
                                 .Select(x => new InventoryModel
            {
                ItemEntry = x.item.ItemEntry,
                ItemGuid  = x.item.Guid,
                ItemCount = x.item.Count,
                Slot      = x.gItem.TabId
            }).ToListAsync();

            var mappedInventory = await _itemMapperService.MapInventory(model.RealmType, guildBankItems);

            return(Ok(mappedInventory));
        }
예제 #2
0
        public async Task <IActionResult> GetGuildEventLogs([FromBody] GetGuildByIdModel model)
        {
            var context = _contextService.GetCharacterContext(model.RealmType);

            var guild = await context.Guilds.FirstOrDefaultAsync(x => x.Id == model.GuildId);

            if (guild == null)
            {
                return(RequestHandler.BadRequest($"No Guild with id {model.GuildId} exists"));
            }

            var guildEventLogs = await(
                from logs in context.GuildEventLogs
                where logs.GuildId == model.GuildId
                join player1 in context.Characters on logs.PlayerGuid1 equals player1.Id into joinTable1
                from player1 in joinTable1.DefaultIfEmpty()
                join player2 in context.Characters on logs.PlayerGuid2 equals player2.Id into joinTable2
                from player2 in joinTable2.DefaultIfEmpty()
                select new GuildEventLog
            {
                GuildId     = model.GuildId,
                EventType   = logs.EventType,
                TimeStamp   = logs.TimeStamp,
                LogGuid     = logs.LogGuid,
                NewRank     = logs.NewRank,
                PlayerGuid1 = logs.PlayerGuid1,
                PlayerGuid2 = logs.PlayerGuid2,
                PlayerName1 = player1.Name,
                PlayerName2 = player2.Name
            }).ToListAsync();

            return(Ok(guildEventLogs));
        }
예제 #3
0
        public async Task <IActionResult> GetGuildById([FromBody] GetGuildByIdModel model)
        {
            var context = _contextService.GetCharacterContext(model.RealmType);

            var guild = await context.Guilds.FirstOrDefaultAsync(x => x.Id == model.GuildId);

            if (guild == null)
            {
                return(RequestHandler.BadRequest($"No Guild with id {model.GuildId} exists"));
            }

            return(Ok(guild));
        }