Пример #1
0
 public static async Task DeleteAllNotesForClassAsync(Class c) {
     var folder = await ApplicationData.Current.RoamingFolder.CreateFolderAsync("Notes", CreationCollisionOption.OpenIfExists);
     foreach (StorageFile f in await folder.GetFilesAsync()) {
         if (f.Name.Contains(c.Id)) {
             await f.DeleteAsync(StorageDeleteOption.PermanentDelete);
             continue;
         }
     }
 }
Пример #2
0
 public static async Task<List<Note>> GetNotesForClassAsync(Class c) {
     var folder = await ApplicationData.Current.RoamingFolder.CreateFolderAsync("Notes", CreationCollisionOption.OpenIfExists);
     var l = new List<Note>();
     foreach (StorageFile f in await folder.GetFilesAsync()) {
         if (f.Name.Contains(c.Id)) {
             l.Add(await Note.CreateFromStorageFileAsync(f));
         }
     }
     return l;
 }
 protected override async void OnNavigatedTo(NavigationEventArgs e) {
     if (e.Parameter != null) {
         Source = (Class)e.Parameter;
     }
     ClassNameBlock.Text = (Source != null) ? Source.Name : "Class name";
     var list = await DataManager.GetNotesForClassAsync(Source);
     foreach (Note n in list) {
         NotesPanel.Children.Add(new NoteControl() { Source = n });
     }
     NoNotesBlock.Visibility = (list.Count == 0) ? Visibility.Visible : Visibility.Collapsed;
 }
Пример #4
0
 public static async Task<Homework> CreateAsync(string name, string desc, HomeworkKind k, DateTime due, Class o) {
     var hw = new Homework() {
         Owner = o,
         Name = name,
         Description = desc,
         Kind = k,
         Status = HomeworkStatus.Incomplete,
         FinalGrade = null,
         DueDate = due,
         TurnedInDate = null
     };
     hw.Owner.Homework.Add(hw);
     await hw.Owner.Commit();
     return hw;
 }
 public NewNoteDialog(Class c, Func<Task> reload) {
     InitializeComponent();
     src = c;
     reloadAction = reload;
 }
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     Owner = e.Parameter as Class;
 }
Пример #7
0
 public static Homework Deserialize(XElement e, Class o) {
     var hw = new Homework() {
         Owner = o,
         Name = e.Attribute("name").Value,
         Description = e.Attribute("description").Value != "null" ? e.Attribute("description").Value : null,
         Status = (HomeworkStatus)Enum.Parse(typeof(HomeworkStatus), e.Attribute("status").Value),
         Kind = (HomeworkKind)Enum.Parse(typeof(HomeworkKind), e.Attribute("kind").Value),
         DueDate = DateTime.Parse(e.Attribute("dueDate").Value),
         TurnedInDate = e.Attribute("turnedInDate").Value == "null" ? null : new DateTime?(DateTime.Parse(e.Attribute("turnedInDate").Value))
     };
     if (e.Attribute("finalGrade").Value == "null") hw.FinalGrade = null; else hw.FinalGrade = int.Parse(e.Attribute("finalGrade").Value);
     return hw;
 }
Пример #8
0
 public static List<Homework> DeserializeList(XElement hw, Class o) {
     var l = new List<Homework>();
     foreach (XElement e in hw.Elements("homework")) {
         l.Add(Deserialize(e, o));
     }
     return l;
 }
Пример #9
0
 public static XDocument Serialize(Class c) {
     var doc = new XDocument();
     var classElement = new XElement("class");
     classElement.Add(new XAttribute("id", c.Id));
     classElement.Add(new XAttribute("name", c.Name));
     classElement.Add(new XAttribute("teacherName", c.TeacherName));
     classElement.Add(new XAttribute("location", c.Location));
     classElement.Add(new XAttribute("startDate", c.StartDate));
     classElement.Add(new XAttribute("startTime", c.StartTime.ToString()));
     classElement.Add(new XAttribute("endTime", c.EndTime.ToString()));
     var daysElement = new XElement("days");
     foreach (string s in c.Days) {
         daysElement.Add(new XElement("day", s));
     }
     classElement.Add(daysElement);
     var overrideElement = new XElement("overrides");
     foreach (Override o in c.Overrides) {
         overrideElement.Add(Override.Serialize(o));
     }
     classElement.Add(overrideElement);
     var homeworkElement = new XElement("homeworks");
     foreach (Homework h in c.Homework) {
         homeworkElement.Add(Classes.Homework.Serialize(h));
     }
     classElement.Add(homeworkElement);
     doc.Add(classElement);
     return doc;
 }
Пример #10
0
 protected static async Task<Class> CreateAsync(string name, string teacherName, string loc, DateTime startDate, TimeSpan startTime, TimeSpan endTime, string id) {
     if (string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(teacherName) || string.IsNullOrWhiteSpace(loc)) {
         throw new Exception();
     }
     var c = new Class() {
         Id = Guid.Parse(id).ToString(),
         Name = name,
         TeacherName = teacherName,
         Location = loc,
         StartDate = startDate,
         StartTime = startTime,
         EndTime = endTime,
         Days = new List<string>(),
         Overrides = new List<Override>(),
         Homework = new List<Homework>()
     };
     c.UpdateGradeAvg();
     await c.Commit();
     return c;
 }