private void AddClasses() { var listClasses = tEntity.tClasses.ToList(); foreach (var cl in listClasses) { var listDivisions = tEntity.tBatchClassSections.Where(t => t.csc_ClassId == cl.cla_id).Select(t => new Division { Id = t.csc_SectionId, Name = t.tSection.sec_SectionName }).ToList(); ListClasses.Add(new Class { Id = cl.cla_id, Name = cl.cla_Name, ListDivisions = listDivisions }); } }
// ============================================================================= #region Classes public async Task AddClasse(ClasseAdded c) { try { if (ListClasses.FirstOrDefault(x => x.Nom == c.Nom) != null) { throw new Exception("Une classe avec ce nom existe déjà !"); } Classe classroom = await ApiManager.Instance.AddClassroom(c); ListClasses.Add(classroom); } catch (Exception ex) { AlertError.ShowErrorAlert(ex.Message); } }
public void CreateData() { try { #region Activites Activite act1 = new Activite() { Id = 1, Libelle = "Echecs", NomIntervenant = "", PrenomIntervenant = "", PathBackground = @"Res\echecBg.jpg", }; Activite act2 = new Activite() { Id = 2, Libelle = "Musique", NomIntervenant = "", PrenomIntervenant = "", PathBackground = @"Res\musiqueBg.jpg", Id_LinkedActivity = 3, }; Activite act3 = new Activite() { Id = 3, Libelle = "Musique Chorale", NomIntervenant = "", PrenomIntervenant = "", PathBackground = @"Res\choraleBg.jpg", Id_LinkedActivity = 2, }; Activite act4 = new Activite() { Id = 4, Libelle = "Pastorale", NomIntervenant = " ", PrenomIntervenant = " ", PathBackground = @"Res\pastoraleBg.jpg", }; Activite act5 = new Activite() { Id = 5, Libelle = "Bibliothèque", NomIntervenant = " ", PrenomIntervenant = " ", PathBackground = @"Res\biblioBg.jpg", Id_LinkedActivity = 6, }; Activite act6 = new Activite() { Id = 6, Libelle = "Informatique", NomIntervenant = " ", PrenomIntervenant = " ", PathBackground = @"Res\infoBg.jpg", Id_LinkedActivity = 5, }; Activite act7 = new Activite() { Id = 7, Libelle = "Sport", NomIntervenant = " ", PrenomIntervenant = " ", PathBackground = @"Res\sportBg.jpg", }; Activite act8 = new Activite() { Id = 8, Libelle = "Anglais", NomIntervenant = " ", PrenomIntervenant = " ", PathBackground = @"Res\anglaisBg.jpg", }; Activite act9 = new Activite() { Id = 9, Libelle = "Histoire", NomIntervenant = " ", PrenomIntervenant = " ", PathBackground = @"Res\histoireBg.jpg", }; Activite act10 = new Activite() { Id = 10, Libelle = "Autre", NomIntervenant = " ", PrenomIntervenant = " ", PathBackground = @"Res\autreBg.jpg", }; ListActivites.Add(act1); ListActivites.Add(act2); ListActivites.Add(act3); ListActivites.Add(act4); ListActivites.Add(act5); ListActivites.Add(act6); ListActivites.Add(act7); ListActivites.Add(act8); ListActivites.Add(act9); ListActivites.Add(act10); #endregion BrushConverter brushConverter = new BrushConverter(); #region Classes Classe cl1 = new Classe() { Id = 1, Libelle = "PS/MS", NomProfesseur = " ", PrenomProfesseur = "Axelle & Chantal", BackgroundColor = (SolidColorBrush)brushConverter.ConvertFrom("#80ffbf") }; Classe cl2 = new Classe() { Id = 2, Libelle = "MS/GS", NomProfesseur = " ", PrenomProfesseur = "Cassandra & Sylvie", BackgroundColor = (SolidColorBrush)brushConverter.ConvertFrom("#ffe680") }; Classe cl3 = new Classe() { Id = 3, Libelle = "GS/CP", NomProfesseur = " ", PrenomProfesseur = "Virginie", BackgroundColor = (SolidColorBrush)brushConverter.ConvertFrom("#EE607B") }; Classe cl4 = new Classe() { Id = 4, Libelle = "CP/CE1", NomProfesseur = " ", PrenomProfesseur = "Caroline", BackgroundColor = (SolidColorBrush)brushConverter.ConvertFrom("#00cccc") }; Classe cl5 = new Classe() { Id = 5, Libelle = "CE1/CE2", NomProfesseur = " ", PrenomProfesseur = "Nathalie", BackgroundColor = (SolidColorBrush)brushConverter.ConvertFrom("#8080ff") }; Classe cl6 = new Classe() { Id = 6, Libelle = "CE2/CM1", NomProfesseur = " ", PrenomProfesseur = "Laurence & Chantal", BackgroundColor = (SolidColorBrush)brushConverter.ConvertFrom("#d5ff80") }; Classe cl7 = new Classe() { Id = 7, Libelle = "CM1/CM2", NomProfesseur = " ", PrenomProfesseur = "Florent", BackgroundColor = (SolidColorBrush)brushConverter.ConvertFrom("#ff8080") }; Classe cl8 = new Classe() { Id = 8, Libelle = "CM2", NomProfesseur = " ", PrenomProfesseur = "Sophie", BackgroundColor = (SolidColorBrush)brushConverter.ConvertFrom("#80dfff") }; ListClasses.Add(cl1); ListClasses.Add(cl2); ListClasses.Add(cl3); ListClasses.Add(cl4); ListClasses.Add(cl5); ListClasses.Add(cl6); ListClasses.Add(cl7); ListClasses.Add(cl8); #endregion #region Duree DureeModel duree1 = new DureeModel() { Libelle = "30min", Minutes = 30, RowSpan = 2 }; DureeModel duree2 = new DureeModel() { Libelle = "45min", Minutes = 45, RowSpan = 3 }; DureeModel duree3 = new DureeModel() { Libelle = "1h", Minutes = 60, RowSpan = 4 }; DureeModel duree4 = new DureeModel() { Libelle = "1h30", Minutes = 90, RowSpan = 6 }; DureeModel duree5 = new DureeModel() { Libelle = "2h", Minutes = 120, RowSpan = 8 }; DureeAvailable.Add(duree1); DureeAvailable.Add(duree2); DureeAvailable.Add(duree3); DureeAvailable.Add(duree4); DureeAvailable.Add(duree5); #endregion #region Heures TimeSpan timeStart = new TimeSpan(8, 30, 0); TimeSpan timeEnd = new TimeSpan(16, 30, 0); for (TimeSpan time = new TimeSpan(8, 30, 0); time <= timeEnd; time = time.Add(new TimeSpan(0, 15, 0))) { //Pas les plages horaires entre 11h45 et 13h30 if (time != new TimeSpan(11, 45, 0) && time != new TimeSpan(12, 0, 0) && time != new TimeSpan(12, 15, 0) && time != new TimeSpan(12, 30, 0) && time != new TimeSpan(12, 45, 0) && time != new TimeSpan(13, 0, 0) && time != new TimeSpan(13, 15, 0)) { HoursAvailables.Add(new HourModel() { Time = time, Libelle = time.ToString("hh") + "H" + time.ToString("mm") }); } } #endregion StreamReader reader; string myJson; string folderSave = ConfigurationManager.AppSettings["FolderSaveJSON"].ToString(); // Chargement des créneaux reader = new StreamReader(folderSave + "listCreneauChoosed.json"); myJson = reader.ReadToEnd(); CalendarManager.Instance.ListCreneauChoosed = JsonConvert.DeserializeObject <List <Creneau> >(myJson); } catch (Exception ex) { string message = "Un problème est survenu lors du chargement des données ! \n \n" + ex; MessageBox.Show(message); } }