public IActionResult LoginManage_Edit(string op, CHIS.Models.CHIS_Sys_Login model, long recId) { string editViewName = nameof(LoginManage_Edit); // var sysUser = base.GetCurrentUserInfo(); ViewBag.OP = op;// 初始化操作类别 switch (op.ToUpper()) { case "NEWF": //新增页面 空白的数据页面 var modelnew = new Models.CHIS_Sys_Login() { }; ViewBag.OP = "NEW"; return(View(editViewName, modelnew)); case "NEW": // 更新新增的数据 try { _db.Add(model); _db.SaveChanges(); return(Json(new { state = "success" })); } catch (Exception ex) { return(Json(new { state = "error", msg = ex.Message })); } case "MODIFYF": //修改 查找出修改的原始实体数据 var modelmodify = _db.CHIS_Sys_Login.Find(recId); ViewBag.OP = "MODIFY"; return(View(editViewName, modelmodify)); case "MODIFY": //修改后的数据 try { _db.Attach(model).State = EntityState.Modified; //设置不更新的部分 if (string.IsNullOrWhiteSpace(model.LoginPassword)) { _db.Entry(model).Property(m => m.LoginPassword).IsModified = false; //不更新此字段 } _db.SaveChanges(); return(Json(new { state = "success" })); } catch (Exception ex) { return(Json(new { state = "error", msg = "修改失败" + ex.Message })); } case "DELETE": //删除,返回json var del = _db.CHIS_Sys_Login.Find(recId); _db.Remove(del); var rlt = _db.SaveChanges() > 0; return(Json(rlt)); case "VIEW": return(View(editViewName, _db.CHIS_Sys_Login.Find(recId))); default: throw new Exception("错误的命令"); } }
/// <summary> /// 注册医生基本信息 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool RegistDoctorBasic(CHIS.Models.ViewModel.CustomerRegistViewModel model) { if (model.RegistType == "mobile") { var find = _db.CHIS_DataTemp_SMS.AsNoTracking().Where(m => m.PhoneCode == model.Mobile && m.VCodeProp == null && m.CreatTime > DateTime.Today).OrderByDescending(m => m.CreatTime).FirstOrDefault(); if (find == null) { throw new Exception("没有找到短信验证码"); } if (!string.Equals(find.VCode, model.VCode, StringComparison.CurrentCultureIgnoreCase)) { throw new Exception("验证码输入错误"); } } if (model.RegistType == "email") { var find = _db.CHIS_DataTemp_SendMailVCode.AsNoTracking().Where(m => m.EmailAddress == model.Email && m.VCodeProp == null && m.CreatTime > DateTime.Today).OrderByDescending(m => m.CreatTime).FirstOrDefault(); if (find == null) { throw new Exception("没有找到邮件的验证码"); } if (!string.Equals(find.VCode, model.VCode, StringComparison.CurrentCultureIgnoreCase)) { throw new Exception("验证码输入错误"); } } if (model.RegPaswd != model.RegPaswdConfirm) { throw new Exception("注册密码与确认密码不一致"); } if (model.RegistRole != "doctor") { throw new Exception("注册非医生"); } _db.BeginTransaction(); try { //----获取或者添加会员信息------- Models.CHIS_Code_Customer cus = null; if (model.RegistType == "mobile") { cus = _db.CHIS_Code_Customer.FirstOrDefault(m => m.CustomerMobile == model.Mobile); } if (model.RegistType == "email") { cus = _db.CHIS_Code_Customer.FirstOrDefault(m => m.Email == model.Email); } if (cus == null) { var newcus = new Models.CHIS_Code_Customer { Email = model.Email, CustomerMobile = model.Mobile, CustomerCreateDate = DateTime.Now, //创建时间 sysLatestActiveTime = DateTime.Now, sysSource = sysSources.医生注册.ToString() }; newcus.NickName = newcus.CustomerName = "用户" + DateTime.Now.ToString("yyMMddHHmmssfff"); cus = _db.Add(newcus).Entity; _db.SaveChanges(); } //----获取医生信息 ----------- Models.CHIS_Code_Doctor doc = null; doc = _db.CHIS_Code_Doctor.FirstOrDefault(m => m.CustomerId == cus.CustomerID); if (doc == null) { var docEntry = _db.Add(new Models.CHIS_Code_Doctor { CustomerId = cus.CustomerID, DoctorCreateTime = DateTime.Now, IsEnable = true }); _db.SaveChanges(); doc = docEntry.Entity; } //--------------增加医生与工作站默认基本联系 网上平台测试站------------- new CHIS.Api.syshis(controller._db).UpsertDoctorStationRoles(doc.DoctorId, 6, new List <int> { 12 }); var login = new Models.CHIS_Sys_Login { CustomerId = cus.CustomerID, DoctorId = doc.DoctorId, Email = model.Email, Mobile = model.Mobile, LoginPassword = model.RegPaswd, IsLock = false }; if (model.RegistType == "email") { login.EmailIsAuthenticated = true; login.EmailAuthenticatedTime = DateTime.Now; } if (model.RegistType == "mobile") { login.MobileIsAuthenticated = true; login.MobileAuthenticatedTime = DateTime.Now; } var addEntry = _db.CHIS_Sys_Login.Add(login); _db.SaveChanges(); // tx.Rollback(); _db.CommitTran(); return(true); } catch (Exception ex) { _db.RollbackTran(); throw ex; } // return false; }