[HttpGet] // Show result of a particular Student public async Task <IActionResult> ShowResult(string id) { try { var student = await studentRepository.FindByIdAsync(id); if (student == null) { ViewBag.ErrorMsg = $"Could not find student: {id}"; return(RedirectToAction("Unknown", "Error")); } var assessmentResults = await assessmentResultRepository.GetStudentAssessmentResults(id); ShowStudentResultViewModel vm = new ShowStudentResultViewModel(); vm.StudentName = student.FirstName + " " + student.SurName; vm.Programme = student.Programme.ProgrammeName; vm.StudentImage = student.StudentImage; vm.listOfAssessmentResult = assessmentResults.ToList(); return(View(vm)); } catch (DataAccessException e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("Data Access exception. ", e); return(RedirectToAction("Unknown", "Error")); } catch (Exception e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("General exception. ", e); return(RedirectToAction("Unknown", "Error")); } }
public async Task <IActionResult> Edit(string id, [Bind("StudentID,FirstName,SurName,Password,AddressOne,AddressTwo,Town,County,MobilePhoneNumber,EmailAddress,EmergencyMobilePhoneNumber,StudentPPS,ProgrammeFeePaid,DateOfBirth,GenderType,FullOrPartTime,StudentImage,ProgrammeID")] Student student) { if (id != student.StudentID) { return(NotFound()); } if (ModelState.IsValid) { try { studentRepository.Update(student); await studentRepository.SaveChangesAsync(); return(RedirectToAction("Details", new { id = student.StudentID })); } catch (DataAccessException e) { if (!await StudentExists(student.StudentID)) { return(NotFound()); } ViewBag.ErrorMsg = ErrorProcessing.ProcessException("Data Access exception. ", e); return(RedirectToAction("Unknown", "Error")); } catch (Exception e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("General exception. ", e); return(RedirectToAction("Unknown", "Error")); } } return(View(student)); }
public async Task <IActionResult> Edit(string id, [Bind("ModuleID,ModuleName,ModuleDescription,ModuleCredits")] Module @module) { if (id != module.ModuleID) { return(NotFound()); } if (ModelState.IsValid) { try { moduleRepository.Update(module); await moduleRepository.SaveChangesAsync(); return(RedirectToAction("Details", new { id = module.ModuleID })); } catch (DataAccessException e) { if (!await ModuleExists(module.ModuleID)) { return(NotFound()); } ViewBag.ErrorMsg = ErrorProcessing.ProcessException("Data Access exception. ", e); return(RedirectToAction("Unknown", "Error")); } catch (Exception e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("General exception. ", e); return(RedirectToAction("Unknown", "Error")); } } return(View(module)); }
public async Task <IActionResult> Create(Module module) { try { if (ModelState.IsValid) { await moduleRepository.AddAsync(module); await moduleRepository.SaveChangesAsync(); ViewBag.SuccessMsg = "Module Created Successfully"; ModelState.Clear(); return(RedirectToAction("Details", new { id = module.ModuleID })); } return(View(module)); } catch (DataAccessException e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("Data Access exception. ", e); return(RedirectToAction("Unknown", "Error")); } catch (Exception e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("General exception. ", e); return(RedirectToAction("Unknown", "Error")); } }
public async Task <IActionResult> Edit(string id, [Bind("ProgrammeID,ProgrammeName,ProgrammeDescription,ProgrammeQQILevel,ProgrammeCredits,ProgrammeCost")] Programme programme) { if (id != programme.ProgrammeID) { return(NotFound()); } if (ModelState.IsValid) { try { programmeRepository.Update(programme); await programmeRepository.SaveChangesAsync(); return(RedirectToAction("Details", new { id = programme.ProgrammeID })); } catch (DataAccessException e) { if (!ProgrammeExists(programme.ProgrammeID)) { return(NotFound()); } ViewBag.ErrorMsg = ErrorProcessing.ProcessException("Data Access exception. ", e); return(RedirectToAction("Unknown", "Error")); } catch (Exception e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("General exception. ", e); return(RedirectToAction("Unknown", "Error")); } } return(View(programme)); }
public async Task <IActionResult> Create([Bind("ProgrammeID,ProgrammeName,ProgrammeDescription,ProgrammeQQILevel,ProgrammeCredits,ProgrammeCost")] Programme programme) { try { if (ModelState.IsValid) { await programmeRepository.AddAsync(programme); await programmeRepository.SaveChangesAsync(); ViewBag.SuccessMsg = "Programme Created Successfully"; var programmeDetails = await programmeRepository.FindByIdAsync(programme.ProgrammeID); ModelState.Clear(); return(RedirectToAction("Details", new { id = programme.ProgrammeID })); } return(View(programme)); } catch (DataAccessException e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("Data Access exception. ", e); return(RedirectToAction("Unknown", "Error")); } catch (Exception e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("General exception. ", e); return(RedirectToAction("Unknown", "Error")); } }
[HttpGet] // GET: Teacher/Delete/5 public async Task <IActionResult> Delete(string id) { try { if (id == null) { return(RedirectToAction("NotFoundPage", "Error")); } var teacher = await teacherRepository.FindByIdIncludeProgrammeAsync(id); if (teacher == null) { return(RedirectToAction("NotFoundPage", "Error")); } return(View(teacher)); } catch (DataAccessException e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("Data Access exception. ", e); return(RedirectToAction("Unknown", "Error")); } catch (Exception e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("General exception. ", e); return(RedirectToAction("Unknown", "Error")); } }
protected virtual void Delete() { if (SelectionMode == DataGridSelectionMode.Single || SelectionMode == DataGridSelectionMode.Extended && SelectedItems?.Count == 1) { if (MessageConfirmBox.Show(Settings.Same().AppImageUrl, $"{CurrentItem.Name}", Settings.Same().LocalisationHelper["DMLRes.ConfirmDeleteCaption"], ConfirmBoxButtons.OKCancel, ConfirmBoxImage.Question) == MessageBoxResult.OK) { try { //RefNode node = _db.RefNodes.Find(Directories[SelectedIndex].Id); //if (node != null) { // _db.RefNodes.Remove(node); // _db.SaveChanges(); //} else { // MessageConfirmBox.Show(Settings.Same().AppImageUrl, $"ID={Directories[SelectedIndex].Id}", "Данные не найдены.", ConfirmBoxButtons.Cancel, ConfirmBoxImage.Warning); //} int deleted = _db.Database.ExecuteSqlCommand("DELETE FROM " + TableName + " WHERE Id = " + CurrentItem.Id); } catch (Exception e) { ErrorProcessing.Show(e); } Load(); } } else { ExecuteDeleteDialog(); } }
public async Task <IActionResult> Edit(string id, [Bind("AssessmentResultID,AssessmentResultDescription,AssessmentResultMark,StudentID,ProgrammeID,AssessmentDate,ModuleID,AssessmentID")] AssessmentResult assessmentResult) { if (id != assessmentResult.AssessmentResultID) { return(NotFound()); } if (ModelState.IsValid) { try { assessmentResultRepository.Update(assessmentResult); await assessmentResultRepository.SaveChangesAsync(); } catch (DataAccessException e) { if (!AssessmentResultExists(assessmentResult.AssessmentResultID)) { return(NotFound()); } ViewBag.ErrorMsg = ErrorProcessing.ProcessException("Data Access exception. ", e); return(RedirectToAction("Unknown", "Error")); } catch (Exception e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("General exception. ", e); return(RedirectToAction("Unknown", "Error")); } return(RedirectToAction(nameof(ShowAll))); } return(View(assessmentResult)); }
// GET: AssessmentResults/Create public async Task <IActionResult> Submit(string id) { try { var student = await studentRepository.FindByIdIncludeProgrammeAsync(id); if (student == null) { ViewBag.StudentList = studentRepository.AllAsync(); } else { ViewBag.StudentId = student.StudentID; ViewBag.StudentFullName = student.FirstName + " " + student.SurName; } return(View()); } catch (DataAccessException e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("Data Access exception. ", e); return(RedirectToAction("Unknown", "Error")); } catch (Exception e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("General exception. ", e); return(RedirectToAction("Unknown", "Error")); } }
private void LogDetailError(string message, Exception ex) { var detail = $"{message}: {ErrorProcessing.ExceptionMessageToString(ex)}"; _logger.Error(detail); MessageBox.Show($"{message}"); }
public async Task <IActionResult> Create(Assessment assessment) { try { if (ModelState.IsValid) { await assessmentRepository.AddAsync(assessment); await assessmentRepository.SaveChangesAsync(); ViewBag.SuccessMsg = "Assessment Created Successfully"; ViewBag.ModuleList = await moduleRepository.AllAsync(); ViewBag.AssessmentID = await GetAssessmentID(); ModelState.Clear(); return(View()); } ViewBag.ModuleList = await moduleRepository.AllAsync(); return(View(assessment)); } catch (DataAccessException e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("Data Access exception. ", e); return(RedirectToAction("Unknown", "Error")); } catch (Exception e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("General exception. ", e); return(RedirectToAction("Unknown", "Error")); } }
public void SetImageRotate(ListContent item) { try { if (item.NProperty != null) { // Update ContentProperty rotateProperty = Settings.Instance.ContentDB.ContentProperties.Find(item.NProperty); if (rotateProperty != null) { rotateProperty.Rotate = (int)item.NRotate; Settings.Instance.ContentDB.Entry(rotateProperty).State = EntityState.Modified; Settings.Instance.ContentDB.SaveChanges(); } } else { // Insert ContentProperty rotateProperty = new ContentProperty { Content = item.Id, Rotate = (int)item.NRotate }; Settings.Instance.ContentDB.ContentProperties.Add(rotateProperty); Settings.Instance.ContentDB.SaveChanges(); item.NProperty = GetIdContentProperties(item.Id); } } catch (Exception e) { ErrorProcessing.Show(e); } }
public async Task <IActionResult> Edit(string id, [Bind("TeacherID,FirstName,SurName,Password,AddressOne,AddressTwo,Town,County,MobilePhoneNumber,EmailAddress,EmergencyMobilePhoneNumber,TeacherPPS,ProgrammeFeePaid,GenderType,FullOrPartTime,TeacherImage,ProgrammeID")] Teacher teacher) { if (id != teacher.TeacherID) { return(NotFound()); } if (ModelState.IsValid) { try { teacherRepository.Update(teacher); await teacherRepository.SaveChangesAsync(); return(RedirectToAction("Details", new { id = teacher.TeacherID })); } catch (DataAccessException e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("Data Access exception. ", e); if (!TeacherExists(teacher.TeacherID)) { return(NotFound()); } return(RedirectToAction("Unknown", "Error")); } catch (Exception e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("General exception. ", e); return(RedirectToAction("Unknown", "Error")); } } return(View(teacher)); }
public async Task <IActionResult> Login(LoginVm login) { try { var user = await userManager.FindByNameAsync(login.UserName); if (user != null) { var result = await signInManager.CheckPasswordSignInAsync(user, login.Password, false); if (result.Succeeded) { var appUser = userManager.Users.FirstOrDefault(x => x.NormalizedUserName == login.UserName.ToUpper()); string token = await GenerateTokenAsync(appUser); if (token != null) { HttpContext.Session.SetString("JWToken", token); return(RedirectToAction("Index", "Home")); } } } ViewBag.ErrorMsg = "Incorrect UserId or Password"; return(View(login)); } catch (Exception e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("Data Access exception. ", e); return(RedirectToAction("Unknown", "Error")); } }
private void Worker_DoWorkDelete(object sender, DoWorkEventArgs e) { int index = 0; int countDeleted = 0; int countUnDeleted = 0; try { foreach (var item in SelectedItems) { if (_workerDeleteRecords.CancellationPending) { e.Cancel = true; break; } index++; T rec = item as T; try { _workerDeleteRecords.ReportProgress(0, $"{index} / {SelectedItems.Count} \n{rec.Name}"); int deleted = _db.Database.ExecuteSqlCommand("DELETE FROM " + TableName + " WHERE Id = " + rec.Id); countDeleted++; } catch (Exception eDel) { _workerDeleteRecords.ReportProgress(0, $"{index} / {SelectedItems.Count} \n{rec.Name} \n{ErrorProcessing.GetExeptionContent(eDel.GetBaseException())}"); countUnDeleted++; } } } catch (Exception eWorkerDelete) { _workerDeleteRecords.ReportProgress(-1, ErrorProcessing.GetExeptionContent(eWorkerDelete)); } finally { _workerDeleteRecords.ReportProgress(0, $"Успешно удалено: {countDeleted}" + $"\nНе удалено: {countUnDeleted}"); } }
// GET: Student/Delete/5 public async Task <IActionResult> Delete(string id) { try { if (id == null) { ViewBag.ErrorMsg = $"Invalid student ID: {id}"; return(RedirectToAction("Unknown", "Error")); } var student = await studentRepository.FindByIdAsync(id); if (student == null) { ViewBag.ErrorMsg = $"Could not find student: {id}"; return(RedirectToAction("Unknown", "Error")); } return(View(student)); } catch (DataAccessException e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("Data Access exception. ", e); return(RedirectToAction("Unknown", "Error")); } catch (Exception e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("General exception. ", e); return(RedirectToAction("Unknown", "Error")); } }
void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { try { //Debug.WriteLine("------> DispatcherUnhandledException"); ErrorProcessing.Show(e.Exception, _localisationHelper["MainWindowRes.AppDispatcherUnhandledExceptionTitleError"]); e.Handled = true; // помечаем необработанное исключение, как обработанное. Settings.Same().AppStatus = TaskStatus.Faulted; Shutdown(); } catch (Exception eLocal) { ErrorProcessing.Show(eLocal); } }
public async Task <ActionResult> QueryResult(QueryInfo queryInfo) { if (queryInfo == null) { return(BadRequest()); } ViewData[nameof(SearchInfo)] = queryInfo; object results; try { /*** validation ***/ queryInfo.Validate(); /*** query preparation ***/ SparqlRemoteEndpoint endpoint = SearchPreparing.CreateEndpoint(queryInfo.Endpoints[0], queryInfo.Timeout, queryInfo.DefaultGraph); SparqlQuery query = QueryParsing.ParseQuery(queryInfo.QueryString); /*** query processing ***/ results = await QueryProcessing.ProcessQuery(query, endpoint); //ViewData["ExecutionTime"] = query.QueryExecutionTime; } catch (BrowserException e) { return(View("QueryResultError", e.Message)); } catch (Exception) { //TODO: better text return(View("QueryResultError", "Unknown error...")); } /*** result processing ***/ if (results is SparqlResultSet) { return(View("QueryResultSet", (SparqlResultSet)results)); } else if (results is IGraph) { return(View("QueryResultGraph", (IGraph)results)); } else if (results is AsyncError) { return(View("QueryResultError", ErrorProcessing.ProcessAsyncError((AsyncError)results))); } else { //TODO: better text return(View("QueryResultError", "Unknown error...")); } }
public KaleidoscopeImagesViewModel() { try { MainWindowViewModel.LocalizationChangedEvent += () => ContentMenuItemsLocalization(); ContentMenuItemsInit(); SelectedIndexContentMenu = 0; _db = Settings.Same().ContentDB; } catch (Exception e) { Settings.Same().AppStatus = TaskStatus.Faulted; ErrorProcessing.Show(e); (Application.Current as App).Shutdown(); } }
private void InitRepos() { _logger.Debug("Инициализация репозиториев..."); try { _userRepository = new UserRepository(); _logger.Debug("Инициализация репозиториев выполнена"); } catch (Exception ex) { var detail = $"Ошибка Инициализации репозиториев: {ErrorProcessing.ExceptionMessageToString(ex)}"; _logger.Error(detail); } }
protected virtual void Insert(string name) { if (!string.IsNullOrWhiteSpace(name)) { try { //T entity = new T() { Name = name }; //_db.RefNodes.Add(node); //_db.SaveChanges(); int inserted = _db.Database.ExecuteSqlCommand("INSERT INTO " + TableName + " (Name) VALUES ('" + name + "')"); } catch (Exception e) { ErrorProcessing.Show(e, name); } Load(); } }
public async Task <IActionResult> Index() { try { return(View(await teacherRepository.AllIncludeProgrammeAsync())); } catch (DataAccessException e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("Data Access exception. ", e); return(RedirectToAction("Unknown", "Error")); } catch (Exception e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("General exception. ", e); return(RedirectToAction("Unknown", "Error")); } }
public async Task <IActionResult> Register(Student student, IFormFile image) { try { if (image != null) { using (var stream = new MemoryStream()) { image.CopyTo(stream); student.StudentImage = stream.ToArray(); } } if (ModelState.IsValid) { await studentRepository.AddAsync(student); //Create Student Role for Authentication string fullName = student.FirstName + " " + student.SurName; await CreateStudentAsUserAsync(student.StudentID, student.Password, fullName); // Commit changes await studentRepository.SaveChangesAsync(); ModelState.Clear(); ViewBag.SuccessMsg = "Student Successfully Registered"; // Redirect to different view to show newly created student return(RedirectToAction("Details", new { id = student.StudentID })); } return(View(student)); } catch (DataAccessException e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("Data Access exception. ", e); return(RedirectToAction("Unknown", "Error")); } catch (Exception e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("General exception. ", e); return(RedirectToAction("Unknown", "Error")); } }
public async Task <IActionResult> Submit(AssessmentResult assessmentResult) { try { string assessmentResultId = await GetAssessmentResultId(); assessmentResult.AssessmentResultID = assessmentResultId; if (ModelState.IsValid) { await assessmentResultRepository.AddAsync(assessmentResult); await assessmentResultRepository.SaveChangesAsync(); return(RedirectToAction(nameof(ShowAll))); } //Student std = _context.Students // .Include(m => m.Programme) // .FirstOrDefault(m => m.StudentID == assessmentResult.StudentID); var student = await studentRepository.FindByIdIncludeProgrammeAsync(assessmentResult.StudentID); if (student == null) { ViewBag.StudentList = await studentRepository.AllAsync(); } else { ViewBag.StudentId = student.StudentID; ViewBag.StudentFullName = student.FirstName + " " + student.SurName; } return(View(assessmentResult)); } catch (DataAccessException e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("Data Access exception. ", e); return(RedirectToAction("Unknown", "Error")); } catch (Exception e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("General exception. ", e); return(RedirectToAction("Unknown", "Error")); } }
public async Task <IActionResult> ShowAll(string programmeID) { try { ViewBag.programmeList = await programmeRepository.AllAsync(); var assessmentResults = assessmentResultRepository.AllResultsForProgrammeAsync(programmeID); return(View(assessmentResults)); } catch (DataAccessException e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("Data Access exception. ", e); return(RedirectToAction("Unknown", "Error")); } catch (Exception e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("General exception. ", e); return(RedirectToAction("Unknown", "Error")); } }
public async Task <IActionResult> Register() { try { ViewBag.ProgrammeList = ViewBag.ProgrammeList = await programmeRepository.AllAsync(); ViewBag.TeacherId = GetTeacherId(); return(View()); } catch (DataAccessException e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("Data Access exception. ", e); return(RedirectToAction("Unknown", "Error")); } catch (Exception e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("General exception. ", e); return(RedirectToAction("Unknown", "Error")); } }
protected virtual void Update(string name) { if (!string.IsNullOrWhiteSpace(name)) { try { //RefNode node = _db.RefNodes.Find(Directories[SelectedIndex].Id); //if (node != null) { // node.Name = name; // _db.Entry(node).State = EntityState.Modified; // _db.SaveChanges(); //} else { // MessageConfirmBox.Show(Settings.Same().AppImageUrl, $"ID={Directories[SelectedIndex].Id}", "Данные не найдены.", ConfirmBoxButtons.Cancel, ConfirmBoxImage.Warning); //} int updated = _db.Database.ExecuteSqlCommand("UPDATE " + TableName + " SET Name = '" + name + "' WHERE Id = " + CurrentItem.Id); } catch (Exception e) { ErrorProcessing.Show(e, name); } Load(); } }
public async Task <IActionResult> Register(Teacher teacher, IFormFile image) { try { if (image != null) { using (var stream = new MemoryStream()) { image.CopyTo(stream); teacher.TeacherImage = stream.ToArray(); } } if (ModelState.IsValid) { await teacherRepository.AddAsync(teacher); await teacherRepository.SaveChangesAsync(); string fullName = teacher.FirstName + " " + teacher.SurName; await CreateTeacherAsUserAsync(teacher.TeacherID, teacher.Password, fullName); ViewBag.SuccessMsg = "Teacher Successfully Registered"; ModelState.Clear(); return(RedirectToAction("Details", new { id = teacher.TeacherID })); } return(View(teacher)); } catch (DataAccessException e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("Data Access exception. ", e); return(RedirectToAction("Unknown", "Error")); } catch (Exception e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("General exception. ", e); return(RedirectToAction("Unknown", "Error")); } }
public async Task <IActionResult> DeleteConfirmed(string id) { try { await teacherRepository.DeleteTeacherAsync(id); await teacherRepository.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } catch (DataAccessException e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("Data Access exception. ", e); return(RedirectToAction("Unknown", "Error")); } catch (Exception e) { ViewBag.ErrorMsg = ErrorProcessing.ProcessException("General exception. ", e); return(RedirectToAction("Unknown", "Error")); } }