public ActionResult Confirm(ResearchPlanUserInfo info) { ResearchPlanUserInfo infoExist = ResearchPlanUserBLL.GetList(p => p.ID == info.ID).FirstOrDefault(); infoExist.IsConfirmed = true; infoExist.DateConfirm = DateTime.Now; if (ResearchPlanUserBLL.Edit(infoExist)) { return(Json(new APIJson(0, "提交成功"))); } return(Json(new APIJson(-1, "提交失败,请重试"))); }
public ActionResult SelectUser(int UserID, bool IsAdd, int ResearchPlanID) { var info = ResearchPlanBLL.GetList(a => a.ID == ResearchPlanID).FirstOrDefault(); var infoUser = UserBLL.GetList(a => a.ID == UserID).FirstOrDefault(); var infoPlanUserExist = info.ResearchPlanUserInfo.FirstOrDefault(a => a.UserID == UserID); var result = true; if (null == infoUser) { return(Json(new APIJson(-1, "用户不存在"))); } if (!IsAdd) { if (null != infoPlanUserExist) { result = ResearchPlanUserBLL.Delete(infoPlanUserExist); } } else { if (null == infoPlanUserExist) { infoPlanUserExist = new ResearchPlanUserInfo(); infoPlanUserExist.ResearchPlanID = info.ID; infoPlanUserExist.UserID = UserID; infoPlanUserExist.DateCreate = DateTime.Now; infoPlanUserExist.DateConfirm = DicInfo.DateZone; infoPlanUserExist.IsConfirmed = false; infoPlanUserExist.Memo = string.Empty; infoPlanUserExist.SumRemark = string.Empty; info.ResearchPlanUserInfo.Add(infoPlanUserExist); result = ResearchPlanBLL.Edit(info); new WeiXin.APIClient.WechatService.TemplateMsg().ResponseTemplateMsg(infoPlanUserExist, infoUser.WechatOpenID); } } if (result) { var SelectedUserJSON = info.ResearchPlanUserInfo.ToList().Select(u => new { u.ID, u.UserID, Name = u.UserInfo.Name, u.IsConfirmed, subjectName = string.Join(",", u.UserInfo.SubjectInfo.Select(s => s.Name)), DepartmentName = u.UserInfo.DepartmentInfo.Name }); return(Json(new APIJson(0, "处理成功", SelectedUserJSON))); } return(Json(new APIJson(-1, "处理失败,请重试"))); }
public ActionResult Join(UserInfo info) { string log = string.Empty; try { int PlanID = Function.GetRequestInt("PlanID"); log += "\n PlanID=" + PlanID; string infoWechatUserReturnOpenID = Function.GetRequestString("infoWechatUserReturnOpenID"); log += "\n infoWechatUserReturnOpenID=" + infoWechatUserReturnOpenID; ResearchPlanInfo infoPlan = ResearchPlanBLL.GetList(p => p.ID == PlanID).FirstOrDefault(); log += "\n infoPlan=" + infoPlan; UserInfo infoUser = null; if (info.ID > 0) { log += "\n info.ID > 0="; infoUser = UserBLL.GetList(a => a.ID == info.ID).FirstOrDefault(); } if (null == infoUser) { log += "\n info.ID < 0="; infoUser = UserBLL.GetList(a => a.WechatOpenID == infoWechatUserReturnOpenID).FirstOrDefault(); } log += "\n infoUser="******"\n infoUser is null"; WechatUserReturnInfo infoWechatUserReturn = WeiXin.APIClient.WechatService.WechatUser.GetWechatUserReturnInfo(infoWechatUserReturnOpenID); if (null == infoWechatUserReturn) { return(Json(new APIJson(-1, "无法获取用户信息"))); } log += "\n infoWechatUserReturn=" + infoWechatUserReturn; infoUser = new UserInfo(); //infoUser.DepartmentID 从config中读到表单hiden了里 //infoUser.Name if (string.IsNullOrEmpty(info.Name) || info.Name.Length > 50) { return(Json(new APIJson(-1, "请输入您的姓名"))); } if (UserBLL.GetList(a => true).Any(a => a.Name == infoUser.Name)) { return(Json(new APIJson(-1, "系统里居然有人跟你同名了,你换一个或加个数字后缀吧"))); } var infoUserExistName = UserBLL.GetList(a => a.Name == info.Name).FirstOrDefault(); if (null != infoUserExistName) { return(Json(new APIJson(-1, "系统已存在当前用户名,请更换"))); } infoUser.DepartmentID = info.DepartmentID; infoUser.Name = info.Name; infoUser.Code = infoUser.Name; infoUser.PassWord = string.Empty; //infoUser.Email if (null == infoUser.Email) { infoUser.Email = string.Empty; } infoUser.Email = info.Email; infoUser.Tel = string.Empty; infoUser.CreateDate = DateTime.Now; infoUser.LastDate = DateTime.Now; infoUser.Enable = true; infoUser.LocationX = infoUser.LocationY = 0; infoUser.WechatOpenID = infoWechatUserReturn.openid; infoUser.WechatNameNick = infoWechatUserReturn.nickname; infoUser.WechatHeadImg = infoWechatUserReturn.headimgurl; infoUser.Sex = infoWechatUserReturn.sex.ToString(); infoUser.IDCard = string.Empty; infoUser.TypeID = -1; infoUser.DefaultSubjectID = 0; log += "\n 准备完后infoUser="******"\n 创建完了"; } ResearchPlanUserInfo infoPlanUser = new ResearchPlanUserInfo(); infoPlanUser.ResearchPlanID = info.ID; infoPlanUser.UserID = infoUser.ID; infoPlanUser.DateCreate = DateTime.Now; infoPlanUser.DateConfirm = DicInfo.DateZone; infoPlanUser.IsConfirmed = true; infoPlanUser.Memo = "二维码邀请"; infoPlanUser.SumRemark = string.Empty; infoPlan.ResearchPlanUserInfo.Add(infoPlanUser); var result = ResearchPlanBLL.Edit(infoPlan); if (result) { return(Json(new APIJson(0, "恭喜您,成功加入本次听评课计划"))); } else { return(Json(new APIJson(-1, "加入失败了,请重试"))); } } catch (Exception ex) { var ex2 = (System.Data.Entity.Infrastructure.DbUpdateException)ex; var ErrorMsg = log + "Ex========" + ex.Message + "\n ex2.InnerException.ObjectToJSON();" + ex2.InnerException.ObjectToJSON(); return(Json(new APIJson(-1, ErrorMsg))); throw; } }