示例#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> GetCharacterInventory([FromBody] SelectCharacterByGuidModel model)
        {
            var characterContext = _contextService.GetCharacterContext(model.RealmType);

            var inventory = await characterContext.CharacterInventory
                            .Where(x => x.Guid == model.Guid && x.Slot < (int)EquipmentSlots.EQUIPMENT_SLOT_END && x.Bag == 0)
                            .Join(characterContext.ItemInstance, ci => ci.Item, i => i.Guid, (ci, i) => new { ci, i })
                            .Select(x => new InventoryModel
            {
                Slot      = x.ci.Slot,
                ItemEntry = x.i.ItemEntry,
                ItemGuid  = x.i.Guid
            }).OrderBy(o => o.Slot).ToListAsync();

            var mappedInventory = model.RealmType == RealmType.TitansLeague ?
                                  await _itemMapperService.MapCustomInventory(model.RealmType, inventory, model.Guid) :
                                  await _itemMapperService.MapInventory(model.RealmType, inventory);

            return(Ok(mappedInventory));
        }