/// <summary> /// 根据成员的ID实现项目成员的增删 /// </summary> /// <param name="request"></param> /// <param name="database"></param> /// <param name="project"></param> /// <param name="projectMemberIDs"></param> public static void SaveComOpeProjectMembers(this HttpRequest request, IDatabase database, Project project, string projectMemberIDs) { var memberID = projectMemberIDs.Split(','); var projectMembers = database.ProjectMembers.Where(d => d.ProjectID == project.ID); foreach (var item in projectMembers) { item.Delete(database); } foreach (var item in memberID) { if (item != string.Empty) { var intItem = Convert.ToInt32(item); var user = database.Users.SingleOrDefault(d => d.ID == intItem); var expert = database.Experts.SingleOrDefault(d => d.UserID == user.ID); var projectMember = new ProjectMember(); projectMember.Member = user; projectMember.Project = project; projectMember.College = expert.College; projectMember.Save(database); } } /*if (projectMemberIDs.Split(',').Count() > 0) { //存项目成员 for (var j = 0; j < projectMemberIDs.Split(',').Count() - 1; j++) { var projectMember = new ProjectMember(); projectMember.Project = project; var mId = projectMemberIDs.Split(',')[j]; int idm = Convert.ToInt32(mId); var member = database.Users.GetByID(idm);//应该是Expert? var ifProjectMember = database.ProjectMembers.SingleOrDefault(pm => pm.Project == project && pm.Member == member); if (ifProjectMember == null) { projectMember.Member = member; projectMember.Save(database); } } }*/ }
/// <summary> /// 根据成员的ID存储项目成员 /// </summary> /// <param name="request"></param> /// <param name="database"></param> /// <param name="project"></param> /// <param name="projectMemberIDs"></param> public static void SaveProjectMembers(this HttpRequest request, IDatabase database, Project project, string projectMemberIDs) { if (projectMemberIDs.Split(',').Count() > 0) { //存项目成员 for (var j = 0; j < projectMemberIDs.Split(',').Count() - 1; j++) { var projectMember = new ProjectMember(); projectMember.Project = project; var mId = projectMemberIDs.Split(',')[j]; int idm = Convert.ToInt32(mId); var member = database.Users.GetByID(idm);//应该是Expert? var ifProjectMember = database.ProjectMembers.SingleOrDefault(pm => pm.Project == project && pm.Member == member); if (ifProjectMember == null) { projectMember.Member = member; projectMember.Save(database); } } } }