public ActionResult GetFormJson(string keyValue) { try { var data = roleApp.FindEntity(keyValue); WirteOperationRecord("Role", "SELECT", "查询", "Info:获取角色(单个)"); return(Content(data.ToJson())); } catch (Exception ex) { log.logLevel = "ERROR"; log.logType = "ERROR"; WirteOperationRecord("Role", "", "", "Info:" + "Info:" + ex.Message.ToString()); return(Error(ex.Message)); } }
public ActionResult SubmitForm(AccountEntity entity, string keyValue) { try { accountApp.SubmitForm(entity, keyValue); if (string.IsNullOrEmpty(keyValue)) { //插入用户角色 string roleName = "学生"; if (entity.accountType == 1) { roleName = "管理员"; } else if (entity.accountType == 2) { roleName = "讲师"; } var roleEntity = roleApp.FindEntity(c => c.roleName.Contains(roleName)); var accountRole = new AccountRoleEntity() { roleInfoGuid = roleEntity.roleGuid, accountInfoGuid = entity.accountGuid }; accountRoleApp.SubmitForm(accountRole, ""); } if (string.IsNullOrEmpty(keyValue)) { WirteOperationRecord("Account", "INSERT", "增加", "Info:" + entity.ToJson()); } else { WirteOperationRecord("Account", "UPDATE", "修改", "Info:" + entity.ToJson()); } } catch (Exception ex) { log.logType = "ERROR"; log.logLevel = "ERROR"; WirteOperationRecord("Account", "", "", "Info:" + ex.Message.ToString()); return(Error(ex.Message.ToString())); } return(Success("操作成功.")); }
public void SubmitForm(TeamMembersEntity entity, string keyValue) { if (string.IsNullOrEmpty(entity.membersGuid)) { var count = FindList(c => c.isEnabled && c.teamInfoGuid == keyValue).Count(); if (count >= 5) { throw new Exception("每个团队中团队成员不能超过4个!!!"); } var account = entity.membersName.Split('&'); entity.Create(); entity.accountInfoGuid = account[0]; entity.membersName = account[1]; entity.teamInfoGuid = keyValue; entity.membersFunction = "组员"; teamMembersRepository.Insert(entity); } else { var lenderEntity = FindList(c => c.isEnabled && c.membersFunction == "组长" && c.teamInfoGuid == keyValue).FirstOrDefault(); var roleEntity = roleApp.FindEntity(c => c.isEnabled && c.roleName.Contains("组长")); entity.membersFunction = "组长"; //该团队对没有组长 if (lenderEntity == null) { var menbersGuid = entity.membersGuid; entity.Modify(menbersGuid); entity.teamInfoGuid = keyValue; var accountRoleEntity = new AccountRoleEntity() { accountInfoGuid = entity.accountInfoGuid, roleInfoGuid = roleEntity.roleGuid }; accountRoleEntity.Create(); accountRoleApp.SubmitForm(accountRoleEntity, ""); teamMembersRepository.Update(entity); } //该团队对有组长 if (lenderEntity != null && !lenderEntity.membersGuid.Equals(entity.membersGuid)) { var accountRoleEntityList = accountRoleApp.FindList(lenderEntity.accountInfoGuid); var accountRoleEntity = accountRoleEntityList.Where(c => c.roleInfoGuid == roleEntity.roleGuid).FirstOrDefault(); accountRoleEntity.accountInfoGuid = entity.accountInfoGuid; accountRoleApp.SubmitForm(accountRoleEntity, accountRoleEntity.accountRoleGuid); lenderEntity.membersFunction = "组员"; lenderEntity.Modify(lenderEntity.membersGuid); entity.Modify(entity.membersGuid); using (var db = teamMembersRepository.BeginTrans()) { db.Update(lenderEntity); db.Update(entity); db.Commit(); } } } }