Beispiel #1
0
        public override JobTypeVM DeepClone()
        {
            var dto = JobTypeConvertUtil.ToDto(this);
            var vm  = JobTypeConvertUtil.FromDto(dto);

            base.CopyStateValues(vm);
            return(vm);
        }
Beispiel #2
0
        private async void RefreshItemsAsync()
        {
            this.ItemList.Clear();
            IsBusy = true;
            ICollection <jobType> items = await AppCxt.Current.DataPortal.GetAllJobTypesAsync();

            IsBusy = false;
            foreach (var item in items)
            {
                JobTypeVM vm = JobTypeConvertUtil.FromDto(item);
                this.ItemList.Add(vm);
            }
        }
Beispiel #3
0
        private async void EditItem()
        {
            JobTypeVM vm = this.SelectedItem.DeepClone();

            vm.IsDirty              = false;
            vm.IsEditing            = true;
            vm.IsNew                = false;
            this.IsEditing          = true;
            this.CurrentEditingItem = vm;
            bool isSaveClick = await this.EditItemDialog?.ShowDialogAsync("添加", vm);

            if (isSaveClick)
            {
                jobType[] items = new jobType[] { JobTypeConvertUtil.ToDto(vm) };
                int       count = await AppCxt.Current.DataPortal.UpdateJobTypes(items);

                this.ClearEditingState();
                this.RefreshItemsAsync();
            }
        }
Beispiel #4
0
        private async void AddItem()
        {
            JobTypeVM vm = new JobTypeVM()
            {
                Id = Guid.NewGuid().ToString()
            };

            vm.IsDirty              = true;
            vm.IsEditing            = true;
            vm.IsNew                = true;
            this.IsEditing          = true;
            this.CurrentEditingItem = vm;
            bool isSaveClick = await this.EditItemDialog?.ShowDialogAsync("添加", vm);

            if (isSaveClick)
            {
                jobType[] items = new jobType[] { JobTypeConvertUtil.ToDto(vm) };
                int       count = await AppCxt.Current.DataPortal.AddJobTypes(items);

                this.ClearEditingState();
                this.RefreshItemsAsync();
            }
        }
Beispiel #5
0
        private async void DeleteItemsAsync()
        {
            if (this.DeleteItemsDialog != null)
            {
                var items = this.ItemList.Where(p => p.IsSelected).ToList();
                if (items.Count == 0)
                {
                    items.Add(this.SelectedItem);
                }
                bool isSureToDelete = await this.DeleteItemsDialog.ShowDialog(items);

                if (isSureToDelete)
                {
                    List <jobType> list = items.Select(p => JobTypeConvertUtil.ToDto(p)).ToList();
                    this.IsBusy = true;
                    int result = await AppCxt.Current.DataPortal.DeletJobTypes(list);

                    if (result > 0)
                    {
                        this.RefreshItemsAsync();
                    }
                }
            }
        }