Пример #1
0
        public async Task RemoveInterest(Guid id, bool confirm = false)
        {
            var model = await _context.ClamProjectInterestsImageDisplays.FindAsync(id);

            var result = FilePathUrlHelper.DataFilePathFilterIndex(model.ImageLocation, 4);
            var path   = model.ImageLocation.Substring(0, result);

            Directory.Delete(path, true);
            if (confirm == true)
            {
                _context.Remove(model);
                await _context.SaveChangesAsync();
            }
        }
Пример #2
0
        public async Task UpdateAllMusicTrackGenreSelection(Guid id, List <MusicGenreSelection> model)
        {
            var category = await _context.ClamUserMusicCategories.FindAsync(id);

            var queryTable = await _context.ClamUserMusicJoinCategories.AsNoTracking().ToListAsync();

            List <ClamUserMusicJoinCategory> joinTables = new List <ClamUserMusicJoinCategory>();

            foreach (var item in model)
            {
                if (item.IsSelected == true && (queryTable.Any(val => val.CategoryId == category.CategoryId && val.SongId == item.SongId)))
                {
                    continue;
                }
                if (item.IsSelected == true && !(queryTable.Any(val => val.CategoryId == category.CategoryId && val.SongId == item.SongId)))
                {
                    joinTables.Add(new ClamUserMusicJoinCategory()
                    {
                        CategoryId = category.CategoryId,
                        SongId     = item.SongId
                    });
                }
                if (item.IsSelected == false && (queryTable.Any(val => val.CategoryId == category.CategoryId && val.SongId == item.SongId)))
                {
                    _context.Remove(new ClamUserMusicJoinCategory()
                    {
                        SongId = item.SongId, CategoryId = category.CategoryId
                    });
                }
            }
            await _context.AddRangeAsync(joinTables);

            await _context.SaveChangesAsync();
        }
Пример #3
0
        public async Task RemoveTicket(Guid id)
        {
            var model = await _context.ClamUserSystemTickets.FindAsync(id);

            _context.Remove(model);
            await _context.SaveChangesAsync();
        }