public async Task<List<Purchase>> GetAll(BuyStatus buyStatus = BuyStatus.AwaitingPayment) { return await _context.Purchases .Include(x=>x.Book.Autor) .Where(x => x.BuyStatus == buyStatus) .OrderBy(x=>x.Book.Title) .ToListAsync(); }
public async Task <IActionResult> Delete(BuyStatus buyStatus = BuyStatus.AwaitingPayment) { await purchasesService.Delete(buyStatus); return(RedirectToAction(buyStatus == BuyStatus.Bought ? nameof(Index) : nameof(RefundedIndex))); }
public async Task Delete(BuyStatus buyStatus) { var purchases = await GetAll(buyStatus); _context.Purchases.RemoveRange(purchases); await _context.SaveChangesAsync(); }