public IHttpActionResult AddEntry(Entry entry) { // To call this method: // DEV: http://localhost:52051/Api/AttendanceEntry/AddEntry // PROD: http://ktkaciovaite-001-site1.ctempurl.com/Api/AttendanceEntry/AddEntry var studentDataService = new StudentDataService(); var students = studentDataService.GetAll(); if (students.Exists(x => x.CardNumber == entry.CardNumber)) { var attendanceEntryDataService = new AttendanceEntryDataService(); var attendanceEntry = new AttendanceEntry() { Time = DateTime.Now, CardNumber = entry.CardNumber }; attendanceEntryDataService.Add(attendanceEntry); var updateAttendanceThread = new Thread(() => UpdateAttendance(attendanceEntry.Time, attendanceEntry.CardNumber)); updateAttendanceThread.Start(); return(Ok("Pažymėta")); } return(Ok("Kortelės nėra sistemoje")); }
public async Task Init() { Group.SetSpecialtyService(SpecialtyDataService); Student.SetService(GroupDataService); Group.SetStudentService(StudentDataService); if (SettingsManager.GetBool("LocalMode")) { LoadExamples(); return; } try { await SpecialtyDataService.Refresh(); await GroupDataService.Refresh(); await StudentDataService.Refresh(); } catch (Exception e) { MessageBox.Show($"Не удалось подключиться к серверу!\n{e.Message}"); Environment.Exit(-1); } }
public StudentController() { ViewBag.Today = new DateTime(2018, 4, 16); _studentDataService = new StudentDataService(); _lectureDataService = new LectureDataService(); _groupDataService = new GroupDataService(); _attendanceDataService = new AttendanceDataService(); }
public async Task <IActionResult> SubmitAssignment(SubmissionInputViewModel input) { StudentDataService studentDataService = new StudentDataService(dbContext); Student student = studentDataService.GetStudentById(input.UserId); bool hasAccess = false; foreach (StudentClass studentClass in student.StudentClasses) { if (studentClass.ClassId == input.ClassId) { hasAccess = true; } } if (ModelState.IsValid && hasAccess) { Submission submission = new Submission(); submission.Input.SourceCode = input.SourceCode; submission.Input.Language = input.Language; submission.AssignmentId = input.AssignmentId; submission.UserId = input.UserId; submission.SubmissionTime = DateTime.Now; SubmissionDataService submissionService = new SubmissionDataService(dbContext); submissionService.AddSubmission(submission); await dbContext.SaveChangesAsync(); // SubmissionId now set on local submission AssignmentDataService assignmentDataService = new AssignmentDataService(dbContext); Assignment assignment = assignmentDataService.GetAssignmentById(submission.AssignmentId); assignment.Submissions.Add(submission); GraderMethod.GradeSubmission(submission, dbContext); submission.Output.Runtime = assignment.TimeLimit; if (submission.Compile()) { submission.RunAndCompare(); submission.GradeTestCases(); submission.MaxRunTime(); } dbContext.Submissions.Update(submission); dbContext.Assignments.Update(assignment); await dbContext.SaveChangesAsync(); submission.deleteJunkFiles(); return(RedirectToAction("SubmissionDetails", "Assignment", new { id = submission.SubmissionId })); } return(RedirectToAction("UnAuthorized", "Home")); }
public IActionResult StudentHome(User user) { StudentDataService studentDataService = new StudentDataService(dbContext); student = studentDataService.GetStudentByUsername(UserManager.GetUserName(User)); ViewData["Id"] = student.Id; StudentClassDataService studentClassDataService = new StudentClassDataService(dbContext); var classes = studentClassDataService.GetClassesByStudentId(student.Id); return(View(classes)); }
public IActionResult ViewAssignments(int classId) { AssignmentDataService assignmentDataService = new AssignmentDataService(dbContext); IEnumerable <Assignment> assignments = assignmentDataService.GetAssignmentsByClassId(classId).Reverse(); StudentDataService studentDataService = new StudentDataService(dbContext); student = studentDataService.GetStudentByUsername(UserManager.GetUserName(User)); ViewData.Add("StudentId", student.Id); return(View(assignments)); }
public void OnGet() { StudentDataService IfaceStudent = new StudentDataService(); TopFiveStudent = IfaceStudent.GetTopFiveScoringStudent(); if (TopFiveStudent == null) { DisplayMessage = "Error Obtaining Student Records from the Database."; } else { DisplayMessage = "Top Five Overall Students"; } }
private void VerwijderStudent() { MessageBoxResult result = MessageBox.Show("Bent u zeker dat u deze student wilt verwijderen ?", "Student verwijderen", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes && selectedStudent != null) { StudentDataService ds = new StudentDataService(); ds.VerwijderStudent(SelectedStudent); LeesGegevens(); Messenger.Default.Send <UpdateFinishedMessage>(new UpdateFinishedMessage("Completed")); } }
static void Main(string[] args) { StudentDataService studentData = new StudentDataService(); var data = studentData.GetAllRecords(); var table = data.Tables[0]; foreach (DataRow row in table.Rows) { foreach (DataColumn column in table.Columns) { Console.WriteLine(column.ColumnName + ": " + row[column.ColumnName]); } Console.WriteLine("=================================="); } }
public void OnGet() { StudentDataService sds = new StudentDataService(); (HousePoints, houses_filled) = sds.GetHousePoints(); if (HousePoints == null) { DisplayMessage = "Error Obtaining Student Records from the Database."; } else { DisplayMessage = "Current Point Totals for Each House"; } }
public IActionResult ViewAllSubmissions(int assignmentId, int studentId) { AssignmentDataService assignmentDataService = new AssignmentDataService(dbContext); IEnumerable <Submission> submissions = assignmentDataService.GetStudentSubmissionsOnAssignment(studentId, assignmentId).Reverse(); var assignmentName = assignmentDataService.GetAssignmentById(assignmentId).Name; ViewData["AssignmentName"] = assignmentName; StudentDataService studentDataService = new StudentDataService(dbContext); var student = studentDataService.GetStudentById(studentId); var name = student.FirstName + " " + student.LastName; ViewData["StudentName"] = name; return(View(submissions)); }
public async Task <IActionResult> LeaveClass(bool confirm, int classId) { StudentClassDataService studentClassDataService = new StudentClassDataService(dbContext); StudentDataService studentDataService = new StudentDataService(dbContext); ClassDataService classDataService = new ClassDataService(dbContext); student = studentDataService.GetStudentByUsername(UserManager.GetUserName(User)); Class c = classDataService.GetClassById(classId); studentClassDataService.RemoveStudentClass(student, c); await dbContext.SaveChangesAsync(); return(RedirectToAction("StudentHome", "Student")); }
/* * **************************************** My changes START here ************************************************ */ //private connection = null; //private SqlCommand command; // private bool insertReady; /* * <summary> * Updates student records in the Database * </summary> * <returns></returns> */ public void Update() { IDbTransaction transaction = null; try { // Create a transaction to ensure all child properties are inserted along with the student record transaction = DataServiceBase.BeginTransaction(); //Create a Student Data Service object with the transction object StudentDataService dataService = new StudentDataService(transaction); //Call the insert method dataService.Update(_studentID, _last4Ssn, _firstName, _lastName, _phoneCell, _phoneDay, _phoneEvening, _email, _address, _city, _state, _zipcode, _gpa, _graduationDate); // Update the Internship Requirement Child Object with the transaction _internshipRequirement.Update(_studentID, transaction); // Update employer if exists if (_employer != null) { _employer.Update(_studentID, transaction); } // Commit the Transaction, ensures all child properites are updated along with the studento Objects transaction.Commit(); } /*catch * { * // Remove all records from the database if an error occurs * transaction.Rollback(); * throw; * }*/ catch (Exception ex) { // Remove all records from the database if an error occurs transaction.Rollback(); // throw new System.Exception(ex.Message); throw new System.Exception("Exception: '" + ex.Message + "' occured while updating data! All transactions have been removed from database!"); } }
public void GetStudentByIdAsync_BasicTest() { StudentDataService srv = new StudentDataService(); Task<JArray> task = srv.GetStudentByIdAsync(TestProperties.AccessToken, student1); task.Wait(); JArray result = task.Result; // make sure we have results Assert.IsTrue(result.HasValues); // get the first student in the result set JToken firstStudent = result.First; Debug.WriteLine(firstStudent.ToString()); // verify we got an id back JToken id = firstStudent.SelectToken("id", false); Assert.IsTrue(!string.IsNullOrEmpty(id.ToString())); }
/// <summary> /// Loads a populated student Object from Database /// </summary> /// <param name="studentId"></param> /// <returns></returns> public static Student Load(string studentId) { try { StudentDataService dataService = new StudentDataService(); DataSet ds = dataService.Load(studentId); Student objStudent = new Student(); return(objStudent.MapData(ds) ? objStudent : null); } catch (Exception ex) { // throw new System.Exception(ex.Message); throw new System.Exception("Exception: '" + ex.Message + "' occured while loading students!"); } }
private void UpdateAttendance(DateTime date, string cardNumber) { var currentTime = new DateTime(2018, 4, 16, 14, 27, 52); var studentDataService = new StudentDataService(); var student = studentDataService.GetByCardNumber(cardNumber); var groupDataService = new GroupDataService(); var group = groupDataService.GetByStudent(student.Id); var lectureDataService = new LectureDataService(); var lectures = lectureDataService.GetByGroupId(group.Id); var lectureId = -1; foreach (var lecture in lectures) { if (lecture.Occurences.FirstOrDefault(x => x.Date.ToShortDateString() == currentTime.ToShortDateString()) != null && lecture.LectureTime.LectureStart.AddMinutes(-5).TimeOfDay <= currentTime.TimeOfDay && lecture.LectureTime.LectureEnd.AddMinutes(5).TimeOfDay >= currentTime.TimeOfDay) { lectureId = lecture.Id; break; } } if (lectureId != -1) { var attendanceDataService = new AttendanceDataService(); var attendance = attendanceDataService.GetStudentAttendance(student.Id, lectureId); var dateString = currentTime.ToString("yyyy-MM-dd"); if (!attendance.AttendedLectures.Contains(dateString)) { attendance.AttendedLectures += dateString + ","; } attendanceDataService.UpdateLectures(attendance); } }
private void UpdateStudent() { StudentDataService ds = new StudentDataService(); Student studentMetUpdates = SelectedStudent; if (!String.IsNullOrWhiteSpace(Achternaam)) { studentMetUpdates.Achternaam = Achternaam; } if (!String.IsNullOrWhiteSpace(Voornaam)) { studentMetUpdates.Voornaam = Voornaam; } if (!String.IsNullOrWhiteSpace(Geslacht)) { studentMetUpdates.Geslacht = Geslacht; } if (!String.IsNullOrWhiteSpace(Klas)) { studentMetUpdates.Klas = Klas; } if (!String.IsNullOrWhiteSpace(TelefoonNummer)) { studentMetUpdates.TelefoonNummer = TelefoonNummer; } if (!String.IsNullOrWhiteSpace(EmailAdres)) { studentMetUpdates.EmailAdres = EmailAdres; } ds.UpdateStudent(studentMetUpdates); Messenger.Default.Send <UpdateFinishedMessage>(new UpdateFinishedMessage("Completed")); Achternaam = string.Empty; Voornaam = string.Empty; Geslacht = string.Empty; Klas = string.Empty; TelefoonNummer = string.Empty; EmailAdres = string.Empty; }
/// <summary> /// Loads all Students From the Database /// </summary> /// <returns></returns> public static StudentCollection Load() { try { //Create a Student Data Service Object StudentDataService dataService = new StudentDataService(); // Call the GETAll() method which returns a populated DataSet DataSet ds = dataService.GetAll(); StudentCollection obj = new StudentCollection(); //Create Student Objects from DataSet and add the objects to the collection obj.MapObjects(ds); // Return the populated collection return(obj); } catch (Exception ex) { throw new System.Exception(ex.Message); } }
public async Task <IActionResult> JoinClass(string ClassKey) { ClassDataService classDataService = new ClassDataService(dbContext); StudentDataService studentDataService = new StudentDataService(dbContext); student = studentDataService.GetStudentByUsername(UserManager.GetUserName(User)); Class c = classDataService.GetClassByKey(ClassKey); if (c != null) { StudentClassDataService studentClassDataService = new StudentClassDataService(dbContext); bool inClass = studentClassDataService.InClass(student, c); if (!inClass) { studentClassDataService.AddStudentClass(student, c); await dbContext.SaveChangesAsync(); } } return(RedirectToAction("StudentHome", "Student")); }
public MainForm() { _service = new StudentDataService(); InitializeComponent(); }
private void InitValues() { studentDataService = new StudentDataService(); Students = new ObservableCollection <Student>(studentDataService.GetAll()); }
private void LeesGegevens() { StudentDataService ds = new StudentDataService(); Studenten = new ObservableCollection <Student>(ds.GetStudenten()); }
public static void SetStudentService(StudentDataService service) { _studentDataService = service; }
private void InsertStudent() { DialogService dialogservice = new DialogService(); var picker = geboortedatum; StudentDataService ds = new StudentDataService(); Student nieuweStudent = new Student(); nieuweStudent.Achternaam = achternaam; nieuweStudent.Voornaam = voornaam; nieuweStudent.Klas = klas; nieuweStudent.Geboortedatum = picker.Date; nieuweStudent.Geslacht = geslacht; nieuweStudent.TelefoonNummer = telefoonNummer; nieuweStudent.EmailAdres = emailAdres; Student bestaandeStudent = new Student(); bestaandeStudent = ds.GetStudent(nieuweStudent.Voornaam, nieuweStudent.Achternaam); if (bestaandeStudent != null) { if (nieuweStudent.Voornaam == bestaandeStudent.Voornaam && nieuweStudent.Achternaam == bestaandeStudent.Achternaam && picker.Date.Year > 1900 && picker.Date < DateTime.Now) { MessageBoxResult resultaat = MessageBox.Show( "Een student met deze naam is al gevonden in het systeem, bent u zeker dat u deze student wilt aanmaken ?", "Dubbel gevonden", MessageBoxButton.YesNo); if (resultaat == MessageBoxResult.Yes) { ds.InsertStudent(nieuweStudent); } } else { if (picker.Date.Year > 1900 && picker.Date < DateTime.Now) { ds.InsertStudent(nieuweStudent); } else { MessageBox.Show( "U probeert een student aan te maken met een ongeldige geboortedatum, probeer nog eens", "Ongeldige geboortedatum", MessageBoxButton.OK); } } } else { if (picker.Date.Year > 1900 && picker.Date < DateTime.Now) { ds.InsertStudent(nieuweStudent); } else { MessageBox.Show( "U probeert een student aan te maken met een ongeldige geboortedatum, probeer nog eens", "Ongeldige geboortedatum", MessageBoxButton.OK); } } Messenger.Default.Send <UpdateFinishedMessage>(new UpdateFinishedMessage("Completed")); }
protected override async Task OnInitializedAsync() { Students = await StudentDataService.GetAllStudentsAsync(); }
public Student[] GetStudent() { this.studentDataService = new StudentDataService(); return(this.studentDataService.GetStudents().ToArray()); }
public DataCoordinator() { SpecialtyDataService = new SpecialtyDataService(); GroupDataService = new GroupDataService(); StudentDataService = new StudentDataService(); }
// ProcessSwipe handles the workflow for a student swiping their id // card at the Learning Factory. public String ProcessSwipe(String studentId) { String message = ""; StudentDataService sds = new StudentDataService(); AttendanceDataService ads = new AttendanceDataService(); Student student = sds.GetStudent(studentId); if (student == null) // new student swipes id card { String house_assignment = HouseAssignment(); Console.WriteLine(house_assignment); if (sds.CreateStudent(studentId, house_assignment) && ads.CreateAttendance(studentId)) { message = "Welcome to the Learning Factory! " + "Your house assignment is " + house_assignment + ". Please see our FAQ page if you have questions about this house " + "assignment or the point tracking process."; } else { message = "An error occurred when processing your card. Please try again or " + "find a staff member if error continues to occur."; } } else // existing student swipes id card { Attendance attendance = ads.GetLatestAttendance(studentId); if ((attendance.check_in != null) && (attendance.check_out != null)) { if (ads.CreateAttendance(studentId)) { message = "Hi " + student.first_name + ", you have signed " + "into the Learning Factory. You currently have " + student.total_points + " points. Have fun building!"; } else { message = "An error occurred when processing your card. Please try again or " + "find a staff member if error continues to occur."; } } else { if (ads.UpdateSession(attendance.session_id.ToString())) { message = "You have been signed out. You received " + ads.GetLatestAttendance(studentId).session_points + " points for this visit, " + " and you have " + sds.GetStudent(studentId).total_points + " points " + "total. Thanks for coming " + student.first_name + "!"; } else { message = "An error occurred when processing your card. Please try again or " + "find a staff member if error continues to occur."; } } } return(message); }
// Activates when Submit button on admin page is clicked. public IActionResult OnPostSubmit() { AdminDataService IfaceAdmin = new AdminDataService(); bool success = true; bool defaultCase = false; TempData.Keep("Action"); TempData.Keep("Actiontype"); // Basic error checking, Need to reset TempData as well if (UID == "" || UID == null) { DisplayMessage = $"Error Occurred due to ID/Prize Field Empty."; return(Page()); } if (Action == "" || Action == null) { DisplayMessage = $"Error Occurred due to Action not specified."; return(Page()); } if ((ChangeValue <= 0) && !(Action == "AddAccount" || Action == "CheckBalance" || Action == "DeletePrize" || Action == "DeleteAccount")) { DisplayMessage = $"Error Occurred due Value <= 0. Please enter a valid number."; PointMessage = $"Could not Complete Action, enter a positive number."; return(Page()); } if (Actiontype == "User") { Student student = new Student(); StudentDataService IfaceStudent = new StudentDataService(); if ((student = IfaceStudent.GetStudentCampusId(UID)) != null) { switch (Action) { case "AddAccount": success = IfaceAdmin.AddAccount(UID); PointMessage = "Student account added successfully."; break; case "CheckBalance": PointMessage = student.total_points.ToString(); break; case "IncreasePoint": success = IfaceAdmin.IncrementPoints(UID, ChangeValue); PointMessage = $" {student.first_name} {student.last_name} has {IfaceAdmin.CheckPoints(UID).ToString()} Points"; break; case "DecreasePoint": success = IfaceAdmin.DecrementPoints(UID, ChangeValue); break; case "SetPoint": success = IfaceAdmin.SetPoints(UID, ChangeValue); break; case "DeleteAccount": success = IfaceStudent.DeleteStudent(student.campus_id); break; default: DisplayMessage = $"Error Occurred due to Action variable undefined."; PointMessage = $"Could not Complete Action"; defaultCase = true; success = false; break; } if (success) { if (Action != "DeleteAccount") { PointMessage = $" {student.first_name} {student.last_name} has {IfaceAdmin.CheckPoints(UID).ToString()} Points"; } DisplayMessage = $"Transaction success with {student.first_name} {student.last_name}"; } else if (defaultCase) { // do Nothing } else { DisplayMessage = $"Action Failed due to database operation issue!"; PointMessage = $"Could not Complete Action"; } } else { switch (Action) { case "AddAccount": success = IfaceAdmin.AddAccount(UID); PointMessage = "Student account added successfully."; break; default: DisplayMessage = $"Error Occurred due to Student not found."; break; } } } else if (Actiontype == "Prize") { switch (Action) { case "SetPrize": success = IfaceAdmin.UpdatePrizePoints(UID, ChangeValue); break; case "AddPrize": success = IfaceAdmin.AddPrize(UID, ChangeValue); break; case "DeletePrize": success = IfaceAdmin.DeletePrize(UID); break; default: DisplayMessage = $"Error Occurred due to Action variable undefined."; defaultCase = true; success = false; break; } PrizeIdList = IfaceAdmin.GetPrizesId(); PrizeNameList = IfaceAdmin.GetAllPrizesName(); PrizeValueList = IfaceAdmin.GetAllPrizesValue(); if (success) { PointMessage = $"Transaction Success with Prize {UID}"; } else if (defaultCase) { //Do Nothing } else { DisplayMessage = $"Transaction Failed due to database operation issue! Check if Prize is valid."; } } else { DisplayMessage = $"Action Type Undefinied!"; } return(Page()); }