/// <summary> /// 添加团队申请人表 /// </summary> /// <param name="teamapplicant"></param> /// <returns></returns> public Model.teamapplicant AddTeamapplicant(Model.teamapplicant teamapplicant) { return(TeamAppliCantService.AddEntity(teamapplicant)); }
/// <summary> /// 删除团队申请人表 /// </summary> /// <param name="teamapplicant"></param> /// <returns></returns> public bool DeleteTeamapplicant(Model.teamapplicant teamapplicant) { teamapplicant.IsDel = true; return(TeamAppliCantService.EditEntity(teamapplicant)); }
public ActionResult TeamApplyaction(string teamPlayers) { string TeamPlayer = teamPlayers; //团队队员iUserID,需分割提取 string TeamName = Request["teamName"]; //团队名称 string TeamType = Request["teamType"]; //团队类型 string TeamTeacherName = Request["teamTeacherName"]; //团队指导老师姓名,需找到老师信息 string TeamCaptainID = Request["teamCaptainID"]; //团队队长iUserID string TeamCaptainInfo = Request["teamCaptainInfo"]; //团队队长简介 string TeamExpectResult = Request["teamExpectResult"]; //团队预期成果 string TeamActivityPlan = Request["teamActivityPlan"]; //团队活动计划 string TeamProSituation = Request["teamProSituation"]; //团队项目情况 #region 获取教师:teacherInfo 获取队长:teamCaptainInfo //获取教师 var teacherInfo = TeamService.GetTeacherByName(TeamTeacherName); //通过姓名获取教师信息 if (teacherInfo == null && teacherInfo.ID == 0) { return(Content("{\"status\":\"no\",\"result\":\"该姓名的教师信息未查询到\"}")); } //获取队长try Model.personalinformation teamCaptainInfo = new Model.personalinformation(); try { teamCaptainInfo = TeamService.GetPerson(Convert.ToInt32(TeamCaptainID)); if (teamCaptainInfo != null && teamCaptainInfo.ID != 0) { //获取队长成功 } else { return(Content("{\"status\":\"no\",\"result\":\"队长信息未查询到\"}")); } } catch (Exception) { return(Content("{\"status\":\"no\",\"result\":\"获取队长信息出错\"}")); } #endregion #region 获取队员 playerPersonList //获取队员 string[] teamplayerArry = TeamPlayer.Split(','); List <int?> TeamplayerIuseridList = new List <int?>(); List <Model.personalinformation> playerPersonList = new List <Model.personalinformation>(); foreach (var item in teamplayerArry) { try { TeamplayerIuseridList.Add(Convert.ToInt32(item)); } catch (Exception) { return(Content("{\"status\":\"no\",\"result\":\"队员信息中存在错误\"}")); } } playerPersonList = TeamService.GetPerson(TeamplayerIuseridList); //如果学生iUserID中有重复的,查询结果将会忽略重复内容 if (playerPersonList.Count == teamplayerArry.Length) { //创建队员表 } else { return(Content("{\"status\":\"no\",\"result\":\"提交的队员信息部分未查询到\"}")); } #endregion #region 创建团队申请表 teamapplication Model.teamapplication teamapplicationInfo = new Model.teamapplication(); teamapplicationInfo.dApplyTime = DateTime.Now; teamapplicationInfo.vcTeamType = TeamType; teamapplicationInfo.iApplyNumber = TeamplayerIuseridList.Count + 1; teamapplicationInfo.bApplyState = false; teamapplicationInfo.vcTeamExpectResult = TeamExpectResult; teamapplicationInfo.vcTeamActivityPlan = TeamActivityPlan; teamapplicationInfo.vcTeamProSituation = TeamProSituation; teamapplicationInfo.vcApplicantIntroduce = TeamCaptainInfo; teamapplicationInfo.IsDel = false; //向团队申请表添加信息 var teamapplication = TeamService.AddTeamapplication(teamapplicationInfo); if (teamapplication.ID == 0 && teamapplication == null) { return(Content("{\"status\":\"no\",\"result\":\"团队申请信息未能成功保存\"}")); } #endregion #region 创建团队表 team Model.team teamInfo = new Model.team(); teamInfo.vcTeamName = TeamName; teamInfo.vcGuideTeacher = teacherInfo.vcName; teamInfo.dTeamSetupTime = DateTime.Now; teamInfo.bCheckedTeacher = true; teamInfo.bCheckedcounselor = false; teamInfo.IsDel = false; //向团队表添加信息 var team = TeamService.AddEntity(teamInfo); if (team.ID == 0 && team == null) { return(Content("{\"status\":\"no\",\"result\":\"团队信息未能成功保存\"}")); } #endregion #region 创建团队申请人表 teamapplicant Model.teamapplicant teamapplicant = new Model.teamapplicant(); if (teamapplication.ID != 0 && teamapplication != null && team.ID != 0 && team != null) { Model.teamapplicant teamapplicantInfo = new Model.teamapplicant(); teamapplicantInfo.iTeamApplicationID = teamapplication.ID; teamapplicantInfo.iTeamID = team.ID; teamapplicantInfo.iUserID = teacherInfo.iUserID; teamapplicantInfo.IsDel = false; //向团队申请人表添加信息 teamapplicant = TeamService.AddTeamapplicant(teamapplicantInfo); } else { //删除前面添加到团队申请人表和团队表信息 try { team.IsDel = true; bool teamFalg = TeamService.EditEntity(team); bool teamapplicationFalg = TeamService.DeleteTeamapplication(teamapplication); if (teamFalg == true && teamapplicationFalg == true) { return(Content("{\"status\":\"no\",\"result\":\"团队申请失败,团队申请人表和团队表创建失败\"}")); } else if (!teamFalg) { return(Content("{\"status\":\"no\",\"result\":\"团队申请失败,团队表删除失败\"}")); } else if (!teamapplicationFalg) { return(Content("{\"status\":\"no\",\"result\":\"团队申请失败,团队申请人表删除失败\"}")); } else { return(Content("{\"status\":\"no\",\"result\":\"团队申请失败,团队申请人表和团队表删除失败\"}")); } } catch (Exception) { return(Content("{\"status\":\"no\",\"result\":\"团队申请失败,团队申请人表和团队表删除出错\"}")); } } #endregion #region 添加队员表 PlayFalg List <Model.players> playersList = new List <Model.players>(); foreach (var item in playerPersonList) { Model.players playersItem = new Model.players(); playersItem.iUserID = item.iUserID; playersItem.bPlayerType = false; playersItem.iTeamApplicantID = teamapplicant.ID; playersItem.IsDel = false; playersList.Add(playersItem); } bool PlayFalg = TeamService.AddPlayerList(playersList); if (!PlayFalg) { return(Content("{\"status\":\"no\",\"result\":\"队员信息添加失败\"}")); } #endregion #region 添加队长 TeamCaptionPlayerFlag bool TeamCaptionPlayerFlag; Model.players TeamCaptionPlayer = new Model.players(); TeamCaptionPlayer.iUserID = teamCaptainInfo.iUserID; TeamCaptionPlayer.iTeamApplicantID = teamapplicant.ID; TeamCaptionPlayer.bPlayerType = true; TeamCaptionPlayer.IsDel = false; TeamCaptionPlayerFlag = TeamService.AddPlayer(TeamCaptionPlayer); if (!TeamCaptionPlayerFlag) { return(Content("{\"status\":\"no\",\"result\":\"队长信息添加失败\"}")); } #endregion //#region 修改队长身份 teamCaptainTypeFlag //bool teamCaptainTypeFlag = false; //if (teamCaptainInfo != null && teamCaptainInfo.ID != 0&& TeamCaptionPlayerFlag==true) //{ // teamCaptainTypeFlag = TeamService.EditTeamCaptionType(Convert.ToInt32(teamCaptainInfo.iUserID)); //} //#endregion return(Content("{\"status\":\"ok\",\"result\":\"添加成功\"}")); }