Exemple #1
0
        public async Task <bool> UpdateAsync(Card item)
        {
            var stored = await _context.Cards.FirstOrDefaultAsync(c => c.Id == item.Id);

            if (stored == null)
            {
                return(false);
            }

            _context.Entry(stored).State = EntityState.Detached;

            //TODO: Card vs CardData? Restore Card's references (Image, Sound) while updating from CardData
            if (item.ImageName == null && item.SoundName == null)
            {
                item.ImageName = stored.ImageName;
                item.SoundName = stored.SoundName;
            }

            await item.StoreExtFilesAsync(_fileRepository);

            _context.Cards.Update(item);
            await _context.SaveChangesAsync();

            return(true);
        }