コード例 #1
0
ファイル: PanelEditorViewModel.cs プロジェクト: girish66/REM
        /// <summary>
        /// Executes the save command.
        /// </summary>
        /// <param name="dto">The dto to save.</param>
        protected virtual void ExecuteSaveCommand(KeyedDataTransferObject dto)
        {
            _editingPart = dto;

            if (dto != null)
            {
                if (!dto.HasErrors ||
                    (dto.HasErrors && dto.DataErrorInfoCollection.Where(p => p.DataErrorInfoType == DataErrorInfoType.PropertyLevel).Count() == 0))
                {
                    var dtoType               = dto.GetType();
                    var openSaveRequestType   = typeof(SaveDtoRequest <>);
                    var closedSaveRequestType = openSaveRequestType.MakeGenericType(dtoType);
                    var saveRequest           = Activator.CreateInstance(closedSaveRequestType, dto);
                    var requestDispatcher     = _asyncRequestDispatcherFactory.CreateAsyncRequestDispatcher();
                    requestDispatcher.Add(saveRequest as Request);

                    _editingPart.IsLoading = true;

                    requestDispatcher.ProcessRequests(RequestCompleted, HandleRequestDispatcherException);
                }
                else
                {
                    var errors = dto.DataErrorInfoCollection.Where(p => p.ErrorLevel == ErrorLevel.Error).Select(p => p.ToString()).Aggregate((i, j) => i + Environment.NewLine + j);
                    _userDialogService.ShowDialog(string.Format("Please fix the following errors before trying to save:{0}{1}", Environment.NewLine, errors), "Errors", UserDialogServiceOptions.Ok);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Executes the save command.
        /// </summary>
        /// <param name="dto">The dto to save changes.</param>
        protected override void ExecuteSaveCommand(KeyedDataTransferObject dto)
        {
            base.ExecuteSaveCommand(dto);

            if (EditingDto.EditStatus == EditStatus.Create)
            {
                _isCreating = true;
            }
        }
コード例 #3
0
        /// <summary>
        /// Executes the save command.
        /// </summary>
        /// <param name="dto">The dto.</param>
        protected override void ExecuteSaveCommand(KeyedDataTransferObject dto)
        {
            if (EditingDto.Key == 0)
            {
                // Save the Patient for future usage
                Patient = EditingDto.Patient;
            }

            base.ExecuteSaveCommand(dto);
        }
コード例 #4
0
ファイル: EditProgramViewModel.cs プロジェクト: girish66/REM
 /// <summary>
 /// Executes the cancel command.
 /// </summary>
 /// <param name="dto">The data transfer object.</param>
 protected override void ExecuteCancelCommand(KeyedDataTransferObject dto)
 {
     if (IsCreate)
     {
         _popupService.ClosePopup("EditProgramView");
     }
     else
     {
         base.ExecuteCancelCommand(dto);
     }
 }
コード例 #5
0
 /// <summary>
 /// Executes the cancel command.
 /// </summary>
 /// <param name="dto">The dto to cancel edit changes.</param>
 protected override void ExecuteCancelCommand(KeyedDataTransferObject dto)
 {
     if (EditingDto.EditStatus == EditStatus.Create)
     {
         _popupService.ClosePopup("AppointmentDetailsView");
     }
     else
     {
         base.ExecuteCancelCommand(dto);
     }
 }
コード例 #6
0
 /// <summary>
 /// Executes the cancel command.
 /// </summary>
 /// <param name="dto">The dto to cancel editing for.</param>
 protected override void ExecuteCancelCommand(KeyedDataTransferObject dto)
 {
     if (EditingDto.EditStatus == EditStatus.Create)
     {
         RaiseViewClosing();
     }
     else
     {
         base.ExecuteCancelCommand(dto);
     }
 }
コード例 #7
0
 /// <summary>
 /// Executes the save command.
 /// </summary>
 /// <param name="dto">The dto to save changes.</param>
 protected override void ExecuteSaveCommand(KeyedDataTransferObject dto)
 {
     IsLoading = true;
     base.ExecuteSaveCommand(dto);
     if (EditingDto.EditStatus == EditStatus.Create)
     {
         _isCreating = true;
     }
     else if (EditingDto.EditStatus == EditStatus.Update)
     {
         _isUpdating = true;
     }
     IsLoading = false;
 }
コード例 #8
0
ファイル: PanelEditorViewModel.cs プロジェクト: girish66/REM
        /// <summary>
        /// Executes the cancel command.
        /// </summary>
        /// <param name="dto">The dto to check.</param>
        protected virtual void ExecuteCancelCommand(KeyedDataTransferObject dto)
        {
            if (dto.Key > 0)
            {
                _editingPart = dto;

                var dtoType = dto.GetType();
                var openCancelRequestType   = typeof(GetDtoRequest <>);
                var closedCancelRequestType = openCancelRequestType.MakeGenericType(dtoType);
                var cancelRequest           = Activator.CreateInstance(closedCancelRequestType, dto.Key);
                var requestDispatcher       = _asyncRequestDispatcherFactory.CreateAsyncRequestDispatcher();
                requestDispatcher.Add(cancelRequest as Request);

                _editingPart.IsLoading = true;

                requestDispatcher.ProcessRequests(RequestCompleted, HandleRequestDispatcherException);
            }
            else
            {
                ExecuteCancelCommandWhenAdding(dto);
            }
        }
コード例 #9
0
ファイル: PanelEditorViewModel.cs プロジェクト: girish66/REM
 /// <summary>
 /// Executes the cancel command when adding.
 /// </summary>
 /// <param name="dto">The dto.</param>
 protected virtual void ExecuteCancelCommandWhenAdding(KeyedDataTransferObject dto)
 {
 }
コード例 #10
0
ファイル: PanelEditorViewModel.cs プロジェクト: girish66/REM
 /// <summary>
 /// Determines whether this instance [can execute save command] the specified dto.
 /// </summary>
 /// <param name="dto">The dto to check.</param>
 /// <returns><c>true</c> if this instance [can execute save command] the specified dto; otherwise, <c>false</c>.</returns>
 protected virtual bool CanExecuteSaveCommand(KeyedDataTransferObject dto)
 {
     return(true);
 }
コード例 #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="KeyedDataTransferObject"/> class.
 /// </summary>
 /// <param name="keyedDataTransferObject">The keyed data transfer object.</param>
 protected KeyedDataTransferObject( KeyedDataTransferObject keyedDataTransferObject )
 {
     Key = keyedDataTransferObject.Key;
 }
コード例 #12
0
 /// <summary>
 /// Determines whether this instance [can execute save command] the specified dto.
 /// </summary>
 /// <param name="dto">The dto to check.</param>
 /// <returns><c>true</c> if this instance [can execute save command] the specified dto; otherwise, <c>false</c>.</returns>
 protected override bool CanExecuteSaveCommand(KeyedDataTransferObject dto)
 {
     return(CanSave());
 }
コード例 #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="KeyedDataTransferObject"/> class.
 /// </summary>
 /// <param name="keyedDataTransferObject">The keyed data transfer object.</param>
 protected KeyedDataTransferObject(KeyedDataTransferObject keyedDataTransferObject)
 {
     Key = keyedDataTransferObject.Key;
 }