Esempio n. 1
0
        public Task <OperatingStatus> DeleteRequest(RequestModel request)
        {
            if (request.BookRequests.Count > 0)
            {
                _context.RemoveRange(request.BookRequests.ToList());
            }

            return(DeleteAsync(request));
        }
Esempio n. 2
0
        //Raderar Medlem och alla tillhörande lån
        public void DeleteMemberAndConnectedItems(int id)
        {
            var loans = _context.Loans.Where(y => y.MemberID == id);

            //List<Loan> deletedLoans = new List<Loan>();
            foreach (var loan in loans)
            {
                _context.RemoveRange(loan);
            }
            var member = _context.Members.FirstOrDefault(x => x.ID == id);

            _context.Members.Remove(member);
            _context.SaveChanges();
        }
Esempio n. 3
0
        //Tar bort vald bok och alla lån knutna till vald bok
        public void RemoveBookAndLoans(int id)
        {
            var         books        = _context.Books.Where(y => y.ID == id);
            List <Loan> deletedLoans = new List <Loan>();

            foreach (var book in books)
            {
                deletedLoans.Add(_context.Loans.FirstOrDefault(x => x.BookID == book.ID));
            }

            if (_context.Loans.Any())
            {
                _context.RemoveRange(deletedLoans);
            }
            Delete(id);
            _context.SaveChangesAsync();
        }
Esempio n. 4
0
        //Raderar Författare och alla object tillhörande författare
        public void DeleteAuthorAndConnectedItems(int id)
        {
            var         books        = _context.Books.Where(y => y.AuthorID == id);
            List <Loan> deletedLoans = new List <Loan>();

            foreach (var book in books)
            {
                var loans = _context.Loans.Where(x => x.BookID == book.ID);
                if (loans != null)
                {
                    deletedLoans.AddRange(loans);
                }
            }
            if (deletedLoans.Any())
            {
                _context.RemoveRange(deletedLoans);
            }
            var author = _context.Authors.FirstOrDefault(x => x.ID == id);

            _context.Authors.Remove(author);
            _context.SaveChanges();
        }
 public async Task DeleteManyAsync(List <Order> orders)
 {
     _context.RemoveRange(orders);
     await _context.SaveChangesAsync();
 }
 public void DeleteAuthors(IEnumerable <Author> authors)
 {
     _context.RemoveRange(authors);
 }