diff --git a/LangLang/Core/Controller/EnrollmentRequestController.cs b/LangLang/Core/Controller/EnrollmentRequestController.cs index c48674df..a40f2c78 100644 --- a/LangLang/Core/Controller/EnrollmentRequestController.cs +++ b/LangLang/Core/Controller/EnrollmentRequestController.cs @@ -1,9 +1,7 @@ - -using LangLang.Core.Model.DAO; +using LangLang.Core.Model.DAO; using System.Collections.Generic; using LangLang.Core.Model; using LangLang.Core.Observer; -using System.Linq; namespace LangLang.Core.Controller { @@ -16,7 +14,7 @@ public EnrollmentRequestController() _enrollmentRequests = new EnrollmentRequestDAO(); } - public Dictionary GetAll() + public List GetAll() { return _enrollmentRequests.GetAllEnrollmentRequests(); } @@ -45,5 +43,23 @@ public List GetStudentRequests(int studentId) { return _enrollmentRequests.GetStudentRequests(studentId); } + + public bool CancelRequest(EnrollmentRequest enrollmentRequest, CourseController courseController) + { + Course course = courseController.GetById(enrollmentRequest.CourseId); + return _enrollmentRequests.CancelRequest(enrollmentRequest, course); + } + + // this method is invoked when the tutor approves the request for the student + public void PauseRequests(int studentId, EnrollmentRequest enrollmentRequest) + { + _enrollmentRequests.PauseRequests(studentId, enrollmentRequest.Id); + } + + // this method is invoked when the student complete/withdrawal_from course + public void ResumePausedRequests(int studentId) + { + _enrollmentRequests.ResumePausedRequests(studentId); + } } } \ No newline at end of file diff --git a/LangLang/Core/Controller/StudentController.cs b/LangLang/Core/Controller/StudentController.cs index 798e34e6..f6a43fdb 100644 --- a/LangLang/Core/Controller/StudentController.cs +++ b/LangLang/Core/Controller/StudentController.cs @@ -41,7 +41,6 @@ public void Subscribe(IObserver observer) _students.Subscribe(observer); } - public List GetAvailableCourses(CourseController courseController) { return _students.GetAvailableCourses(courseController); @@ -52,9 +51,14 @@ public List GetAvailableExamSlots(Student student, CourseController co return _students.GetAvailableExamSlots(student, courseController, examSlotController, enrollmentRequestController); } - public bool CanModifyInfo(int studentId, EnrollmentRequestController erc) + public bool CanModifyInfo(int studentId, EnrollmentRequestController erController, CourseController courseController) { - return _students.CanModifyInfo(studentId, erc); + return _students.CanModifyInfo(studentId, erController, courseController); + } + + public bool CanRequestEnroll(int id, EnrollmentRequestController erController, CourseController courseController) + { + return _students.CanRequestEnroll(id, erController, courseController); } public List SearchExamSlotsByStudent(ExamSlotController examSlotController, CourseController courseController, EnrollmentRequestController enrollmentRequestController, int studentId, DateTime examDate, string courseLanguage, LanguageLevel? languageLevel) @@ -69,5 +73,6 @@ public List SearchCoursesByStudent(CourseController courseController, st List filteredCourses = courseController.SearchCourses(availableCourses, language, level, startDate, duration, online); return filteredCourses; } + } } diff --git a/LangLang/Core/Model/DAO/EnrollmentRequestDAO.cs b/LangLang/Core/Model/DAO/EnrollmentRequestDAO.cs index cf26c45a..725d1e73 100644 --- a/LangLang/Core/Model/DAO/EnrollmentRequestDAO.cs +++ b/LangLang/Core/Model/DAO/EnrollmentRequestDAO.cs @@ -1,5 +1,7 @@ -using LangLang.Core.Observer; +using LangLang.Core.Model.Enums; +using LangLang.Core.Observer; using LangLang.Core.Repository; +using System; using System.Collections.Generic; using System.Linq; @@ -18,7 +20,7 @@ public EnrollmentRequestDAO() private int GenerateId() { if (_enrollmentRequests.Count == 0) return 0; - return _enrollmentRequests.Count + 1; + return _enrollmentRequests.Keys.Max() + 1; } public EnrollmentRequest? GetEnrollmentRequestById(int id) @@ -26,9 +28,9 @@ private int GenerateId() return _enrollmentRequests[id]; } - public Dictionary GetAllEnrollmentRequests() + public List GetAllEnrollmentRequests() { - return _enrollmentRequests; + return _enrollmentRequests.Values.ToList(); } public EnrollmentRequest Add(EnrollmentRequest enrollmentRequest) @@ -42,11 +44,12 @@ public EnrollmentRequest Add(EnrollmentRequest enrollmentRequest) public EnrollmentRequest? Update(EnrollmentRequest enrollmentRequest) { - EnrollmentRequest oldRequest = GetEnrollmentRequestById(enrollmentRequest.Id); + EnrollmentRequest? oldRequest = GetEnrollmentRequestById(enrollmentRequest.Id); if (oldRequest == null) return null; - oldRequest.Status = enrollmentRequest.Status; - + oldRequest.UpdateStatus(enrollmentRequest.Status); + oldRequest.IsCanceled = enrollmentRequest.IsCanceled; + oldRequest.LastModifiedTimestamp = DateTime.Now; _repository.Save(_enrollmentRequests); NotifyObservers(); return oldRequest; @@ -54,7 +57,7 @@ public EnrollmentRequest Add(EnrollmentRequest enrollmentRequest) public EnrollmentRequest? Remove(int id) { - EnrollmentRequest enrollmentRequest = GetEnrollmentRequestById(id); + EnrollmentRequest? enrollmentRequest = GetEnrollmentRequestById(id); if (enrollmentRequest == null) return null; _enrollmentRequests.Remove(enrollmentRequest.Id); @@ -65,13 +68,48 @@ public EnrollmentRequest Add(EnrollmentRequest enrollmentRequest) public List GetStudentRequests(int studentId) { - Dictionary studentRequests = new(); - foreach (EnrollmentRequest enrollmentRequest in GetAllEnrollmentRequests().Values) + List studentRequests = new(); + foreach (EnrollmentRequest enrollmentRequest in GetAllEnrollmentRequests()) { - if (enrollmentRequest.StudentId == studentId) studentRequests.Add(enrollmentRequest.Id, enrollmentRequest); + if (enrollmentRequest.StudentId == studentId) studentRequests.Add(enrollmentRequest); + } + return studentRequests; + } + + // returns true if the cancellation was successful, otherwise false + public bool CancelRequest(EnrollmentRequest enrollmentRequest, Course course) + { + if (course.StartDateTime.Date - DateTime.Now.Date <= TimeSpan.FromDays(7)) + return false; // course start date must be at least 7 days away + + enrollmentRequest.IsCanceled = true; + return true; + } + public void PauseRequests(int studentId, int acceptedRequestId) + { + var studentRequests = GetStudentRequests(studentId); + foreach (EnrollmentRequest er in studentRequests) + { + if (er.Id == acceptedRequestId) + { + er.UpdateStatus(Status.Accepted); + } + else if (er.Status == Status.Pending && !er.IsCanceled) + { + er.UpdateStatus(Status.Paused); + } } - return studentRequests.Values.ToList(); } + + public void ResumePausedRequests(int studentId) + { + var studentRequests = GetStudentRequests(studentId); + foreach (EnrollmentRequest request in studentRequests) + { + if (request.Status == Status.Paused) request.UpdateStatus(Status.Pending); + } + } + } } diff --git a/LangLang/Core/Model/DAO/StudentDAO.cs b/LangLang/Core/Model/DAO/StudentDAO.cs index 91f0925e..4228f8e8 100644 --- a/LangLang/Core/Model/DAO/StudentDAO.cs +++ b/LangLang/Core/Model/DAO/StudentDAO.cs @@ -4,20 +4,16 @@ using LangLang.Core.Observer; using LangLang.Core.Controller; using LangLang.Core.Model.Enums; +using System; namespace LangLang.Core.Model.DAO { - /** - * This class encapsulates a list of Student objects and provides methods - * for adding, updating, deleting, and retrieving Student objects. - * Additionally, this class uses Repository for loading and saving objects. - **/ public class StudentDAO : Subject { private readonly Dictionary _students; private readonly Repository _repository; - - + + public StudentDAO() { _repository = new Repository("students.csv"); @@ -69,7 +65,7 @@ public Student AddStudent(Student student) NotifyObservers(); return oldStudent; } - + public Student? RemoveStudent(int id, EnrollmentRequestController enrollmentRequestController) { Student student = GetStudentById(id); @@ -130,15 +126,28 @@ public List GetAvailableExamSlots(Student student, CourseController co return availableExamSlots; } - public bool CanModifyInfo(int studentId, EnrollmentRequestController erc) + public bool CanModifyInfo(int studentId, EnrollmentRequestController erController, CourseController courseController) { - List studentRequests = erc.GetStudentRequests(studentId); - foreach (EnrollmentRequest request in studentRequests) - { - if (request.Status == Status.Accepted) return false; // TODO: Check if the course is incomplete upon implementing functionality in courseController. + // can modify - student is not currently enrolled in any course and has not applied for any exams + return (CanRequestEnroll(studentId, erController, courseController) && !HasRegisteredForExam()); + } + public bool CanRequestEnroll(int id, EnrollmentRequestController erController, CourseController courseController) + { + foreach (EnrollmentRequest er in erController.GetStudentRequests(id)) + { + if (er.Status == Status.Accepted && !er.IsCanceled) + { + if (!courseController.IsCompleted(er.Id)) return false; + } } return true; } + + public bool HasRegisteredForExam() + { + // TODO: Implement this method once the exam application class is implemented. + return false; + } } } diff --git a/LangLang/Core/Model/EnrollmentRequest.cs b/LangLang/Core/Model/EnrollmentRequest.cs index bb80c700..f09f0f4b 100644 --- a/LangLang/Core/Model/EnrollmentRequest.cs +++ b/LangLang/Core/Model/EnrollmentRequest.cs @@ -9,19 +9,28 @@ public class EnrollmentRequest : ISerializable public int Id { get; set; } public int StudentId { get; set; } public int CourseId { get; set; } - public Status Status { get; set; } + public Status Status { get; private set; } public DateTime RequestSentAt { get; set; } public DateTime LastModifiedTimestamp { get; set; } + public bool IsCanceled { get; set; } public EnrollmentRequest() { } - public EnrollmentRequest(int id, int studentId, int courseId, Status erStatus, DateTime requestSentAt) + public EnrollmentRequest(int id, int studentId, int courseId, Status status, DateTime requestSentAt) { Id = id; StudentId = studentId; CourseId = courseId; - Status = erStatus; + Status = status; RequestSentAt = requestSentAt; + LastModifiedTimestamp = requestSentAt; //Later this will refer to the date of acceptance/rejection/cancellation + IsCanceled = false; // this refers whether the student has canceled request before the course has started + } + + public void UpdateStatus(Status status) + { + Status = status; + LastModifiedTimestamp = DateTime.Now; } public void FromCSV(string[] values) @@ -38,6 +47,7 @@ public void FromCSV(string[] values) StudentId = int.Parse(values[1]); CourseId = int.Parse(values[2]); Status = (Status)Enum.Parse(typeof(Status), values[3]); + IsCanceled = bool.Parse(values[6]); } public string[] ToCSV() @@ -48,7 +58,8 @@ public string[] ToCSV() CourseId.ToString(), Status.ToString(), RequestSentAt.ToString("yyyy-MM-dd"), - LastModifiedTimestamp.ToString("yyyy-MM-dd") + LastModifiedTimestamp.ToString("yyyy-MM-dd"), + IsCanceled.ToString() }; } } diff --git a/LangLang/Core/Model/Enums/Status.cs b/LangLang/Core/Model/Enums/Status.cs index d511cbc6..4478fac5 100644 --- a/LangLang/Core/Model/Enums/Status.cs +++ b/LangLang/Core/Model/Enums/Status.cs @@ -5,6 +5,7 @@ public enum Status { Pending, Accepted, - Rejected + Rejected, + Paused } } diff --git a/LangLang/Core/Model/ExamSlot.cs b/LangLang/Core/Model/ExamSlot.cs index 436f202a..c7e31314 100644 --- a/LangLang/Core/Model/ExamSlot.cs +++ b/LangLang/Core/Model/ExamSlot.cs @@ -1,104 +1,56 @@ using LangLang.Core.Repository.Serialization; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace LangLang.Core.Model { - public class ExamSlot: ISerializable + public class ExamSlot: ISerializable, Overlapable { - // Private attributes - private int _id; - private int _courseId; - private int _maxStudents; - private DateTime _examDateTime; - private int _numberOfStudents; + public int Id { get; set; } + public string Language { get; set; } + public LanguageLevel Level { get; set; } + public int TutorId { get; set; } + public TimeSlot TimeSlot { get; set; } + public int MaxStudents { get; set; } + public bool ApplicationPossible { get; set; } - // Public properties - public int Id - { - get { return _id; } - set { _id = value; } - } - - public int CourseId - { - get { return _courseId; } - set { _courseId = value; } - } - - public int MaxStudents - { - get { return _maxStudents; } - set { _maxStudents = value; } - } - - public DateTime ExamDateTime - { - get { return _examDateTime; } - set { _examDateTime = value; } - } + // NOTE: if possible don't save number of registeredStudents, ask the database. If not, then add attribute. + - public int NumberOfStudents + public ExamSlot(int id, string language, LanguageLevel level, TimeSlot timeSlot, int maxStudents, int tutorId, bool applicationPossible) { - get { return _numberOfStudents; } - set { _numberOfStudents = value; } - } - - // Constructor - public ExamSlot(int id, int courseId, int maxStudents, DateTime examDateTime, int numberOfStudents) - { - _id = id; - _courseId = courseId; - _maxStudents = maxStudents; - _examDateTime = examDateTime; - _numberOfStudents = numberOfStudents; - } - - public ExamSlot(int id, int courseId, int maxStudents, DateTime examDateTime) - { - _id = id; - _courseId = courseId; - _maxStudents = maxStudents; - _examDateTime = examDateTime; - _numberOfStudents = 0; + Id = id; + Language = language; + Level = Level; + TutorId = tutorId; + TimeSlot = timeSlot; + MaxStudents = maxStudents; + ApplicationPossible = applicationPossible; } public ExamSlot() { } - // Methods - - // Method to display information about the exam slot - public override string ToString() - { - return $"ID: {_id} | Course: {_courseId.ToString()} | Max Students: {_maxStudents} | Exam Date and Time: {_examDateTime} | Number of Students: {_numberOfStudents}"; - } - - // Method to convert object to CSV format - //returns array of strings representing attributes of ExamSlot object in string form public string[] ToCSV() { - string[] csvValues = - { - _id.ToString(), - _courseId.ToString(), - _maxStudents.ToString(), - _examDateTime.ToString(), - _numberOfStudents.ToString() - }; - return csvValues; + return new string[] { + Id.ToString(), + Language, + Level.ToString(), + TutorId.ToString(), + // TODO: add serialization for timeSlot when implemented + MaxStudents.ToString(), + ApplicationPossible.ToString() + }; } - // Method to make object from CSV data - //takes array of strings representing ExamSlot object values and sets attributes of object to that values + public void FromCSV(string[] values) { - _id = int.Parse(values[0]); - _courseId = int.Parse(values[1]); - _maxStudents = int.Parse(values[2]); - _examDateTime = DateTime.Parse(values[3]); - _numberOfStudents = int.Parse(values[4]); + Id = int.Parse(values[0]); + Language = values[1]; + Level = (LanguageLevel)Enum.Parse(typeof(LanguageLevel), values[2]); + TutorId = int.Parse(values[3]); + // TODO: add deserialization for timeSlot when implemented + MaxStudents = int.Parse(values[6]); + ApplicationPossible = bool.Parse(values[7]); } } } diff --git a/LangLang/Core/Model/Overlapable.cs b/LangLang/Core/Model/Overlapable.cs new file mode 100644 index 00000000..96a19ac1 --- /dev/null +++ b/LangLang/Core/Model/Overlapable.cs @@ -0,0 +1,8 @@ + +namespace LangLang.Core.Model +{ + public interface Overlapable + { + // TODO: implement + } +} diff --git a/LangLang/Core/Model/TimeSlot.cs b/LangLang/Core/Model/TimeSlot.cs new file mode 100644 index 00000000..1dd1aad0 --- /dev/null +++ b/LangLang/Core/Model/TimeSlot.cs @@ -0,0 +1,32 @@ +using System; +using System.Runtime.Serialization; + +namespace LangLang.Core.Model +{ + public class TimeSlot + { + // NOTE: Adapt as needed during implementation + public int Duration { get; set; } + public DateTime Time { get; set; } + + public TimeSlot(int duration, DateTime time) + { + Duration = duration; + Time = time; + } + + public bool OverlappsWith(TimeSlot timeSlot) + { + // TODO: Implement + return false; + } + + public bool IsInFuture() + { + // TODO: Implement + return false; + } + + // TODO: Add serialization methods + } +} diff --git a/LangLang/DTO/CourseDTO.cs b/LangLang/DTO/CourseDTO.cs index a12c5d9b..fb050808 100644 --- a/LangLang/DTO/CourseDTO.cs +++ b/LangLang/DTO/CourseDTO.cs @@ -25,7 +25,7 @@ public class CourseDTO : INotifyPropertyChanged, IDataErrorInfo private List days; private bool online; private int maxStudents; - private DateTime startDateTime; + private DateTime startDate; private bool createdByDirector; private string time; private bool mon; @@ -143,18 +143,18 @@ public string Time } } - public DateTime StartDateTime + public DateTime StartDate { get { - return startDateTime; + return startDate; } set { - if (value != startDateTime) + if (value != startDate) { - startDateTime = value; - OnPropertyChanged("StartDateTime"); + startDate = value; + OnPropertyChanged("StartDate"); } } } @@ -294,10 +294,10 @@ public string this[string columnName] if (timeParts.Length != 2) return "Time format must be HH:mm"; else return ""; } - if (columnName == "StartDateTime") + if (columnName == "StartDate") { - if (startDateTime < DateTime.Now) return "Please enter a valid date. Dates in the past are not allowed."; - if (startDateTime == default) return "Birth date is required"; + if (startDate < DateTime.Now) return "Please enter a valid date. Dates in the past are not allowed."; + if (startDate == default) return "Birth date is required"; else return ""; } if (columnName == "NumberOfWeeks") @@ -313,19 +313,21 @@ public string this[string columnName] return ""; } } + + private string[] _validatedProperties = {"StartDate", "Language", "Level", "NumberOfWeeks", "Time" }; + public string ConcatenatedDays { get { return string.Join(", ", Days); } } - private string[] _validatedProperties = { "StartDateTime", "Language", "Level", "NumberOfWeeks", "Time" }; - // checks if all properties are valid public bool IsValid { get { - if (online == false) + // if the course is held in person add validation for maximal number of student, otherwize remove it + if (online == false) { _validatedProperties = _validatedProperties.Append("MaxStudents").ToArray(); } @@ -345,37 +347,22 @@ public bool IsValid _validatedProperties = newArray; } } - days = new List(); - if (mon) - { - days.Add(DayOfWeek.Monday); - } - if (tue) - { - days.Add(DayOfWeek.Tuesday); - } - if (wed) - { - days.Add(DayOfWeek.Wednesday); - } - if (thu) - { - days.Add(DayOfWeek.Thursday); - } - if (fri) - { - days.Add(DayOfWeek.Friday); - } - if (days.Count == 0) - { - return false; - } + foreach (var property in _validatedProperties) { - if (this[property] != "") - return false; + if (this[property] != "") return false; } + List _days = new List(); + + if (mon) _days.Add(DayOfWeek.Monday); + if (tue) _days.Add(DayOfWeek.Tuesday); + if (wed) _days.Add(DayOfWeek.Wednesday); + if (thu) _days.Add(DayOfWeek.Thursday); + if (fri) _days.Add(DayOfWeek.Friday); + + if(_days.Count == 0) return false; + days = _days; return true; } } @@ -399,7 +386,7 @@ public Course ToCourse() string[] timeParts = time.Split(':'); int hour = int.Parse(timeParts[0]); int minute = int.Parse(timeParts[1]); - return new Course(Id, tutorId, language, level, numberOfWeeks, days, online, maxStudents, new DateTime(startDateTime.Year, startDateTime.Month, startDateTime.Day, hour, minute, 0), createdByDirector); + return new Course(Id, tutorId, language, level, numberOfWeeks, days, online, maxStudents, new DateTime(startDate.Year, startDate.Month, startDate.Day, hour, minute, 0), createdByDirector); } public CourseDTO(Course course) @@ -412,59 +399,8 @@ public CourseDTO(Course course) TutorId = course.TutorId; Days = course.Days; NumberOfStudents = course.NumberOfStudents; - StringBuilder sbDays = new StringBuilder(); - if (Days.Contains(DayOfWeek.Monday)) - { - Mon = true; - sbDays.Append("Mon "); - } - else - { - Mon = false; - } - if (Days.Contains(DayOfWeek.Tuesday)) - { - Tue = true; - sbDays.Append("Tue "); - } - else - { - Tue = false; - } - if (Days.Contains(DayOfWeek.Wednesday)) - { - Wed = true; - sbDays.Append("Wed "); - } - else - { - Wed = false; - } - if (Days.Contains(DayOfWeek.Thursday)) - { - Thu = true; - sbDays.Append("Thu "); - } - else - { - Thu = false; - } - if (Days.Contains(DayOfWeek.Friday)) - { - Fri = true; - sbDays.Append("Fri "); - } - else - { - Fri = false; - } - // Deletes the last white space from stringbuilder - if (sbDays.Length > 0) - { - sbDays.Remove(sbDays.Length - 1, 1); - } - StringDays = sbDays.ToString(); - StartDateTime = course.StartDateTime; + StringDays = ConcatenatedDays; + StartDate = course.StartDateTime; NumberOfWeeks = course.NumberOfWeeks.ToString(); MaxStudents = course.MaxStudents.ToString(); Time = course.StartDateTime.ToString("HH:mm"); diff --git a/LangLang/DTO/ExamSlotDTO.cs b/LangLang/DTO/ExamSlotDTO.cs index 1c134cbc..bdb24bef 100644 --- a/LangLang/DTO/ExamSlotDTO.cs +++ b/LangLang/DTO/ExamSlotDTO.cs @@ -1,41 +1,33 @@ using LangLang.Core.Model; using System; -using System.Collections.Generic; using System.ComponentModel; -using System.Data; using System.Diagnostics; -using System.Linq; -using System.Reflection; -using System.Text; using System.Text.RegularExpressions; -using System.Threading.Tasks; -using System.Xml.Linq; + namespace LangLang.DTO { - public class ExamSlotDTO : INotifyPropertyChanged, IDataErrorInfo + public class ExamSlotDTO : INotifyPropertyChanged { - public ExamSlotDTO() { - _courseId = -1; - } + public int Id { get; set; } - private int _courseId; + private int _tutorId; private string _language; private LanguageLevel _level; private int _maxStudents; private DateTime _examDate; private string _time; - private int _numberOfStudents; - private DateTime _examDateTime; + private int _numberStudents; + private bool _applicationPossible; - public int CourseId + public int TutorId { - get { return _courseId; } + get { return _tutorId; } set { - _courseId = value; - OnPropertyChanged("CourseId"); + _tutorId = value; + OnPropertyChanged("TutorId"); } } @@ -74,7 +66,7 @@ public string MaxStudents if (int.TryParse(value, out int result) && result >= 0) { _maxStudents = result; - //OnPropertyChanged("MaxStudents"); + OnPropertyChanged("MaxStudents"); } else { @@ -94,13 +86,13 @@ public DateTime ExamDate } } - public int NumberOfStudents + public int NumberStudents { - get { return _numberOfStudents; } + get { return _numberStudents; } set { - _numberOfStudents = value; - //OnPropertyChanged("NumberOfStudents"); + _numberStudents = value; + OnPropertyChanged("NumberOfStudents"); } } @@ -114,12 +106,13 @@ public string Time } } - public DateTime ExamDateTime + + public bool ApplicationPossible { - get { return _examDateTime; } - set + get { return _applicationPossible; } + set { - _examDateTime = value; + _applicationPossible = value; } } @@ -177,51 +170,17 @@ public bool IsValid - public ExamSlotDTO(ExamSlot examSlot, Course course) + public ExamSlotDTO(ExamSlot examSlot, LanguageLevel level, string language, int tutorId, int numberStudents) { this.Id = examSlot.Id; - this.Language = course.Language; - this.Level = course.Level; + this.Language = language; + this.Level = level; + this.TutorId = tutorId; this.MaxStudents = examSlot.MaxStudents.ToString(); - this.NumberOfStudents = examSlot.NumberOfStudents; - this.CourseId = examSlot.CourseId; - this.ExamDate = examSlot.ExamDateTime.Date; - this.Time = examSlot.ExamDateTime.ToString("HH:mm"); - this.ExamDateTime = examSlot.ExamDateTime; - } - - private DateTime ToDateTime(DateTime date, string time) - { - - string[] timeComponents = time.Split(':'); - - if (timeComponents.Length == 2) - { - // Parse hour component - if (int.TryParse(timeComponents[0], out int hours)) - { - // Parse minute component - if (int.TryParse(timeComponents[1], out int minutes)) - { - // Create a new DateTime object with the combined date and time components - DateTime combinedDateTime = new DateTime(date.Year, date.Month, date.Day, hours, minutes, 0); - - } - else - { - Console.WriteLine("Invalid minute component."); - } - } - else - { - Console.WriteLine("Invalid hour component."); - } - } - else - { - Console.WriteLine("Invalid time format."); - } - return DateTime.Now; + this.NumberStudents = numberStudents; + this.ExamDate = examSlot.TimeSlot.Time.Date; + this.Time = examSlot.TimeSlot.Time.ToString("HH:mm"); + this.ApplicationPossible = examSlot.ApplicationPossible; } public ExamSlot ToExamSlot() @@ -229,11 +188,9 @@ public ExamSlot ToExamSlot() string[] timeParts = _time.Split(':'); int hour = int.Parse(timeParts[0]); int minute = int.Parse(timeParts[1]); - return new ExamSlot(Id, _courseId, _maxStudents, new DateTime(_examDate.Year, _examDate.Month, _examDate.Day, hour, minute, 0), 0); + return new ExamSlot(Id, _language,_level, new TimeSlot(4,new DateTime(_examDate.Year, _examDate.Month, _examDate.Day, hour, minute, 0)),_maxStudents,_tutorId,_applicationPossible); } - public string Error => throw new NotImplementedException(); - public event PropertyChangedEventHandler? PropertyChanged; protected virtual void OnPropertyChanged(string name) diff --git a/LangLang/Data/enrollmentRequests.csv b/LangLang/Data/enrollmentRequests.csv index 7ada731c..3f86d48b 100644 --- a/LangLang/Data/enrollmentRequests.csv +++ b/LangLang/Data/enrollmentRequests.csv @@ -1,6 +1,6 @@ -0|0|2|Accepted|2024-03-20|2024-03-20 -1|2|0|Accepted|2024-03-10|2024-03-10 -2|0|1|Accepted|2024-02-02|2024-02-02 -3|1|2|Accepted|2024-02-05|2024-02-05 -4|0|0|Accepted|2024-07-07|2024-07-07 -5|0|3|Accepted|2024-08-07|2024-08-07 \ No newline at end of file +0|0|2|Pending|2024-03-20|2024-03-20|false +1|2|0|Accepted|2024-03-10|2024-03-10|false +2|0|1|Pending|2024-02-02|2024-02-02|false +3|1|2|Accepted|2024-02-05|2024-02-05|false +4|0|0|Pending|2024-07-07|2024-07-07|false +5|0|3|Pending|2024-08-07|2024-08-07|false \ No newline at end of file diff --git a/LangLang/Data/students.csv b/LangLang/Data/students.csv index 339a3e04..edfc2d37 100644 --- a/LangLang/Data/students.csv +++ b/LangLang/Data/students.csv @@ -1,3 +1,3 @@ -0|Novak|Djokovic|Male|1980-01-01|+36245621|djokovic1@gmail.com|tenis123|Student|tenis player +0|Novak|Djokovic|Male|1980-01-01|+36245621|nole@gmail.com|idemoo10|Student|tenis player 1|Nikola|Jokic|Male|1980-01-01|+36245621|jokic1@gmail.com|sombor15|Student|basketball player 2|Bogdan|Bogdanovic|Male|1998-05-08|+3816532598|bodan@gmail.com|partizan10|Student|basketball player diff --git a/LangLang/View/CourseGUI/CourseCreateWindow.xaml b/LangLang/View/CourseGUI/CourseCreateWindow.xaml index e7635ed8..13dbf5d4 100644 --- a/LangLang/View/CourseGUI/CourseCreateWindow.xaml +++ b/LangLang/View/CourseGUI/CourseCreateWindow.xaml @@ -206,7 +206,7 @@