public Task <OperateResultRsp> ActivateCorporation(CommonCMDReq req) { var rsp = new OperateResultRsp { OperateFlag = false, OperateResult = "参数错误" }; try { if (!string.IsNullOrEmpty(req.CommonCMD)) { var corp = _queryCorpRepository.Get(a => a.CorporationKeyId == req.Identify.CorporationKeyId).FirstOrDefault(); corp.IsDelete = false; var empId = corp.Activate(); _repository.Commit(); rsp.OperateFlag = true; rsp.OperateResult = "激活成功"; Publish(new CorporationActivatedEvent() { CorpId = req.Identify.CorporationKeyId, Email = req.CommonCMD, EmpId = empId }); } } catch (Exception ex) { string msg = ex.Message; } return(Task.FromResult(rsp)); // return rsp; }
public Task <OperateResultRsp> CreateRole(RoleEditReq req) { OperateResultRsp rsp = new OperateResultRsp(); var corporation = _repository.FindBy(req.Identify.CorporationKeyId); if (corporation != null) { if (!corporation.CorpRoles.Exists(a => a.Name == req.RoleName.Trim())) { var corpRole = new CorpRole { Name = req.RoleName, CorporationKeyId = req.Identify.CorporationKeyId, }; corpRole.SetEditer(null); corpRole.KeyId = Guid.NewGuid(); corporation.CorpRoles.Add(corpRole); _repository.Commit(); rsp.OperateFlag = true; } else { rsp.OperateFlag = false; rsp.FlagErrorMsg = "角色名字已经存在"; } } else { rsp.OperateFlag = false; rsp.FlagErrorMsg = "当前公司编号错误"; } return(Task.FromResult(rsp)); }
public Task <OperateResultRsp> CreateEmployee(EmployeeEditReq req) { OperateResultRsp rsp = new OperateResultRsp(); var corporation = _repository.FindBy(req.Identify.CorporationKeyId); if (corporation != null) { var dept = corporation.Departments.FirstOrDefault(a => a.KeyId == req.DeptKeyId); if (dept != null) { var emp = new Employee { Name = req.Name, CorporationKeyId = req.Identify.CorporationKeyId, DepartmentKeyId = req.DeptKeyId, RoleKeyId = req.RoleKeyId, RoleName = req.RoleName }; emp.SetEditer(null); emp.KeyId = Guid.NewGuid(); dept.Employees.Add(emp); _repository.Commit(); rsp.OperateFlag = true; } else { rsp.OperateFlag = false; rsp.FlagErrorMsg = "角色名字已经存在"; } } else { rsp.OperateFlag = false; rsp.FlagErrorMsg = "当前公司编号错误"; } return(Task.FromResult(rsp)); }