123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- using AIPractice.LabellerServer.Managers;
- using System;
- using System.Collections.ObjectModel;
- namespace AIPractice.LabellerServer.ViewModels
- {
- public class AccountManagerViewModel:ViewModel
- {
- public ObservableCollection<AccountViewModel> Accounts { get; }
- public AccountManagerViewModel()
- {
- Accounts = new ObservableCollection<AccountViewModel>();
- var dataManager = ManagerContainer.GetManager<IDataManager>();
- var accounts = dataManager.GetAccounts();
- foreach(var account in accounts)
- {
- var accountViewModel = new AccountViewModel
- {
- Id = account.Id,
- Name = account.Name,
- Description = account.Description,
- Password = account.Password,
- CreatedTime = account.CreatedTime,
- Labels = account.Labels,
- IsReviewer = account.IsReviewer,
- Email = account.Email,
- };
- Accounts.Add(accountViewModel);
- }
- }
- public void AddAccount(AccountViewModel accountViewModel)
- {
- accountViewModel.CreatedTime = DateTime.Now;
- var dataManager = ManagerContainer.GetManager<IDataManager>();
- dataManager.AddAccount(accountViewModel.Account);
- Accounts.Add(accountViewModel);
- }
- public void DeleteAccount(AccountViewModel accountViewModel)
- {
- var dataManager = ManagerContainer.GetManager<IDataManager>();
- dataManager.DeleteAccount(accountViewModel.Account);
- Accounts.Remove(accountViewModel);
- }
- public void UpdateAccount(AccountViewModel accountViewModel)
- {
- var dataManager = ManagerContainer.GetManager<IDataManager>();
- dataManager.UpdateAccount(accountViewModel.Account);
- }
- }
- }
|