Exemple #1
0
        private async void OnEmployeeSelected(Employee value)
        {
            async Task LoadEmployees()
            {
                EmployeeJobs = await _employeeRepository.GetEmployeeJobsByEmployee(value.Id)
                               .Select(CreateEmployeeJobViewModel)
                               .ToAsyncObservableCollection();

                await EmployeeJobs.InitializeAll();
            }

            await ToggleBusyAsync(LoadEmployees());
        }
Exemple #2
0
        private async void EmployeeJobsChanged(object sender, RepositoryChangeEventArgs <EmployeeJob> args)
        {
            if (SelectedEmployee != null && SelectedEmployee.Id == args.Item.EmployeeId)
            {
                async Task AddJob()
                {
                    var job = CreateEmployeeJobViewModel(args.Item);
                    await job.Initialize();

                    EmployeeJobs.Add(job);
                }

                void DeleteJob()
                {
                    var job = EmployeeJobs.FirstOrDefault(e => e.EmployeeJob.Equals(args.Item));

                    EmployeeJobs.Remove(job);
                }

                switch (args.OperationType)
                {
                case OperationType.Add:
                    await AddJob();

                    break;

                case OperationType.Edit:
                    DeleteJob();
                    await AddJob();

                    break;

                case OperationType.Delete:
                    DeleteJob();
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
        }