コード例 #1
0
        /// <summary>
        /// Delete Lot dataset from database, used for reset
        /// </summary>
        public async Task ClearPlantsAsync()
        {
            Lot[] lots = await m_context.Lots.ToArrayAsync();

            m_context.RemoveRange(lots);
            await m_context.SaveChangesAsync();
        }
コード例 #2
0
        public async Task <List <RegistrationForViewDto> > ClearUserData(int excelId)
        {
            var registeredEventList = await _context.Registrations.Where(r => r.ExcelId == excelId).ToListAsync();

            if (registeredEventList.Count == 0)
            {
                throw new DataInvalidException("Invalid excel ID. Please re-check the excel ID");
            }
            _context.RemoveRange(registeredEventList);
            await _context.SaveChangesAsync();

            return(registeredEventList.Select(x => _mapper.Map <RegistrationForViewDto>(x)).ToList());
        }
コード例 #3
0
        public async Task <List <BookmarkForViewDto> > RemoveAll(int excelId)
        {
            var bookmarks = await _context.Bookmarks.Where(r => r.ExcelId == excelId).ToListAsync();

            if (bookmarks.Count == 0)
            {
                throw new DataInvalidException("Invalid User ID. Please re-check the user ID");
            }
            _context.RemoveRange(bookmarks);
            await _context.SaveChangesAsync();

            return(bookmarks.Select(x => _mapper.Map <BookmarkForViewDto>(x)).ToList());
        }
コード例 #4
0
        public async Task <List <Result> > RemoveAllResults(int eventId)
        {
            try
            {
                var resultFromDb = _context.Results.Where(r => r.EventId == eventId).ToList();
                if (resultFromDb == null)
                {
                    throw new DataInvalidException("Invalid event ID");
                }
                _context.RemoveRange(resultFromDb);
                await _context.SaveChangesAsync();

                return(resultFromDb);
            }
            catch (DbUpdateException)
            {
                throw new DataInvalidException("Problem saving data. Try again");
            }
        }
コード例 #5
0
 public async Task RemoveRangeAsync(IEnumerable <Patient> patients)
 {
     _context.RemoveRange(patients);
     await _context.SaveChangesAsync();
 }