Ejemplo n.º 1
0
        /// <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);
                }
            }
        }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 4
0
 /// <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);
     }
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 8
0
        /// <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);
            }
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Executes the cancel command when adding.
 /// </summary>
 /// <param name="dto">The dto.</param>
 protected virtual void ExecuteCancelCommandWhenAdding(KeyedDataTransferObject dto)
 {
 }
Ejemplo n.º 10
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 virtual bool CanExecuteSaveCommand(KeyedDataTransferObject dto)
 {
     return(true);
 }
 /// <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;
 }
Ejemplo n.º 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());
 }
Ejemplo n.º 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;
 }