public ActionResult SelectUser(int UserID, bool IsAdd, int MemberGroupID) { var info = MemberGroupBLL.GetList(a => a.ID == MemberGroupID).FirstOrDefault(); var infoUser = info.UserInfo.FirstOrDefault(a => a.ID == UserID); var result = true; if (!IsAdd) { if (null != infoUser) { info.UserInfo.Remove(infoUser); result = true; } } else { if (null == infoUser) { infoUser = UserBLL.GetList(a => a.ID == UserID).FirstOrDefault(); if (null == infoUser) { result = false; } else { info.UserInfo.Add(infoUser); result = true; } } } if (result) { result = MemberGroupBLL.Edit(info); } if (result) { var SelectedUserJSON = info.UserInfo.ToList().Select(u => new { u.ID, u.Name, subjectName = string.Join(",", u.SubjectInfo.Select(s => s.Name)) }); return(Json(new APIJson(0, "处理成功", SelectedUserJSON))); } return(Json(new APIJson(-1, "处理失败,请重试"))); }
public ActionResult Edit(MemberGroupInfo info) { MemberGroupInfo infoExist = MemberGroupBLL.GetList(p => p.ID == info.ID).FirstOrDefault(); if (string.IsNullOrEmpty(info.Name)) { return(Json("请填写名称")); } if (string.IsNullOrEmpty(info.Description)) { info.Description = string.Empty; } infoExist.Name = info.Name; infoExist.Description = info.Description; infoExist.SortID = info.SortID; infoExist.Enable = info.Enable; if (MemberGroupBLL.Edit(infoExist)) { return(Json(new APIJson(0, "提交成功"))); } return(Json(new APIJson(-1, "提交失败,请重试"))); }