private async void btnUnCheck_Click(object sender, RoutedEventArgs e) { string strErrorMsg = ""; try { StudentDisplayModel sdm = StudentTree.SelectedItem as StudentDisplayModel; IAsyncProxy <IScheduleService> scheduleAsyncProxy = await Task.Run(() => ServiceHelper.GetScheduleService()); await scheduleAsyncProxy.CallAsync(c => c.UnCheckStudent(ScheduleId, sdm.Id, GlobalObjects.currentLoginUser)); this.ShowAutoCloseDialogOwter(UIResources.MsgInfo, "撤销学员上课记录成功!"); this.DialogResult = true; } catch (TimeoutException timeProblem) { strErrorMsg = timeProblem.Message + UIResources.TimeOut + timeProblem.Message; } catch (FaultException <LCFault> af) { strErrorMsg = af.Detail.Message; } catch (FaultException unknownFault) { strErrorMsg = UIResources.UnKnowFault + unknownFault.Message; } catch (CommunicationException commProblem) { strErrorMsg = UIResources.ConProblem + commProblem.Message + commProblem.StackTrace; } if (strErrorMsg != string.Empty) { await DialogManager.ShowMessageAsync(this, UIResources.MsgError, "撤销学员上课记录失败!原因:" + strErrorMsg, MessageDialogStyle.Affirmative, null); } }
private StudentDisplayModel BuildModel(student studentEntity) { if (studentEntity == null) { return(null); } else { StudentDisplayModel studentModel = new StudentDisplayModel(); studentModel.Address = studentEntity.address; studentModel.Birthdate = studentEntity.students_birthdate; studentModel.Dadsname = studentEntity.dads_name; studentModel.Dadsphone = studentEntity.dads_phone; studentModel.Email = studentEntity.email; studentModel.ExtraInfo = studentEntity.extra_info; studentModel.Grade = studentEntity.grade; studentModel.Id = studentEntity.student_id; studentModel.Momsname = studentEntity.moms_name; studentModel.Momsphone = studentEntity.moms_phone; studentModel.Name = studentEntity.students_name; studentModel.Nickname = studentEntity.students_nickname; studentModel.OriginalClass = studentEntity.original_class; studentModel.RemainingBalance = studentEntity.remaining_balance.HasValue ? studentEntity.remaining_balance.Value : 0; studentModel.School = studentEntity.school; studentModel.Status = studentEntity.status1.description; return(studentModel); } }
// GET: Student public async Task <ActionResult> Index() { var studentDisplayModel = new StudentDisplayModel { Students = await _studentOrchestrator.GetAllStudents() }; return(View(studentDisplayModel)); }
public async Task <IActionResult> EditStudent(int studentId) { StudentModel student = await _db.GetStudentById(studentId); StudentDisplayModel display = new StudentDisplayModel { Id = student.Id, StudentId = student.StudentId, FirstName = student.FirstName, LastName = student.LastName, Email = student.Email }; return(View(display)); }
//[Authorize(Roles = "Admin")] public IActionResult AddStudent(StudentDisplayModel student) { if (ModelState.IsValid) { StudentModel newStudent = new StudentModel { StudentId = student.StudentId, FirstName = student.FirstName, LastName = student.LastName, Email = student.Email }; _db.InsertStudent(newStudent); return(RedirectToAction("ViewStudents")); } return(View()); }
private async void UpdateConsultant_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { StudentDisplayModel selectStudent = this.gvStudent.SelectedItem as StudentDisplayModel; if (selectStudent != null) { string strErrorMsg = string.Empty; try { EditStudentWindow newStudentWindow = new EditStudentWindow(); newStudentWindow.StudentId = selectStudent.Id; newStudentWindow.Om = OperationMode.EditMode; if (newStudentWindow.ShowDialog() == true) { await bindStudentList(); } } catch (TimeoutException timeProblem) { strErrorMsg = timeProblem.Message + UIResources.TimeOut + timeProblem.Message; } catch (FaultException <LCFault> af) { strErrorMsg = af.Detail.Message; } catch (FaultException unknownFault) { strErrorMsg = UIResources.UnKnowFault + unknownFault.Message; } catch (CommunicationException commProblem) { strErrorMsg = UIResources.ConProblem + commProblem.Message + commProblem.StackTrace; } catch (Exception ex) { strErrorMsg = ex.Message; } if (strErrorMsg != string.Empty) { await DialogManager.ShowMessageAsync(this.GetMainWindow(), UIResources.MsgError, "更新学员失败!原因:" + strErrorMsg, MessageDialogStyle.Affirmative, null); } } }
public async Task <IActionResult> UpdateStudent(StudentDisplayModel student) { if (ModelState.IsValid) { StudentModel updatedStudent = new StudentModel { Id = student.Id, StudentId = student.StudentId, FirstName = student.FirstName, LastName = student.LastName, Email = student.Email }; await _db.UpdateStudent(updatedStudent); return(RedirectToAction("ViewStudents")); } return(View()); }
public IActionResult OnPost() { if (ModelState.IsValid == false) { return(Page()); } StudentModel newStudent = new StudentModel { StudentId = Student.StudentId, FirstName = Student.FirstName, LastName = Student.LastName, Email = Student.Email }; _data.InsertStudent(newStudent); Student = new StudentDisplayModel(); return(RedirectToPage("/Index")); }
public async Task <IActionResult> ViewStudentById(int studentId) { StudentModel student = null; string loadLocation = null; string isCacheData = null; student = await _cache.GetEntryAsync <StudentModel>(studentId.ToString()); if (student is null) { if (await _db.IsValidStudentId(studentId) == false) { return(RedirectToAction("Alert")); } student = await _db.GetStudentById(studentId); loadLocation = "Data loaded from SQL database"; isCacheData = "text-success"; await _cache.SetEntryAsync(studentId.ToString(), student); } else { loadLocation = "Data loaded form Redis Cache"; isCacheData = "text-danger"; } StudentDisplayModel displayStudent = new StudentDisplayModel { StudentId = student.StudentId, FirstName = student.FirstName, LastName = student.LastName, Email = student.Email }; TempData["loadLocation"] = loadLocation; TempData["isCacheData"] = isCacheData; return(View(displayStudent)); }
private async void DeleteConsultant_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (this.gvStudent.SelectedItem == null) { await DialogManager.ShowMessageAsync(this.GetMainWindow(), UIResources.MsgInfo, "请选择需要删除的学员!", MessageDialogStyle.Affirmative, null); return; } MessageDialogResult delResult = await DialogManager.ShowMessageAsync(this.GetMainWindow(), UIResources.MsgInfo, "确定删除该学员吗?", MessageDialogStyle.AffirmativeAndNegative, null); if (delResult == MessageDialogResult.Affirmative) { StudentDisplayModel selectStudent = this.gvStudent.SelectedItem as StudentDisplayModel; if (selectStudent != null) { string strErrorMsg = string.Empty; try { IAsyncProxy <IStudentService> studentAyncProxy = await Task.Run(() => ServiceHelper.GetStudentService()); if (selectStudent.Id != 0) { //删除已经存在于数据库的数据,对于没有存于数据库的,则事件处理完成时都会刷新列表,故不用处理 bool blIsSuccess = await studentAyncProxy.CallAsync(c => c.DeleteById(selectStudent.Id)); if (blIsSuccess == true) { await DialogManager.ShowMessageAsync(this.GetMainWindow(), UIResources.MsgInfo, "删除学员成功!", MessageDialogStyle.Affirmative, null); } } await bindStudentList(); } catch (TimeoutException timeProblem) { strErrorMsg = timeProblem.Message + UIResources.TimeOut + timeProblem.Message; } catch (FaultException <LCFault> af) { strErrorMsg = af.Detail.Message; } catch (FaultException unknownFault) { strErrorMsg = UIResources.UnKnowFault + unknownFault.Message; } catch (CommunicationException commProblem) { strErrorMsg = UIResources.ConProblem + commProblem.Message + commProblem.StackTrace; } catch (Exception ex) { strErrorMsg = ex.Message; } if (strErrorMsg != string.Empty) { await DialogManager.ShowMessageAsync(this.GetMainWindow(), UIResources.MsgError, "删除学员失败!原因:" + strErrorMsg, MessageDialogStyle.Affirmative, null); } } } }