public void AllocateTeamMember(Entities.TeamMember teamMember) { IList <EntityViews.TeamMember> teamMembers = ListTeamMembers(teamMember.PatientId); foreach (var item in teamMember.UserIds) { if (item != Guid.Empty) { if (teamMembers.Count(x => x.Id == item && !x.DeallocationDate.HasValue) == 0) { _patientRepository.AllocateTeamMember(teamMember.PatientId, item, teamMember.FacilityId); } } } }