public async Task <IActionResult> DeleteOffer(Guid Id) { ICollection <Offers> offers; ICollection <EstimateConnects> Connect; using (var context = new DataBaseContext()) { offers = context.Offer .Include(offermodel => offermodel.Estimate) .Include(user => user.CreatedBy) .Include(user => user.UpdatedBy) .ToList(); Connect = context.EstimateConnects .Include(line => line.EstimateLines) .ToList(); } var offer = offers.FirstOrDefault(x => x.Id.Equals(Id)); var lines = Connect.Where(x => x.Estimate.Id == offer.Estimate.Id).ToList(); foreach (var item in lines) { await EstimateConnectsRepository.RemoveAsync(item.Id); } await OfferRepository.RemoveAsync(Id); await EstimateRepository.RemoveAsync(offer.Estimate.Id); return(Redirect("../")); }