private void SaveEditModel(ProjectEditModel model) { var project = model.Project; projectRepo.Save(project); var oldProjectMembers = projectMemberRepo.GetForProject(project.Id); foreach (var oldMember in oldProjectMembers) { if (model.ProjectMembers.All(p => p.Id != oldMember.Id)) { projectMemberRepo.Delete(oldMember); } } foreach (var newMember in model.ProjectMembers.Where(pm => pm.EmployeeId > 0)) { projectMemberRepo.Save(newMember); } }