Example #1
0
        public async Task <IActionResult> GetList(int id)
        {
            var list = await _listsRepository.Get(id);

            Validator.Assert(list != null, ValidationAreas.NotExists);

            return(Ok(list));
        }
        public async Task <IActionResult> GetListWithItems([FromRoute] int listId)
        {
            var existingList = await _listsRepository.Get(listId);

            Validator.Assert(existingList != null, ValidationAreas.NotExists);

            var listWithItems = await _itemsInListCacheManager.GetList(listId);

            if (listWithItems == null)
            {
                var result = await _itemsListRelationsRepository.GetListWithItems(listId);

                listWithItems = await _itemsInListCacheManager.AddList(existingList);

                if (result != null)
                {
                    foreach (var res in result.ItemList.ItemListRelations)
                    {
                        listWithItems.Items.Add(new CachedItem(res.Item, res.IsActive));
                    }

                    await _itemsInListCacheManager.AddList(listWithItems);
                }
            }
            return(Ok(listWithItems));
        }