/// <summary>
 /// Initializes a new instance of the <see cref="EditUniversityViewModel"/> class.
 /// </summary>
 /// <param name="dataService">
 /// The data service.
 /// </param>
 /// <param name="navigationService">
 /// The navigation service.
 /// </param>
 public EditUniversityViewModel(IDataService dataService, INavigationService navigationService)
 {
     _dataService = dataService;
     _navigationService = navigationService;
     _university = null;
     SaveCommand =new RelayCommand(SaveUniversity);
     CancelCommand =new RelayCommand(_navigationService.GoBack);
     GoBackCommand = new RelayCommand(_navigationService.GoBack);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="EditUniversityViewModel"/> class.
 /// </summary>
 /// <param name="dataService">
 /// The data service.
 /// </param>
 /// <param name="navigationService">
 /// The navigation service.
 /// </param>
 public EditUniversityViewModel(IDataService dataService, INavigationService navigationService)
 {
     _dataService = dataService;
     _navigationService = navigationService;
     _university = null;
     LoadDataCommand = new RelayCommand(async () => await LoadDataAsync());
     SaveCommand =new RelayCommand(SaveUniversity);
     CancelCommand =new RelayCommand(_navigationService.GoBack);
 }
示例#3
0
        /// <summary>
        /// Deletes the university.
        /// </summary>
        /// <param name="selectedUniversity">The selected university.</param>
        /// <returns>The <see cref="Task" />.</returns>
        public async Task DeleteUniversityAsync(University selectedUniversity)
        {
           var students = await LoadStudentsByUniversityAsync(selectedUniversity);
           await App.Connection.RunInTransactionAsync(async (SQLiteConnection connection) =>
           {
               foreach (var student in students)
               {
                   DeleteStudentAsync(student);
               }

               App.Connection.DeleteAsync(selectedUniversity);
           }); 
        }
 public void LoadData()
 {
    University = new University();
 }
 /// <summary>
 /// Loads the data.
 /// </summary>
 /// <returns></returns>
 public async Task LoadData(University university)
 {
     University = university;
     Students = await _dataService.LoadStudentsByUniversityAsync(university);
 }
 /// <summary>
 /// Loads the data.
 /// </summary>
 public void LoadData(University university)
 {
    Student = new Student { UniversityId = university.Id };
 }
 /// <summary>
 /// Loads the data.
 /// </summary>
 /// <returns></returns>
 public async Task LoadDataAsync()
 {
     try
     {
         var guid = _navigationService.QueryString["university"];
         University = await this._dataService.LoadUniversityByIdAsync(guid);
     }
     catch (KeyNotFoundException)
     {
         University = new University();
     }
 }
 /// <summary>
 /// Loads the data.
 /// </summary>
 /// <returns></returns>
 public void LoadData(University university)
 {
     University = university;
 }
示例#9
0
 /// <summary>
 /// Loads the students by university.
 /// </summary>
 /// <param name="university">The university.</param>
 /// <returns></returns>
 public async Task<IList<Student>> LoadStudentsByUniversityAsync(University university)
 {
     return await LoadStudentsByUniversityAsync(university.Id);
 }
示例#10
0
 /// <summary>
 /// Updates the university.
 /// </summary>
 /// <param name="selectedUniversity">The selected university.</param>
 /// <returns>The <see cref="Task" />.</returns>
 public async Task UpdateUniversityAsync(University selectedUniversity)
 {
     var existingContact = await App.Connection.FindAsync<University>(u => u.Id == selectedUniversity.Id);
     if (existingContact != null)
     {
         await App.Connection.UpdateAsync(selectedUniversity);
     }
 }
示例#11
0
 /// <summary>
 /// Saves the university.
 /// </summary>
 /// <param name="newUniversity">The new university.</param>
 /// <returns>The <see cref="Task" />.</returns>
 public async Task SaveUniversityAsync(University newUniversity)
 {
     await App.Connection.InsertAsync(newUniversity);
 }