public IActionResult SetApplicationUser(Guid id) { var boVM = _boVMService.GetVM(id); var tempVM = new CreateOrEditUserWithPersonVM(); tempVM.PersonId = boVM.Id; tempVM.PersonName = boVM.Name; tempVM.UserId = boVM.UserId; tempVM.UserName = boVM.UserName; tempVM.SaveStatus = "OK"; if (String.IsNullOrEmpty(tempVM.UserName)) { tempVM.UserName = boVM.Name; } ViewData["ModuleName"] = "组织与人员管理"; ViewData["FunctionName"] = "设置用户"; return(PartialView("_SetApplicationUser", tempVM)); }
/// <summary> /// 将员工设置为系统用户 /// </summary> /// <param name="id"></param> /// <returns></returns> public IActionResult SetApplicationUser(Guid id) { var boVM = _boVMService.GetVM(id); // 临时模型,用来在用户数据和员工数据之间作为转换使用 var tempVM = new CreateOrEditUserWithPersonVM(); tempVM.PersonId = boVM.Id; tempVM.PersonName = boVM.Name; tempVM.UserId = boVM.UserId; tempVM.UserName = boVM.UserName; tempVM.SaveStatus = "OK"; if (String.IsNullOrEmpty(tempVM.UserName)) { tempVM.UserName = boVM.EmployeeCode; // 缺省使用员工工号作为创建的员工用户的登录名 } ViewData["ModuleName"] = "组织与人员管理"; ViewData["FunctionName"] = "设置用户"; return(PartialView("_SetApplicationUser", tempVM)); }
public async Task <IActionResult> SetApplicationUser(CreateOrEditUserWithPersonVM tempVM) { if (ModelState.IsValid) { var saveResult = await _boVMService.CreateOrEditRelevaneceUser(tempVM.PersonId, tempVM.UserName); if (saveResult.Succeeded) { tempVM.SaveStatus = "OK"; var user = saveResult.BusinessObject as ApplicationUser; tempVM.UserId = user.Id; tempVM.UserName = user.UserName; } else { tempVM.SaveStatus = "Failed"; } } ViewData["ModuleName"] = "组织与人员管理"; ViewData["FunctionName"] = "设置用户"; return(PartialView("_SetApplicationUser", tempVM)); }