public void DeleteApplyState(Guid studentID) { ApplyStateEntity applyState = context.ApplyState.FirstOrDefault(a => a.StudentID == studentID); if (applyState == null) { context.ApplyState.Remove(applyState); } context.SaveChanges(); }
public void SaveApplyState(ApplyStateEntity applyState) { ApplyStateEntity originApplyState = context.ApplyState.FirstOrDefault(a => a.StudentID == applyState.StudentID); if (originApplyState == null) { context.ApplyState.Add(applyState); } else { context.Entry(originApplyState).CurrentValues.SetValues(applyState); } context.SaveChanges(); }
public ActionResult BeginApply(Guid id) { ApplyStateEntity applyStateEntity = applyStateReposity.ApplyStates.FirstOrDefault(a => a.StudentID == id); if (applyStateEntity == null) { applyStateEntity = new ApplyStateEntity { StudentID = id }; applyStateReposity.SaveApplyState(applyStateEntity); return(RedirectToAction("Familiar", new { id = id })); } else { #region swith to current state switch (applyStateEntity.CurrentState) { case "Familiar": //检测了解期 return(RedirectToAction("Familiar", new { id = applyStateEntity.StudentID })); case "Actplan": //检测活动策划期 if (applyStateEntity.IsActplanDone == false && applyStateEntity.IsFamiliarDone) { return(RedirectToAction("Actplan", new { id = applyStateEntity.StudentID })); } else { return(RedirectToAction("Familiar", new { id = applyStateEntity.StudentID })); } case "ApplyBegin": //检测申请初期 if (applyStateEntity.IsBeginingDone == false && applyStateEntity.IsFamiliarDone && applyStateEntity.IsActplanDone) { return(RedirectToAction("ApplyBegin", new { id = applyStateEntity.StudentID })); } else { return(RedirectToAction("Familiar", new { id = applyStateEntity.StudentID })); } case "ApplyMiddle": //检测申请中期 if (applyStateEntity.IsMiddleDone == false && applyStateEntity.IsBeginingDone && applyStateEntity.IsFamiliarDone && applyStateEntity.IsActplanDone) { return(RedirectToAction("ApplyMiddle", new { id = applyStateEntity.StudentID })); } else { return(RedirectToAction("Familiar", new { id = applyStateEntity.StudentID })); } case "ApplyLast": //检测申请后期 if (applyStateEntity.IsLateDone == false && applyStateEntity.IsMiddleDone && applyStateEntity.IsBeginingDone && applyStateEntity.IsFamiliarDone && applyStateEntity.IsActplanDone) { return(RedirectToAction("ApplyLast", new { id = applyStateEntity.StudentID })); } else { return(RedirectToAction("Familiar", new { id = applyStateEntity.StudentID })); } default: return(RedirectToAction("Familiar", new { id = applyStateEntity.StudentID })); } #endregion } }
/// <summary> /// 确认申请流程 /// </summary> /// <param name="id">学生ID</param> /// <param name="currentState">当前阶段</param> /// <param name="nextState">下一个阶段</param> /// <returns></returns> public ActionResult ApplyStateConfirm(Guid id, string currentState, string nextState) { ApplyStateEntity applyState = applyStateReposity.ApplyStates.FirstOrDefault(a => a.StudentID == id); if (applyState != null) { #region Save the ApplyState switch (currentState) { case "Familiar": applyState.IsFamiliarDone = true; applyState.IsActplanDone = false; applyState.IsBeginingDone = false; applyState.IsMiddleDone = false; applyState.IsLateDone = false; break; case "Actplan": applyState.IsFamiliarDone = true; applyState.IsActplanDone = true; applyState.IsBeginingDone = false; applyState.IsMiddleDone = false; applyState.IsLateDone = false; break; case "ApplyBegin": applyState.IsFamiliarDone = true; applyState.IsActplanDone = true; applyState.IsBeginingDone = true; applyState.IsMiddleDone = false; applyState.IsLateDone = false; break; case "ApplyMiddle": applyState.IsFamiliarDone = true; applyState.IsActplanDone = true; applyState.IsBeginingDone = true; applyState.IsMiddleDone = true; applyState.IsLateDone = false; break; case "ApplyLast": applyState.IsFamiliarDone = true; applyState.IsActplanDone = true; applyState.IsBeginingDone = true; applyState.IsMiddleDone = true; applyState.IsLateDone = false; break; default: break; } #endregion applyState.CurrentState = nextState; //更新当前状态 applyStateReposity.SaveApplyState(applyState); //持久化申请状态到数据库中 return(RedirectToAction(nextState, new { id = id })); } else { return(RedirectToAction("BeginApply", new { id = id })); } }