Example #1
0
        private void Modify()
        {
            try
            {
                if (SelectedDeviceGroupViewModel == null)
                {
                    Messenger.Default.Send(new NotificationMessage("请先选择有效数据!"), Tokens.DeviceGroupPage_ShowNotification);
                    return;
                }

                var coreModel = Mapper.Map <DeviceGroup>(SelectedDeviceGroupViewModel);
                var viewModel = Mapper.Map <DeviceGroupViewModel>(coreModel);

                Messenger.Default.Send(new OpenWindowMessage()
                {
                    DataContext = viewModel
                }, Tokens.DeviceGroupView_Open);
                if (viewModel.ViewModelAttachment.LastOperationSuccess)
                {
                    var index = DeviceGroupViewModels.IndexOf(SelectedDeviceGroupViewModel);
                    DeviceGroupViewModels[index] = viewModel;
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }
Example #2
0
 private void Add()
 {
     try
     {
         var viewModel = Mapper.Map <DeviceGroupViewModel>(new DeviceGroup());
         Messenger.Default.Send(new OpenWindowMessage()
         {
             DataContext = viewModel
         }, Tokens.DeviceGroupView_Open);
         if (viewModel.ViewModelAttachment.LastOperationSuccess)
         {
             viewModel = Mapper.Map <DeviceGroupViewModel>(viewModel.ViewModelAttachment.CoreModel);
             DeviceGroupViewModels.Add(viewModel);
         }
     }
     catch (Exception ex)
     {
         Log.Error(ex);
     }
 }
Example #3
0
        private void Delete()
        {
            DispatcherHelper.CheckBeginInvokeOnUI(() =>
            {
                string message = "";
                try
                {
                    _deviceGroupRepo.Delete(SelectedDeviceGroupViewModel.DeviceGroupID);
                    message = "删除成功!";

                    DeviceGroupViewModels.Remove(SelectedDeviceGroupViewModel);
                }
                catch (Exception ex)
                {
                    Log.Error(ex);
                    message = "删除失败!";
                }
                Messenger.Default.Send(new NotificationMessage(message), Tokens.DeviceGroupPage_ShowNotification);
            });
        }