public ActionResult ConfirmData() { try { using (var data = new NDAPortalDatabaseEntities()) { var admission = data.Admissions.FirstOrDefault(x => x.Id == UserInformation.Admission.Id); if (admission == null) { return(RedirectToAction("Index")); } admission.AdmissionStatus = (int)AdmissionStates.SchoolApprovalPending; data.Entry(admission).State = EntityState.Modified; data.SaveChanges(); UserInformation.ActivateSession(UserInformation.UserInformationCredential); return(RedirectToAction("Index")); } } catch (Exception ex) { ActivityLogger.Log(ex); return(RedirectToAction("Index")); } }
public JsonResult DeleteUser(int credentialId) { try { using (var data = new NDAPortalDatabaseEntities()) { var credential = data.Credentials.FirstOrDefault(x => x.Id == credentialId && !x.IsDeleted); if (credential == null) { return(Json(new { Status = false, Message = "User NOT Found" }, JsonRequestBehavior.AllowGet)); } credential.IsDeleted = true; data.SaveChanges(); return(Json(new { Status = true, Message = "Successful" }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { ActivityLogger.Log(ex); return(Json(new { Status = true, Message = ex.Message }, JsonRequestBehavior.AllowGet)); } }
private int ProcessSubSchoolDepartmentEntry(int subSchoolId, string subSchoolDepartmentName) { try { var innerentities = new Entities(); var subSchoolDepartment = innerentities.School_SubSchoolDepartment.FirstOrDefault(x => !x.IsDeleted && x.SubSchoolId == subSchoolId && x.SubSchoolDepartmentName == subSchoolDepartmentName) ?? new School_SubSchoolDepartment(); if (subSchoolDepartment.Id != 0) { return(subSchoolDepartment.Id); } subSchoolDepartment.SubSchoolDepartmentName = subSchoolDepartmentName; subSchoolDepartment.SubSchoolId = subSchoolId; innerentities.School_SubSchoolDepartment.Add(subSchoolDepartment); innerentities.SaveChanges(); return(subSchoolDepartment.Id); } catch (Exception e) { ActivityLogger.Log(e); return(0); } }
public JsonResult ProcessGetFiles(string query) { try { return(new JsonResult { Data = new { Status = true, Message = "Successful", Data = SearchManager.Query(query) }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } catch (Exception ex) { ActivityLogger.Log(ex); return(new JsonResult { Data = new { Status = false, ex.Message }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } }
protected override void OnActionExecuting(ActionExecutingContext filterContext) { try { if (!UserInformation.IsSessionValid) { filterContext.Result = RedirectToAction("Index", "Home", new { area = "" }); return; } var area = filterContext.RouteData.DataTokens["area"]?.ToString() ?? ""; if (!string.IsNullOrEmpty(area)) { if (UserInformation.CredentialAreas.FirstOrDefault(x => x.AreaName == area) == null) { if (area != UserInformation.Route) { filterContext.Result = RedirectToAction("Index", "Home", new { area = "" }); UserInformation.DeactivateSession(); return; } } } } catch (Exception ex) { ActivityLogger.Log(ex); filterContext.Result = RedirectToAction("Index", "Home", new { area = "" }); return; } }
public void SendPin(string admissionId) { var sessionId = UserInformation.CurrentSession.Id; new Thread(() => { try { using (var data = new NDAPortalDatabaseEntities()) { var admission = data.Admissions.FirstOrDefault(x => x.AdmissionId == admissionId && x.SessionId == sessionId); var credential = data.Credentials.FirstOrDefault(x => x.Id == admission.CredentialId); var message = $"Dear {credential.Surname}, {credential.FirstName} {credential.OtherNames}, <br/>"; message += $"Your Payment has been confirmed by the bank and your PIN has been generated. Find your PIN below.<br/>"; message += $"PIN: <strong>{admission.AccessPin}</strong>. <br/> <br/> Regards."; Core.ClassLib.Messaging.SendMail(credential.Username, "", "", "NDA Admission PIN", message, ""); } } catch (Exception ex) { ActivityLogger.Log(ex); } }).Start(); }
public bool ProcessDumpFile() { try { foreach (string fileName in Request.Files) { var file = Request.Files[fileName]; if (file == null || file.ContentLength <= 0) { continue; } var location = $"{HostingEnvironment.ApplicationPhysicalPath}\\CabynetProDataArchive\\Prep"; if (!Directory.Exists(location)) { Directory.CreateDirectory(location); } var directory = new DirectoryInfo(location); var path = $"{directory.FullName}\\{file.FileName}"; file.SaveAs(path); } return(true); } catch (Exception ex) { ActivityLogger.Log(ex); return(false); } }
public JsonResult DeleteItem(long itemId) { try { using (var entities = new Entities()) { var regManifestItem = entities.Administration_RegistrationSessionManifestItems.FirstOrDefault(x => !x.IsDeleted && x.Id == itemId); if (regManifestItem == null) { return(Json( ResponseData.SendFailMsg(), JsonRequestBehavior.AllowGet)); } entities.Administration_RegistrationSessionManifestItems.Remove(regManifestItem); entities.SaveChanges(); return(Json( ResponseData.SendSuccessMsg(), JsonRequestBehavior.AllowGet)); } } catch (Exception e) { ActivityLogger.Log(e); return(Json(ResponseData.SendExceptionMsg(e), JsonRequestBehavior.AllowGet)); } }
public ActionResult Register(int registrationManifestId = 0) { try { if (registrationManifestId == 0) { return(RedirectToAction("Index", "AdminRegistration")); } using (var entities = new Entities()) { ViewBag.RegistrationManifestId = registrationManifestId; var manifest = entities.Administration_RegistrationSessionManifest.FirstOrDefault(x => !x.IsDeleted && x.Id == registrationManifestId); return(View(manifest)); } } catch (Exception e) { ActivityLogger.Log(e); return(RedirectToAction("Index", "AdminRegistration")); } }
public JsonResult GetUser(string username) { try { using (var data = new Entities()) { var credo = data.Credentials.FirstOrDefault(x => x.Username == username); return(new JsonResult() { Data = new { Status = true, Message = $"Found User", Data = new { UserInformation = credo } }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } } catch (Exception ex) { ActivityLogger.Log(ex); return(new JsonResult() { Data = new { Status = false, Message = ex.Message, Data = string.Empty }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } }
public JsonResult GetAllRegistrationManifests() { try { using (var entities = new Entities()) { var regManifests = entities.Administration_RegistrationSessionManifest.Where(x => !x.IsDeleted) .ToList(); return(Json( ResponseData.SendSuccessMsg(data: regManifests.Select(x => new { DateOfManifest = x.DateOfManifest.ToLongDateString(), x.Id, x.RegistrationDesc, RegistrationReaasonDesc = ((RegistrationReason)x.RegistrationReaason).DisplayName(), x.RegistrationReaason, CurrentCount = entities.Administration_RegistrationSessionManifestItems.Count(y => y.RegistrationSessionManifestId == x.Id && !y.IsDeleted) }).ToList()), JsonRequestBehavior.AllowGet)); } } catch (Exception e) { ActivityLogger.Log(e); return(Json(ResponseData.SendExceptionMsg(e), JsonRequestBehavior.AllowGet)); } }
public ActionResult ManageStudents(string studentId) { try { if (string.IsNullOrEmpty(studentId)) { return(RedirectToAction("Index")); } using (var data = new Entities()) { var student = data.Students.FirstOrDefault(x => x.StudentId == studentId); if (student == null) { return(RedirectToAction("Index")); } ViewBag.Class = data.Classes.FirstOrDefault(x => x.Id == student.CurrentClassId)?.ClassName ?? "No Class Assigned"; return(View(student)); } } catch (Exception ex) { ActivityLogger.Log(ex); return(RedirectToAction("Index")); } }
public JsonResult GetStateLga(string stateName) { try { using (var data = new NDAPortalDatabaseEntities()) { var state = data.States.FirstOrDefault(x => x.StateName == stateName); var lga = data.Localities.Where(x => x.StateId == state.StateId).OrderBy(x => x.LocalityName).ToList(); return (Json( new { Status = true, Message = "Successful", Data = lga }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { ActivityLogger.Log(ex); return(Json(new { Status = false, Message = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public JsonResult GetStates() { try { using (var data = new NDAPortalDatabaseEntities()) { var states = data.States.OrderBy(x => x.StateName).ToList(); return (Json( new { Status = true, Message = "Successful", Data = states }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { ActivityLogger.Log(ex); return(Json(new { Status = false, Message = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public JsonResult GetClassStudents(int currentClassId) { try { var credentialId = UserInformation.UserInformationCredential.Id; using (var data = new Entities()) { var currentStudentsInClass = data.Students.Where(x => x.CurrentClassId == currentClassId) .OrderBy(x => x.StudentSurname) .ThenBy(x => x.StudentOtherName) .ToList(); return(new JsonResult() { Data = new { Status = true, Message = $"Successful", Data = currentStudentsInClass }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } } catch (Exception ex) { ActivityLogger.Log(ex); return(new JsonResult() { Data = new { Status = false, Message = ex.Message, Data = string.Empty }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } }
public JsonResult SaveRegistrationManifestItemIdCard(RegModelIdCard registrationModel, int registrationManifest, int itemId = 0) { try { using (var entity = new Entities()) { var existingData = entity.Administration_RegistrationSessionManifestItems.Where(x => !x.IsDeleted && x.RegistrationSessionManifestId == registrationManifest).ToList(); var list = new List <RegModelIdCard>(); foreach (var x in existingData) { list.Add(Newtonsoft.Json.JsonConvert.DeserializeObject <RegModelIdCard>(x.DataPayLoad)); } if (list.Any(y => y.MatricNumber == registrationModel.MatricNumber)) { return(Json(ResponseData.SendFailMsg("This Matric Number has been Used"), JsonRequestBehavior.AllowGet)); } } var location = System.Web.Hosting.HostingEnvironment.MapPath( $"~/PassportPictureFiles/Students/") ?? ""; //var location = System.Web.Hosting.HostingEnvironment.MapPath( // $"~/PassportPictureFiles/{RegistrationReason.IdCard.DisplayName()}/{registrationManifest}") ?? // ""; if (!Directory.Exists(location)) { Directory.CreateDirectory(location); } var base64String = registrationModel.Picture.Substring(23); var fileName = registrationModel.MatricNumber .Replace("-", "0") .Replace("_", "0") .Replace("/", "0") .Replace("\\", "0") + ".png"; var filePath = Path.Combine(location, fileName); System.IO.File.WriteAllBytes(filePath, Convert.FromBase64String(base64String)); registrationModel.PictureFileName = fileName; return(Json( SaveRegistrationModelItem(Newtonsoft.Json.JsonConvert.SerializeObject(registrationModel), registrationManifest) ? ResponseData.SendSuccessMsg() : ResponseData.SendFailMsg(), JsonRequestBehavior.AllowGet)); } catch (Exception e) { ActivityLogger.Log(e); return(Json(ResponseData.SendExceptionMsg(e), JsonRequestBehavior.AllowGet)); } }
public JsonResult GetAssessments(int classSubjectId) { try { using (var data = new Entities()) { var classSubjectMemberResult = data.ClassSubjectMemberResults.Where( x => x.IsDeleted == false && x.ClassSubjectId == classSubjectId) .ToList() .Select(c => new { c, AssessmentType = ((AssessmentType)c.MemberResultType).DisplayName() }) .ToList(); var classSubject = data.ClassSubjects.FirstOrDefault(x => x.Id == classSubjectId); return(new JsonResult() { Data = new { Status = true, Message = $"Successful", Data = classSubjectMemberResult, IsActivated = classSubject?.IsActivated }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } } catch (Exception ex) { ActivityLogger.Log(ex); return(new JsonResult() { Data = new { Status = false, Message = ex.Message, Data = string.Empty }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } }
private bool SaveRegistrationModelItem(string modelItem, int registrationManifestId) { try { using (var entities = new Entities()) { entities.Administration_RegistrationSessionManifestItems.Add( new Administration_RegistrationSessionManifestItems() { DataPayLoad = modelItem, DateOfEntry = DateTime.Now, IsDeleted = false, RegistrationSessionManifestId = registrationManifestId }); entities.SaveChanges(); } return(true); } catch (Exception e) { ActivityLogger.Log(e); return(false); } }
public JsonResult GetUploadedResults(int assessmentId, int classId, int subjectId) { try { using (var data = new Entities()) { var uploadedData = data.ResultRaws.Where( x => x.AssessmentId == assessmentId && x.ClassId == classId && x.SubjectId == subjectId) .OrderBy(x => x.StudentId) .ToList(); return(new JsonResult() { Data = new { Status = true, Message = $"Success", Data = uploadedData }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } } catch (Exception ex) { ActivityLogger.Log(ex); return(new JsonResult() { Data = new { Status = false, Message = ex.Message, Data = string.Empty }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } }
// GET: RemoteStudentManagement public JsonResult PullUsers(int done = 0) { try { //var accessCredentials = _entities.Administration_AccessCredential.Where(x => !x.IsDeleted) // .OrderBy(x=> x.Id) // .Skip(done) // .Take(100) // .ToList(); var accessCredentials = Mocks.MockCredentials .OrderBy(x => x.AccessCredential.Id) .Skip(done) .Take(100) .ToList(); var accessCredentialData = accessCredentials.Select(x => new AuthModel() { AccessCredential = x.AccessCredential, AccessRoles = x.AccessRoles }).ToList(); return(Json(ResponseData.SendSuccessMsg(data: accessCredentialData), JsonRequestBehavior.AllowGet)); } catch (Exception e) { ActivityLogger.Log(e); return(Json(ResponseData.SendExceptionMsg(e), JsonRequestBehavior.AllowGet)); } }
public bool UploadDocument(int?assessmentId) { try { foreach (string fileName in Request.Files) { var file = Request.Files[fileName]; if (file != null && file.ContentLength > 0) { var location = $"{HostingEnvironment.ApplicationPhysicalPath}UploadedFile\\UploadedResults\\{UserInformation.UserInformationCredential.Username}\\{assessmentId}"; if (!Directory.Exists(location)) { Directory.CreateDirectory(location); } var directory = new System.IO.DirectoryInfo(location); var path = $"{directory.FullName}\\{file.FileName}"; file.SaveAs(path); } } return(true); } catch (Exception ex) { ActivityLogger.Log(ex); return(false); } }
public static PinState PinRegResultView(string studentId) { try { if (Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["PinRegResultView"] ?? "false") == false) { return(PinState.NoPinRequired); } using (var data = new Entities()) { var pinBatch = data.PinBatches.FirstOrDefault(x => x.IsDeleted == false && x.EducationalPeriod == CurrentEducationalPeriod.Id && x.SubEducationalPeriod == CurrentSubEducationalPeriod.Id); if (pinBatch == null) { return(PinState.PinRequiredNotFound); } var pin = data.PinBatchMembers.FirstOrDefault(x => x.IsDeleted == false && x.StudentId == studentId && x.BatchId == pinBatch.Id); return(pin == null ? PinState.PinRequiredNotFound : PinState.PinRequiredFound); } } catch (Exception ex) { ActivityLogger.Log(ex); return(PinState.NoPinRequired); } }
public static void LogFileAudit(long fileInformationId, AuditStates auditStates, int userId) { new Thread(() => { try { using (var entities = new Entities()) { entities.FileAuditLogs.Add(new FileAuditLog() { IsDeleted = false, AuditCommitUserId = userId, AuditPeriod = DateTime.Now, AuditType = (int)auditStates, FileInformationId = fileInformationId }); entities.SaveChanges(); } } catch (Exception e) { ActivityLogger.Log(e); } }).Start(); }
public JsonResult GetAssessments() { try { using (var data = new Entities()) { var assessment = data.Assessments.Where(x => x.IsDeleted == false) .ToList() .Select(a => new { a, AssessmentTypeDisplay = ((AssessmentType)a.AssessmentType).DisplayName() }) .ToList(); return(new JsonResult() { Data = new { Status = true, Message = "Successful", Data = assessment }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } } catch (Exception ex) { ActivityLogger.Log(ex); return(new JsonResult() { Data = new { Status = false, Message = ex.Message, Data = string.Empty }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } }
public JsonResult MapRoles(int credentialId, string areaName, bool isDeleted) { try { using (var data = new NDAPortalDatabaseEntities()) { var role = data.CredentialAreas.FirstOrDefault( x => x.AreaName == areaName && x.CredentialId == credentialId); if (role == null) { data.CredentialAreas.Add(new CredentialArea() { AreaName = areaName, CredentialId = credentialId, IsDeleted = isDeleted }); } else { role.IsDeleted = isDeleted; } data.SaveChanges(); return(Json(new { Status = true, Message = "Successful" }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { ActivityLogger.Log(ex); return(Json(new { Status = true, Message = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public JsonResult MakeCurrentSession(int sessionId) { try { using (var data = new NDAPortalDatabaseEntities()) { var newSession = data.Sessions.FirstOrDefault(x => !x.IsDeleted && x.Id == sessionId); if (newSession == null) { return(Json( new { Status = false, Message = "This Session does not exist. Please select another" }, JsonRequestBehavior.AllowGet)); } var oldSession = data.Sessions.FirstOrDefault(x => !x.IsDeleted && x.IsCurrentSession); if (oldSession != null) { oldSession.IsCurrentSession = false; } newSession.IsCurrentSession = true; data.SaveChanges(); return(Json( new { Status = true, Message = "Successful Modification" }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { ActivityLogger.Log(ex); return(Json(new { Status = false, Message = ex.Message }, JsonRequestBehavior.AllowGet)); } }
private int ProcessSubSchoolEntry(string subSchoolName) { try { var innerentities = new Entities(); var subSchool = innerentities.School_SubSchool.FirstOrDefault(x => !x.IsDeleted && x.SubSchoolName == subSchoolName) ?? new School_SubSchool(); if (subSchool.Id != 0) { return(subSchool.Id); } subSchool.SubSchoolName = subSchoolName; innerentities.School_SubSchool.Add(subSchool); innerentities.SaveChanges(); return(subSchool.Id); } catch (Exception e) { ActivityLogger.Log(e); return(0); } }
public JsonResult RemoveSubProgramme(string subProgrammeCode, int subProgrameId) { try { using (var data = new NDAPortalDatabaseEntities()) { var subProgramme = data.SubProgrammes.FirstOrDefault( x => x.SubProgrammeCode == subProgrammeCode && x.Id == subProgrameId); if (subProgramme == null) { return (Json( new { Status = false, Message = "This Sub Programme does not Exist. Please check and verify" }, JsonRequestBehavior.AllowGet)); } subProgramme.IsDeleted = true; data.Entry(subProgramme).State = EntityState.Modified; data.SaveChanges(); return(Json(new { Status = true, Message = "Successful Configuration" }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { ActivityLogger.Log(ex); return(Json(new { Status = false, Message = ex.Message }, JsonRequestBehavior.AllowGet)); } }
private void FinalizeFileUpload(IReadOnlyCollection <List <string> > returnData, DataSet dataSet, string notifyDestination) { try { var messageBody = System.IO.File.ReadAllText( $"{HostingEnvironment.ApplicationPhysicalPath}Assets\\message\\fileprocesscomplete.html"); messageBody = messageBody.Replace("{{file_name}}", dataSet.DataSetName); if (returnData.Count > 0) { var errors = ""; foreach (var returnDatum in returnData) { foreach (var returnDatumItem in returnDatum) { errors += $"{returnDatumItem}<br />"; } } messageBody = messageBody.Replace("{{table_other_info}}", errors); } else { messageBody = messageBody.Replace("{{table_other_info}}", "No Notable Errors"); } Messaging.SendMail(notifyDestination, null, null, "File Processing Status", messageBody, null); } catch (Exception e) { ActivityLogger.Log(e); } }
public JsonResult LoadRegistrationInformation() { try { using (var data = new NDAPortalDatabaseEntities()) { var regInformation = data.Registrations.FirstOrDefault( x => !x.IsDeleted && x.CredentialId == UserInformation.UserInformationCredential.Id && x.AdmissionId == UserInformation.Admission.AdmissionId && x.SessionId == UserInformation.CurrentSession.Id); if (regInformation == null) { return(Json(new { Status = false, Message = "No Information Available to Display. Please Contact Support" }, JsonRequestBehavior.AllowGet)); } var dob = regInformation.DateOfBirth?.ToString("dd-MM-yyyy") ?? DateTime.Now.ToString("dd-MM-yyyy"); return(Json(new { Status = true, Message = "Succesful", Data = regInformation, DateOfBirth = dob }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { ActivityLogger.Log(ex); return (Json( new { Status = false, Message = ex.Message }, JsonRequestBehavior.AllowGet)); } }