示例#1
0
        public void SyncWithServerForAdd([FromBody] List <string> result)
        {
            List <Book>      addBooks      = JsonSerializer.Deserialize <List <Book> >(result[0]);
            List <Author>    addAuthors    = JsonSerializer.Deserialize <List <Author> >(result[1]);
            List <Category>  addCategories = JsonSerializer.Deserialize <List <Category> >(result[2]);
            List <Publisher> addPublishers = JsonSerializer.Deserialize <List <Publisher> >(result[3]);
            List <Language>  addLanguages  = JsonSerializer.Deserialize <List <Language> >(result[4]);

            foreach (var el in addBooks)
            {
                CacheItem cacheItem = new CacheItem
                {
                    Book      = el,
                    Author    = addAuthors.FirstOrDefault(p => p.Id == el.AuthorId),
                    Category  = addCategories.FirstOrDefault(p => p.Id == el.CategoryId),
                    Publisher = addPublishers.FirstOrDefault(p => p.Id == el.PublisherId),
                    Language  = addLanguages.FirstOrDefault(p => p.Id == el.LanguageId),
                };

                _cache.AddCacheItem(cacheItem);
            }
        }