private YellowstonePathology.Business.Rules.MethodResult CanDeleteClient(YellowstonePathology.Business.Client.Model.Client client) { YellowstonePathology.Business.Rules.MethodResult result = new Business.Rules.MethodResult(); int accessionCount = YellowstonePathology.Business.Gateway.PhysicianClientGateway.GetAccessionCountByClientId(client.ClientId); if (accessionCount > 0) { result.Success = false; result.Message = client.ClientName + " has accessions and can not be deleted."; } else { StringBuilder msg = new StringBuilder(); msg.AppendLine(client.ClientName); YellowstonePathology.Business.Domain.PhysicianClientCollection physicianClientCollection = YellowstonePathology.Business.Gateway.PhysicianClientGateway.GetPhysicianClientCollectionByClientId(client.ClientId); foreach (YellowstonePathology.Business.Domain.PhysicianClient physicianClient in physicianClientCollection) { YellowstonePathology.Business.Client.Model.PhysicianClientDistributionCollection physicianClientDistributionCollection = YellowstonePathology.Business.Gateway.PhysicianClientGateway.GetPhysicianClientDistributionByPhysicianClientId(physicianClient.PhysicianClientId); if (physicianClientDistributionCollection.Count > 0) { result.Success = false; msg.AppendLine("- has distributions. The distributions must be removed before the client can be deleted."); break; } } if (physicianClientCollection.Count > 0) { result.Success = false; msg.AppendLine("- has membereship. The membership must be removed before the client can be deleted."); } result.Message = msg.ToString(); } return(result); }
private YellowstonePathology.Business.Rules.MethodResult CanDeleteProvider(YellowstonePathology.Business.Domain.Physician physician) { YellowstonePathology.Business.Rules.MethodResult result = new Business.Rules.MethodResult(); int accessionCount = YellowstonePathology.Business.Gateway.PhysicianClientGateway.GetAccessionCountByPhysicianId(physician.PhysicianId); if (accessionCount > 0) { result.Success = false; result.Message = physician.DisplayName + " has accessions and can not be deleted."; } else { StringBuilder msg = new StringBuilder(); msg.AppendLine(physician.DisplayName); YellowstonePathology.Business.Domain.PhysicianClientCollection physicianClientCollection = YellowstonePathology.Business.Gateway.PhysicianClientGateway.GetPhysicianClientCollectionByProviderId(physician.ObjectId); foreach (YellowstonePathology.Business.Domain.PhysicianClient physicianClient in physicianClientCollection) { YellowstonePathology.Business.Client.Model.PhysicianClientDistributionCollection physicianClientDistributionCollection = YellowstonePathology.Business.Gateway.PhysicianClientGateway.GetPhysicianClientDistributionByPhysicianClientId(physicianClient.PhysicianClientId); if (physicianClientDistributionCollection.Count > 0) { result.Success = false; msg.AppendLine("- has existing distributions. The distributions must be removed before the provider may be deleted."); break; } } if (physicianClientCollection.Count > 0) { result.Success = false; msg.Append("- is a member of " + physicianClientCollection.Count.ToString() + " client/s. The membership must be removed before the provider may be deleted."); } result.Message = msg.ToString(); } return(result); }