// GET: Section/Edit/5 public IActionResult Edit(int?id) { Section section = null; User currentUser = SessionVariables.GetCurrentUser(HttpContext); if (currentUser != null && currentUser.Role != null && currentUser.Role.Sections.CanEdit) { if (id == null) { return(NotFound()); } section = DAL.GetSection((int)id); if (section == null) { return(NotFound()); } SetUpSectionViewBags(section, true); if (currentUser != null && currentUser.Role != null) { ViewData["CanDelete"] = currentUser.Role.Sections.CanDelete; } else { ViewData["CanDelete"] = false; } return(View(section)); } else { SessionVariables.SetErrorMessage("You do not have permission edit sections"); return(RedirectToAction("Index")); } }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddScoped <SessionLayer>(serviceProvider => SessionVariables.GetSession(serviceProvider)); services.AddSession(); services.AddMvc(); }
public void SelectAcademicSemester(int currentSemesterID, int currentYear) { //List<Section> retList = new List<Section>(); SessionVariables.SetSessionAcademicSemesterID(HttpContext, DAL.GetAcademicSemesterByYearAndSemester(currentSemesterID, currentYear).ID); //retList = DAL.GetSections().Where(s => s.AcademicSemesterID == SessionVariables.GetSessionAcademicSemesterID(HttpContext)).ToList(); //return PartialView("Parts/_IndexList", retList); }
public ResponseModel LoginUser(LoginUserModel user) { ResponseModel result = new ResponseModel(); try { var db_user = _userM.GetUserByEmailAndPassword(user.UserName, user.Password); result.IsSuccess = false; if (db_user != null && db_user.IsActive && db_user.IsApproved) { var currentUserModel = _userM.GetCurrentUserModel(db_user); SessionVariables.SetUser(currentUserModel); var do_user_log = UserBrowserHelper.getUserRequestInfo(); DoLogLoginUser(do_user_log); result.IsSuccess = true; } else { result.Message = "Kullanıcı adı yada şifreniz yanlış!"; } } catch (Exception ex) { result.Message = ex.Message; throw; } return(result); }
protected static void Scriptlet_LastCommand() { try { SessionVariables _SessionVariables = new SessionVariables(); List <string> LastCommands = _SessionVariables.CommandHistory(); long CommandCount = 0; if (LastCommands.Count == 0) { string Error = "No last successful commands recorded."; ValidationResponse.ResponseFromCommandClass = Error; ValidationResponse.CommandReturnedWasSuccessful = false; } CommandInterpreter.WriteToScreenWithNoInterrupt(AppOnlyScope.Status.CommandInformationMessage("Displaying " + CommandCount + " successful commands..")); foreach (object command in LastCommands) { CommandCount += 1; CommandInterpreter.WriteToScreenWithNoInterruptNoSpaces(CommandCount + ". " + command); } var Commands = string.Join(Environment.NewLine, LastCommands); CommandInterpreter.WriteToScreenWithNoInterrupt(CommandCount + ". " + Commands); ValidationResponse.CommandReturnedWasSuccessful = true; } catch (Exception FileListException) { ValidationResponse.ResponseFromCommandClass = FileListException.Message; ValidationResponse.CommandReturnedWasSuccessful = false; } }
public SessionVariables LoadUserSession() { SessionVariables session = NewSessionVariables(); CreateSubDirectories(session); GetLiveFileLocation(session); CopyHistoricFiles(session); LoadValidUserList(session); session = LoadPreviousSession(session); CreateSubDirectories(session); if (!session.ValidUsers.ContainsKey(session.LocalUserName) || !session.UIDLookup.ContainsKey(session.LocalUserName)) { FindLocalUserName(session); } if (session.UIDLookup.ContainsKey(session.LocalUserName)) { session.LocalUserID = session.UIDLookup[session.LocalUserName]; } AssignUserTheme(session); SaveSessionConfig(session); return(session); }
public async Task <IActionResult> Edit(int id, [Bind("FirstName,MiddleName,LastName,Number,CourseLoad,ID")] Instructor instructor) { User currentUser = SessionVariables.GetCurrentUser(HttpContext); if (currentUser != null && currentUser.Role != null && currentUser.Role.Instructors.CanEdit) { if (id != instructor.ID) { return(NotFound()); } if (ModelState.IsValid) { if (DAL.UpdateInstructor(instructor) > 0) { SessionVariables.SetSuccessMessage("Instructor edited successfully"); } else { SessionVariables.SetErrorMessage("Instructor edit failed"); } return(RedirectToAction(nameof(Index))); } return(View(instructor)); } else { SessionVariables.SetErrorMessage("You do not have permission to edit instructors"); return(RedirectToAction("Index")); } }
public async Task <IActionResult> Create([Bind("FirstName,MiddleName,LastName,Number,CourseLoad,ID")] Instructor instructor) { User currentUser = SessionVariables.GetCurrentUser(HttpContext); if (currentUser != null && currentUser.Role != null && currentUser.Role.Instructors.CanAdd) { if (ModelState.IsValid) { if (DAL.AddInstructor(instructor) > 0) { SessionVariables.SetSuccessMessage("Instructor created successfully"); } else { SessionVariables.SetErrorMessage("Instructor create failed"); } return(RedirectToAction(nameof(Index))); } ViewData["InstructorID"] = new SelectList(DAL.GetInstructors(), "ID", "ID", instructor.ID); return(View(instructor)); } else { SessionVariables.SetErrorMessage("You do not have permission to create instructors"); return(RedirectToAction("Index")); } }
public async Task <IActionResult> Create([Bind("Name,IsAdmin,Buildings,Campuses,Courses,Days,Departments,DateTimeModels,Fees,Instructors," + "Roles,Rooms,ScheduleTypes,Sections,Spreadsheets,Subjects,Users,ID")] Role role) { User currentUser = SessionVariables.GetCurrentUser(HttpContext); if (currentUser != null && currentUser.Role != null && currentUser.Role.Roles.CanAdd) { if (ModelState.IsValid) { if (DAL.AddRole(role) > 0) { SessionVariables.SetSuccessMessage("Role created successfully"); } else { SessionVariables.SetErrorMessage("Role create failed"); } return(RedirectToAction(nameof(Index))); } return(View(role)); } else { SessionVariables.SetErrorMessage("You do not have permission to create roles"); return(RedirectToAction("Index")); } }
// GET: Section public IActionResult Index() { User currentUser = SessionVariables.GetCurrentUser(HttpContext); if (currentUser != null && currentUser.Role != null && currentUser.Role.Sections.CanView) { List <AcademicSemester> academicSemesters = DAL.GetAcademicSemesters(); List <int> years = new List <int>(); foreach (AcademicSemester academicSemester in academicSemesters) { if (!years.Contains(academicSemester.AcademicYear)) { years.Add(academicSemester.AcademicYear); } } List <Section> sections = DAL.GetSectionsByAcademicSemesterID(SessionVariables.GetSessionAcademicSemester(HttpContext).ID); ViewData["AcademicSemesterYear"] = SessionVariables.GetSessionAcademicSemester(HttpContext).AcademicYear; ViewData["SemesterID"] = new SelectList(DAL.GetSemesters(), "ID", "Name", SessionVariables.GetSessionAcademicSemester(HttpContext).SemesterID); ViewData["AcademicYears"] = new SelectList(years, SessionVariables.GetSessionAcademicSemester(HttpContext).AcademicYear); ViewData["AcademicSemester"] = SessionVariables.GetSessionAcademicSemester(HttpContext).Display; return(View(sections)); } else { SessionVariables.SetErrorMessage("Login required"); return(RedirectToAction("Login", "User")); } }
public void AssignUserTheme(SessionVariables session) { bool valid_theme = false; foreach (Theme.UITheme theme in Theme.themes) { if (session.SelectedTheme == theme.Name) { valid_theme = true; } } if (!valid_theme) { session.SelectedTheme = "Terminal"; } foreach (Theme.UITheme theme in Theme.themes) { if (session.SelectedTheme == theme.Name) { session.ForeColor = theme.ForeGround; session.BackColor = theme.BackGround; } } }
public ResponseModel LogoutUser() { ResponseModel result = new ResponseModel(); SessionVariables.RemoveAll(); result.IsSuccess = true; return(result); }
public void RemoveVariable(string name) { name = name.ToLower(); if (SessionVariables.ContainsKey(name)) { SessionVariables.TryRemove(name, out object value); } }
public object GetVariableValue(string name) { name = name.ToLower(); if (SessionVariables.ContainsKey(name)) { return(SessionVariables[name]); } return(null); }
public ResponseModel ResetSessionUser(int user_id) { ResponseModel result = new ResponseModel(); var db_user = _userM.GetUserByID(user_id); var currentUserModel = _userM.GetCurrentUserModel(db_user); SessionVariables.SetUser(currentUserModel); result.IsSuccess = true; return(result); }
public void FindLocalUserName(SessionVariables session) { if (session.ValidUsers.Count() == 0) { MessageBox.Show("No valid user names were detected. Please try restarting CO_Driver. If problem persists after restart please contact Rot_Fish_Bandit at https://discord.gg/kKcnVXu2Xe"); Application.Exit(); return; } session.LocalUserName = session.ValidUsers.Aggregate((l, r) => l.Value > r.Value ? l : r).Key; }
public void SetVariable(string name, object value) { name = name.ToLower(); if (SessionVariables.ContainsKey(name)) { SessionVariables[name] = value; } else { SessionVariables.TryAdd(name, value); } }
public ResponseModel LoginUser(int user_id) { ResponseModel result = new ResponseModel(); var db_user = _userM.GetUserByID(user_id); var currentUserModel = _userM.GetCurrentUserModel(db_user); SessionVariables.SetUser(currentUserModel); var do_user_log = UserBrowserHelper.getUserRequestInfo(); DoLogLoginUser(do_user_log); result.IsSuccess = true; return(result); }
public void SaveSessionConfig(SessionVariables session) { if (!ValidUserSession(session)) { //MessageBox.Show("Configuration invalid, aborting save."); return; } using (StreamWriter file = File.CreateText(session.ConfigFileLocation + @"\config.json")) { JsonSerializer serializer = new JsonSerializer(); serializer.Serialize(file, session); } }
// GET: Instructor/Create public IActionResult Create() { User currentUser = SessionVariables.GetCurrentUser(HttpContext); if (currentUser != null && currentUser.Role != null && currentUser.Role.Instructors.CanAdd) { return(View()); } else { SessionVariables.SetErrorMessage("You do not have permission to create instructors"); return(RedirectToAction("Index")); } }
protected void ddlFieldConfigurationMode_SelectedIndexChanged(object sender, EventArgs e) { var currentEntity = "ScheduleDetail"; GetData(); var fcMode = ddlFieldConfigurationMode.SelectedValue; SessionVariables.SaveSessionInstanceFCMode(Convert.ToInt32(fcMode), currentEntity); var settingCategory = "ScheduleDetailDefaultView"; PerferenceUtility.UpdateUserPreference(settingCategory, ApplicationCommon.FieldConfigurationMode, fcMode); }
public IActionResult Create([Bind("ID,Name,DepartmentComments,Notes,RequiresPermission,RequiresMoodle,CRN,DateArchived,DateCreated,StudentLimit," + "StartTime,EndTime,PartOfTermID,CourseID,PrimaryInstructorPercent,SecondaryInstructorPercent,ScheduleTypeID,Number" + "PrimaryInstructorID,SecondaryInstructorID,RoomID")] Section section) { if (ModelState.IsValid) { //section number isn't being passed from the form for some reason so it's being grabbed directly from the form section.Number = Request.Form["Number"]; section.AcademicSemesterID = SessionVariables.GetSessionAcademicSemester(HttpContext).ID; if (section.PrimaryInstructorID > 0 && section.SecondaryInstructorID > 0) { if (section.PrimaryInstructorPercent + section.SecondaryInstructorPercent != 100) { ModelState.AddModelError("PrimaryInstructorPercent", "Percentages don't equal 100%"); ModelState.AddModelError("SecondaryInstructorPercent", "Percentages don't equal 100%"); SetUpSectionViewBags(section, true); return(View(section)); } } else { section.PrimaryInstructorPercent = 100; } section.ID = DAL.AddSection(section); if (section.ID > 0) { SessionVariables.SetSuccessMessage("Section created"); if (section.Course.CrossListedCourseID > 0) { CreateCrossListedSection(ref section); } SetUpSectionDays(section); SetUpSectionInstructors(section); ChangeLog changeLog = new ChangeLog(); changeLog.SectionID = section.ID; changeLog.DateCreated = DateTime.Now; changeLog.DateDeleted = DAL.MaximumDateTime; changeLog.DateImported = DAL.MinimumDateTime; DAL.AddChangeLog(changeLog); } else { SessionVariables.SetErrorMessage("Section create failed"); } return(RedirectToAction(nameof(Index))); } SetUpSectionViewBags(section); return(View(section)); }
// GET: Role public async Task <IActionResult> Index() { User currentUser = SessionVariables.GetCurrentUser(HttpContext); if (currentUser != null && currentUser.Role != null && currentUser.Role.Roles.CanView) { List <Role> roles = DAL.GetRoles(); return(View(roles)); } else { SessionVariables.SetErrorMessage("You do not have permission to view roles"); return(RedirectToAction("Index", "Section")); } }
public async Task <IActionResult> DeleteConfirmed(int id) { User currentUser = SessionVariables.GetCurrentUser(HttpContext); if (currentUser != null && currentUser.Role != null && currentUser.Role.ScheduleTypes.CanDelete) { DAL.RemoveScheduleType(id); return(RedirectToAction(nameof(Index))); } else { SessionVariables.SetErrorMessage("You do not have permission to delete schedule types"); return(RedirectToAction("Index")); } }
public async Task <IActionResult> DeleteConfirmed(int id) { User currentUser = SessionVariables.GetCurrentUser(HttpContext); if (currentUser != null && currentUser.Role != null && currentUser.Role.Spreadsheets.CanDelete) { DAL.RemoveSpreadsheetVariables((int)id); return(RedirectToAction("Index")); } else { SessionVariables.SetErrorMessage("You do not have permission to delete spreadsheet details"); return(RedirectToAction("Index")); } }
// GET: SpreadsheetVariables public IActionResult Index() { User currentUser = SessionVariables.GetCurrentUser(HttpContext); if (currentUser != null && currentUser.Role != null && currentUser.Role.Spreadsheets.CanEdit) { List <SpreadsheetVariables> spreadsheetVariables = DAL.GetSpreadsheetVariablesList(); return(RedirectToAction("Edit", spreadsheetVariables[0])); } else { SessionVariables.SetErrorMessage("You do not have permission to edit spreadsheet details"); return(RedirectToAction("Index", "Section")); } }
// GET: SpreadsheetVariables/Create public IActionResult Create() { User currentUser = SessionVariables.GetCurrentUser(HttpContext); if (currentUser != null && currentUser.Role != null && currentUser.Role.Spreadsheets.CanAdd) { SpreadsheetVariables sv = new SpreadsheetVariables(); return(View(sv)); } else { SessionVariables.SetErrorMessage("You do not have permission to create spreadsheet details"); return(RedirectToAction("Index")); } }
// GET: Role/Create public IActionResult Create() { User currentUser = SessionVariables.GetCurrentUser(HttpContext); if (currentUser != null && currentUser.Role != null && currentUser.Role.Roles.CanAdd) { ViewData["RoleID"] = new SelectList(DAL.GetRoles(), "ID", "Name"); return(View()); } else { SessionVariables.SetErrorMessage("You do not have permission to create roles"); return(RedirectToAction("Index")); } }
public static string PassedCommand(string Data) { SessionVariables _SessionVariables = new SessionVariables(); // initialize the class. List <string> commandList = _SessionVariables.commandHistoryList; Functions.AppOnlyScope.Disposal.RunCleanup(); bool Command = Interpret(Data); if (ValidationResponse.CommandReturnedWasSuccessful && Command) { commandList.Add(Data); // Add recent command (successful) to list. SessionVariables.LastCommandDate = DateTime.Now.ToString(); // set date and time of last successful command CommandInputListener.TypePrompt(); ValidationResponse.ResetValidationResponse(); // Reset the Validation Response class objects. return(ValidationResponse.CommandReturnedWasSuccessful.ToString()); } if (!ValidationResponse.CommandReturnedWasSuccessful && Command) { WriteToScreen(Functions.AppOnlyScope.Status.CommandFailureMessage(ValidationResponse.ResponseFromCommandClass)); // Reset the Validation Response class objects. ValidationResponse.ResetValidationResponse(); return(ValidationResponse.CommandReturnedWasSuccessful.ToString()); } if (!Command) { ValidationResponse.ResponseFromCommandClass = "Command '" + Data + "' not recognized."; WriteToScreen(Functions.AppOnlyScope.Status.CommandFailureMessage(ValidationResponse.ResponseFromCommandClass)); // Reset the Validation Response class objects. ValidationResponse.ResetValidationResponse(); return(ValidationResponse.CommandReturnedWasSuccessful.ToString()); } else { commandList.Add(Data); SessionVariables.LastCommandDate = DateTime.Now.ToString(); // set date and time of last successful command Interpreter.CommandInputListener.TypePrompt(); Functions.AppOnlyScope.Disposal.RunCleanup(); return(null); } }
public IActionResult DeleteConfirmed(int id, [Bind("ID,Number,DepartmentComments,Notes,RequiresPermission,RequiresMoodle,CRN,DateArchived,DateCreated,StudentLimit," + "StartTime,EndTime,PartOfTermID,CourseID,ScheduleTypeID,PrimaryInstructorID,SectionFeeID,SecondaryInstructorID,RoomID,")] Section section) { Section sectionToDelete = DAL.GetSection(id); User currentUser = SessionVariables.GetCurrentUser(HttpContext); if (currentUser != null && currentUser.Role != null && currentUser.Role.Sections.CanDelete) { ChangeLog changeLog = DAL.GetChangeLogBySection(sectionToDelete); //checks if the section was created after the spreadsheet import changeLog.DateDeleted = DateTime.Now; sectionToDelete.DateDeleted = DateTime.Now; if (changeLog.DateCreated >= changeLog.DateImported) { //completely delete the section so it isn't put on the spreadsheet as it was created after the import List <InstructorToSection> instructorToSections = DAL.GetInstructorsBySectionID(id); foreach (InstructorToSection its in instructorToSections) { DAL.RemoveInstructorToSection(its.ID); } List <SectionDay> sectionDays = DAL.GetSectionDaysBySectionID(id); foreach (SectionDay sd in sectionDays) { DAL.RemoveSectionDay(sd.ID); } ChangeLog changeLogToDelete = DAL.GetChangeLogBySection(section); DAL.RemoveChangeLog(changeLogToDelete); DAL.RemoveSection(section); } int updatedChangelog = DAL.UpdateChangeLog(changeLog); int updatedSection = DAL.UpdateSection(sectionToDelete); if (updatedChangelog >= 0 && updatedSection >= 0) { SessionVariables.SetSuccessMessage("Section deleted"); } else { SessionVariables.SetErrorMessage("Section delete failed"); } return(RedirectToAction(nameof(Index))); } else { SessionVariables.SetErrorMessage("You do not have permission to delete sections"); return(RedirectToAction("Index")); } }