public Timetable GetTimetable(VulcanAccount account, DateTime date) { account.SwitchToSymbol(School.SchoolSymbol); account.RestClient.BaseUrl = new Uri(new UrlGenerator(account.UrlGenerator.Host, School.SchoolSymbol, School.SchoolId).Generate(UrlGenerator.Site.STUDENT)); var request = new RestRequest("PlanZajec.mvc/Get/", Method.POST); request.RequestFormat = DataFormat.Json; request.AddJsonBody(new { data = date.ToString("s") }); request.AddCookie("idBiezacyDziennik", Diary.DiaryId.ToString()); request.AddCookie("idBiezacyDziennikPrzedszkole", Diary.KindergartenDiaryId.ToString()); request.AddCookie("idBiezacyUczen", StudentId.ToString()); var result = account.RestClient.Execute(request); if (result.IsSuccessful) { var response = JsonConvert.DeserializeObject <ApiResponse <TimetableResponse> >(result.Content); if (response.Success) { return(new Timetable(response.Data)); } else { return(null); } } else { return(null); } }
private async Task ExecuteLoadedAsync(object parameter) { User user = null; if (!IsOfflineMode) { user = await _usersRepository.GetAsync(nameof(Student), StudentId.ToString()); _applicationSettingsService.SaveLoggedUserDataInRegistry(nameof(Student), user as Student); } else { user = _applicationSettingsService.GetLoggedUserDataFromRegistry(nameof(Student)); if (user == null) { return; } } Student student = user as Student; if (!String.IsNullOrWhiteSpace(student.SerializedGrades)) { student.Grades = JsonConvert.DeserializeObject <Dictionary <string, List <Grade> > >(student.SerializedGrades); var subjects = new ObservableCollection <WrappedSubject>(); foreach (var subjectName in student.Grades.Keys) { var wrappedGrades = new ObservableCollection <WrappedGrade>(); var grades = student.Grades[subjectName]; if (grades.Count > 0) { double sum = 0; foreach (var grade in grades) { wrappedGrades.Add(new WrappedGrade { Value = grade.Value, Comment = grade.Comment, LastModificationDate = grade.LastModificationDate }); sum += grade.Value; } double average = sum / grades.Count; var subject = new WrappedSubject { Name = subjectName, Grades = wrappedGrades, Average = String.Format("{0:0.00}", average) }; subjects.Add(subject); } } Subjects = subjects; OnPropertyChanged(nameof(Subjects)); } }
private async Task ExecuteLoadedAsync(object parameter) { var user = await _usersRepository.GetAsync(nameof(Student), StudentId.ToString()); Student = user as Student; if (!String.IsNullOrEmpty(Student.SerializedAttendances)) { Student.Attendances = JsonConvert.DeserializeObject <List <Attendance> >(Student.SerializedAttendances); } else { Student.Attendances = new List <Attendance>(); } }
public override string ToString() { return(FirstName + " " + LastName + " (" + StudentId.ToString() + ")"); }
//重写ToString方法 public override String ToString() { return(StudentId.ToString() + "," + StudentPassword + "," + StudentSex + "," + StudentName + "," + StudentClassName); }
public string this[string name] { get { string errorText = null; //a line of text that show when validate switch (name) { case "StudentId": if (string.IsNullOrWhiteSpace(StudentId)) { errorText = "Student ID cannot be empty"; } else if (StudentId.ToString().Length > 10) { errorText = "Student ID maximun length is 10 charaters"; } else if (!Regex.Match(StudentId, @"^[0-9]+$").Success) { errorText = "Invalid Student ID"; } break; case "FirstName": if (string.IsNullOrWhiteSpace(FirstName)) { errorText = "First Name cannot be empty"; } else if (FirstName.Length > 20) { errorText = "First Name maximun length is 20 charaters"; } else if (!Regex.Match(FirstName, @"^[a-zA-Z]+$").Success) { errorText = "Invalid First Name"; } break; case "LastName": if (string.IsNullOrWhiteSpace(LastName)) { errorText = "Last Name cannot be empty"; } else if (LastName.Length > 20) { errorText = "Last Name maximun length is 20 charaters"; } else if (!Regex.Match(LastName, @"^[a-zA-Z]+$").Success) { errorText = "Invalid Last Name"; } break; case "BirthDate": break; case "Gender": break; case "City": if (string.IsNullOrWhiteSpace(City)) { errorText = "City cannot be empty"; } else if (City.Length > 20) { errorText = "City maximun length is 20 charaters"; } else if (!Regex.Match(City, @"^[a-zA-Z]+$").Success) { errorText = "Invalid City"; } break; case "Email": var regex = @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z"; if (string.IsNullOrWhiteSpace(Email)) { errorText = "Email cannot be empty"; } else if (!Regex.Match(Email, regex).Success) { errorText = "Email is invalid"; } else if (Email.ToString().Length > 30) { errorText = "Email maximun length is 30 charaters"; } break; case "Class": if (string.IsNullOrWhiteSpace(Class)) { errorText = "Class cannot be empty"; } break; } if (ErrorCollection.ContainsKey(name)) { ErrorCollection[name] = errorText; } else if (errorText != null) { ErrorCollection.Add(name, errorText); } NotifyOfPropertyChange(() => ErrorCollection); NotifyOfPropertyChange(() => CanSaveButton); return(errorText); } }
public string DisplayInfo() { return("Id is " + StudentId.ToString() + "Name is " + Name + "Age is " + Age.ToString()); }
public override string ToString() { return($"StudentId: {StudentId.ToString()}, Navn: {Navn}, Grade {Grade.ToString()} "); }