public void Delete(ProviderInsurance entity) { var data1 = (from proIns in _context.ProviderInsurances where proIns.ProviderId == entity.ProviderId && proIns.InsuranceId == entity.InsuranceId select proIns).FirstOrDefault(); if (data1 != null) { _context.ProviderInsurances.Remove(data1); } else { throw new Exception("Insurance does not exist."); } }
public void AddProviderInsurances(ProviderInsurance entity) { var data = (from proIns in _context.ProviderInsurances where proIns.ProviderId == entity.ProviderId && proIns.InsuranceId == entity.InsuranceId select proIns).FirstOrDefault(); if (data == null) { _context.ProviderInsurances.Add(entity); } else { throw new Exception("Insurance already added."); } }