コード例 #1
0
        protected void ItemDelete(ConditionalConfirmation confirmation, IList selectedItemsList, IRepository repository)
        {
            var selectionCount = selectedItemsList.Count;

            if (selectionCount > 0)
            {
                CommonConfirmRequest.Raise(confirmation,
                                           (x) =>
                {
                    if (x.Confirmed)
                    {
                        OnUIThread(() => ShowLoadingAnimation = true);
                        var anyOperationSucceded = false;
                        try
                        {
                            foreach (var item in selectedItemsList)
                            {
                                if (item is IViewModelDetailBase)
                                {
                                    (item as IViewModelDetailBase).Delete();
                                }
                                else if (item is T)
                                {
                                    repository.Attach(item);
                                    repository.Remove(item);
                                    repository.UnitOfWork.Commit();
                                }
                                anyOperationSucceded = true;
                            }
                        }
                        catch (Exception ex)
                        {
                            ShowErrorDialog(ex, string.Format("An error occurred when trying to remove"));
                        }
                        finally
                        {
                            OnUIThread(() => ShowLoadingAnimation = false);
                            if (anyOperationSucceded)
                            {
                                ListItemsSource.Refresh();
                            }
                        }
                    }
                });
            }
        }
コード例 #2
0
		public void SelectItem(object selectedObj)
		{
			var itemVM = _lineItemVmFactory.GetViewModelInstance();
			itemVM.ItemToAdd = selectedObj as Item;

			var confirmation = new ConditionalConfirmation();
			confirmation.Title = "Specify item details".Localize();
			confirmation.Content = itemVM;
			ItemDetailsConfirmRequest.Raise(confirmation, x =>
			{
				if (x.Confirmed)
				{
					// ReturnBuilder.AddExchangeItem(itemVM.ItemToAdd, itemVM.Quantity, itemVM.SelectedColor);
					// OrderBuilder.AddLineItem(...)
					SelectedItemsToAdd.Add(itemVM);
				}
			});
			//OnPropertyChanged("ReturnTotal");
		}
コード例 #3
0
		private void RaiseItemRebuildInteractionRequest(BuildSettings item)
		{
			var confirmation = new ConditionalConfirmation
			{
				Content = string.Format("Are you sure you want to rebuild index \'{0}\'?".Localize(), item.DocumentType),
				Title = "Action confirmation".Localize(null, LocalizationScope.DefaultCategory)
			};

			if (IsActive)
				Stop();
			CommonConfirmRequest.Raise(confirmation, (x) =>
			{
				if (x.Confirmed)
				{
					item.Status = System.Convert.ToInt32(BuildStatus.NeverStarted);
					_repository.UnitOfWork.Commit();
				}
			});
			if (IsActive)
				Start(10);

		}
        /// <summary>
        /// Base method to delete Item.
        /// Rises given confirmation dialog and remove given Item from DB.
        /// Removes given Item from HomeView list.
        /// Works with a repository in not UI thread.
        /// Shows Load Animation
        /// </summary>
        /// <param name="item">Item for remove</param>
        /// <param name="confirmation">confirmation dialog for removing given Item</param>
        /// <param name="repository">Repository</param>
        /// <param name="itemFromRep">Item for remove from repository</param>
        protected virtual void ItemDelete(T item, ConditionalConfirmation confirmation, IRepository repository, object itemFromRep)
        {
            if (item == null || itemFromRep == null || confirmation == null || repository == null)
            {
                return;
            }

            if (string.IsNullOrEmpty(confirmation.Title))
            {
                confirmation.Title = "Delete confirmation".Localize();
            }
            CommonConfirmRequest.Raise(confirmation, async(x) =>
            {
                if (x.Confirmed)
                {
                    ShowLoadingAnimation = true;
                    try
                    {
                        await Task.Run(() =>
                        {
                            if (!repository.IsAttachedTo(itemFromRep))
                            {
                                repository.Attach(itemFromRep);
                            }
                            repository.Remove(itemFromRep);
                            repository.UnitOfWork.Commit();
                        });

                        Items.Remove(item);
                    }
                    finally
                    {
                        ShowLoadingAnimation = false;
                    }
                }
            });
        }
コード例 #5
0
		private void RaiseCreateFolderRequest()
		{
			var inputVm = _inputNameVmFactory.GetViewModelInstance();

			var confirmation = new ConditionalConfirmation { Title = "Enter new folder name".Localize(), Content = inputVm };

			InputNameDialogRequest.Raise(confirmation, (x) =>
			{
				if (x.Confirmed)
				{
					var inputNameDialogViewModel = x.Content as IInputNameDialogViewModel;
					if (inputNameDialogViewModel != null)
					{
						var newFolderName = inputNameDialogViewModel.InputText;
						_assetRepository.CreateFolder(newFolderName, ParentItem.InnerItemID);
						LoadItems();
					}
				}
			});
		}
コード例 #6
0
		private void RestoreAccess()
		{
			if (CommonConfirmRequest != null)
			{
				var confirmation = new ConditionalConfirmation()
				{
					Title = "Restore access confirmation",
					Content = string.Format("Restore access for user '{0}'?", InnerItem.FullName)
				};

				CommonConfirmRequest.Raise(confirmation,
					async (x) =>
					{
						if (x.Confirmed)
						{
							try
							{
								await Task.Run(() => _securityService.Unlock(InnerItem.MemberId));
								HasCurrentContactLoginAndSuspendAccessCheck();
							}
							catch (Exception ex)
							{
								ShowErrorDialog(ex, string.Format("An error occurred when trying to restore access: {0}", ex.InnerException.Message));
							}
						}
					});
			}
		}
コード例 #7
0
		private void CreateLoginPassword()
		{
			if (SelectStoreRequest != null)
			{
				var itemVm =
					_wizardUserVmFactory.GetViewModelInstance(new KeyValuePair<string, object>("operationType",
						CreateUserDialogOperationType.CreateLogin));

				var confirmation = new ConditionalConfirmation { Title = "Enter login details", Content = itemVm };

				SelectStoreRequest.Raise(confirmation,
					async (x) =>
					{
						if (x.Confirmed)
						{
							var storeId = (x.Content as ICreateUserDialogViewModel).StoreId;
							var userName = (x.Content as ICreateUserDialogViewModel).UserName;
							var password = (x.Content as ICreateUserDialogViewModel).Password;

							try
							{
								await Task.Run(() => _securityService.CreateUser(InnerItem.MemberId, userName, password, storeId));
								HasCurrentContactLoginAndSuspendAccessCheck();
							}
							catch (Exception ex)
							{
								ShowErrorDialog(ex,
									string.Format("An error occurred when trying to create the login: {0}", ex.InnerException.Message));
							}
						}
					});
			}

		}
コード例 #8
0
		private void EditAddress(Address item)
		{
			if (AddAddressPhoneEmailInteractioNRequest != null)
			{
				var addressToEdit = item.DeepClone(_entityFactory as IKnownSerializationTypes);
				var countries = CountryRepository.Countries.Expand(c => c.Regions).ToArray();

				var parameters = new List<KeyValuePair<string, object>>
					{
						new KeyValuePair<string, object>("item", addressToEdit),
						new KeyValuePair<string, object>("countries", countries)
					};

				var itemVm = _addressVmFactory.GetViewModelInstance(parameters.ToArray());

				var confirmation = new ConditionalConfirmation { Title = "Enter address details", Content = itemVm };

				AddAddressPhoneEmailInteractioNRequest.Raise(confirmation,
					(x) =>
					{
						if (x.Confirmed)
						{
							var itemToUpdate =
								(x.Content as IAddressDialogViewModel).InnerItem;

							var itemFromInnerItem =
								ContactAddresses.SingleOrDefault(
									a => a.AddressId == itemToUpdate.AddressId);

							if (itemFromInnerItem != null)
							{
								itemFromInnerItem.InjectFrom(itemToUpdate);
								_parentViewModel.IsModified = true;
							}

						}
					});
			}
		}
コード例 #9
0
		private void AddPhone()
		{
			if (AddAddressPhoneEmailInteractioNRequest != null)
			{
				var itemVm = _phoneVmFactory.GetViewModelInstance(new KeyValuePair<string, object>("item", new Phone()));

				var confirmation = new ConditionalConfirmation { Title = "Enter phone details", Content = itemVm };

				AddAddressPhoneEmailInteractioNRequest.Raise(confirmation,
					(x) =>
					{
						if (x.Confirmed)
						{
							var phoneToAdd =
								(x.Content as IPhoneNumberDialogViewModel)
									.InnerItem;

							ContactPhones.Add(phoneToAdd);
							AddPhoneCommand.RaiseCanExecuteChanged();
						}
					});
			}
		}
コード例 #10
0
		private void RaiseRmaRequestCompleteInteractionRequest()
		{
			if (!RmaRequestCompleteCommand.CanExecute())
				return;

			if (CurrentRmaRequest.ReturnTotal > 0)
			{
				var itemVM = _wizardVmFactory.GetViewModelInstance(
					new KeyValuePair<string, object>("item", _parentViewModel.InnerItem),
					new KeyValuePair<string, object>("defaultAmount", CurrentRmaRequest.ReturnTotal)
					);
				itemVM.OnAfterSuccessfulSubmit = () =>
					{
						CurrentRmaRequest.RefundAmount = itemVM.InnerModel.Amount;
						CurrentRmaRequest.Complete(_orderClient);
						_parentViewModel.DoSaveChanges1();
						RaiseCanExecuteChanged();
						_parentViewModel.ReQueryPayments();
					};

				var confirmation = new ConditionalConfirmation { Title = "Create Refund for RMA Request".Localize(), Content = itemVM };
				_parentViewModel.CommonOrderWizardDialogInteractionRequest.Raise(confirmation, x =>
					{
						//if (x.Confirmed)
						//{
						//	// moved to: itemVM.OnAfterSuccessfulSubmit = () =>
						//}		
					});
			}
			else
			{
				CurrentRmaRequest.Complete(_orderClient);
				RaiseCanExecuteChanged();
			}
		}
コード例 #11
0
        private void DeleteCase(string item)
        {
            if (_parentViewModel != null && CommonInfoRequest != null)
            {
                var confirmation = new ConditionalConfirmation()
                {
                    Title = "Delete confirmation".Localize(null, LocalizationScope.DefaultCategory),
                    Content = string.Format("Are you sure you want to delete case '{0}'?".Localize(), InnerItem.Number)
                };

                CommonInfoRequest.Raise(confirmation,
                    (x) =>
                    {
                        if (x.Confirmed)
                        {
                            _parentViewModel.DeleteCaseCommand.Execute(item);
                            Close();
                        }
                    });



            }
        }
コード例 #12
0
        private void DeleteCurrentContact()
        {
            if (CommonInfoRequest != null)
            {
                var confirmation = new ConditionalConfirmation()
                    {
                        Title = "Delete confirmation".Localize(null, LocalizationScope.DefaultCategory),
                        Content = string.Format("Are you sure you want to delete contact '{0}'?".Localize(), CurrentCustomer.FullName)
                    };

                CommonInfoRequest.Raise(confirmation,
                    (x) =>
                    {
                        if (x.Confirmed)
                        {
                            if (_parentViewModel != null)
                            {
                                Close();
                                _parentViewModel.DeleteCustomerCommand.Execute(CurrentCustomer);
                            }
                        }
                    });
            }
        }
コード例 #13
0
        private void ShowCreateCustomerDialog()
        {
            var itemVm =
                _wizardCustomerVmFactory.GetViewModelInstance(new KeyValuePair<string, object>("item",
                                                                                        new Contact
                                                                                            ()));

            var confirmation = new ConditionalConfirmation { Title = "Enter customer details".Localize(), Content = itemVm };

            if (CreateCustomerInteractionRequest != null)
            {
                CreateCustomerInteractionRequest.Raise(confirmation,
                                                       (x) =>
                                                       {
                                                           if (x.Confirmed)
                                                           {
                                                               var contactToAdd =
                                                                   (x.Content as
                                                                    ICreateCustomerDialogViewModel)
                                                                       .InnerItem;
                                                               var emailToAdd =
                                                                   (x.Content as
                                                                    ICreateCustomerDialogViewModel)
                                                                       .EmailForUserInput;
                                                               var phoneToAdd =
                                                                   (x.Content as
                                                                    ICreateCustomerDialogViewModel)
                                                                       .PhoneForUserInput;

                                                               if (emailToAdd.Validate())
                                                               {
                                                                   emailToAdd.Type = EmailType.Primary.ToString();
                                                                   contactToAdd.Emails.Add(
                                                                       emailToAdd);
                                                                   emailToAdd.MemberId =
                                                                       contactToAdd.MemberId;
                                                               }
                                                               if (phoneToAdd.Validate() &&
                                                                   !string.IsNullOrEmpty(
                                                                       phoneToAdd.Number))
                                                               {
                                                                   contactToAdd.Phones.Add(
                                                                       phoneToAdd);
                                                                   phoneToAdd.MemberId =
                                                                       contactToAdd.MemberId;
                                                               }

                                                               CurrentCustomer = contactToAdd;
                                                               _isNewContactInitialized = true;
                                                           }
                                                       });
            }
        }
コード例 #14
0
		private void RaiseMoveLineItemInteractionRequest(ShipmentItem movingItem)
		{
			if (movingItem != null)
			{
				var itemVM = _splitVmFactory.GetViewModelInstance(
					new KeyValuePair<string, object>("currentOrder", _currentOrder.InnerItem)
					, new KeyValuePair<string, object>("sourceShipment", CurrentShipment)
					, new KeyValuePair<string, object>("movingItem", movingItem));

				var confirmation = new ConditionalConfirmation { Title = "Split shipment", Content = itemVM };

				CommonShipmentConfirmRequest.Raise(confirmation, (x) =>
				{
					if (x.Confirmed)
					{
						var quantity = itemVM.MoveQuantity;
						var targetShipment = itemVM.TargetShipment;

						var anyOperationSucceded = false;
						try
						{
							ParentViewModel.CloseAllSubscription1();

							_currentOrder.MoveShippingItem(movingItem, quantity, targetShipment, CurrentShipment);
							if (itemVM.IsNewShipmentSelected)
							{
								targetShipment.ShipmentId = targetShipment.GenerateNewKey();
								targetShipment.OrderFormId = _currentOrder.OrderForms[0].OrderFormId;
								_currentOrder.OrderForms[0].Shipments.Add(targetShipment);
							}

							ParentViewModel.OrderShipmentViewModels.Clear();
							ParentViewModel.InitializeOrderShipmentViewModels();

							ParentViewModel.Recalculate();
							anyOperationSucceded = true;
						}
						finally
						{
							ParentViewModel.SetAllSubscription1();
							// fake assignment for triggers to fire
							if (anyOperationSucceded)
								ParentViewModel.InnerItem.OrderGroupId = ParentViewModel.InnerItem.OrderGroupId;
						}
						RaiseCanExecuteChanged();
					}
				});
			}
		}
コード例 #15
0
		private void RaiseDeleteRequest()
		{
			if (ItemListSelectedItem is FileSearchViewModel ||
				ItemListSelectedItem is FolderSearchViewModel)
			{
				var item = (AssetEntitySearchViewModelBase)ItemListSelectedItem;
				var message = ItemListSelectedItem is FileSearchViewModel
					? "Are you sure you want to delete file '{0}'?".Localize()
					: "Are you sure you want to delete folder '{0}' and all its files and subfolders?".Localize();

				var confirmation = new ConditionalConfirmation
				{
					Content = string.Format(message, item.DisplayName),
					Title = "Delete confirmation".Localize(null, LocalizationScope.DefaultCategory)
				};

				CommonConfirmRequest.Raise(confirmation, (x) =>
				{
					if (x.Confirmed)
					{
						_assetRepository.Delete(item.InnerItemID);
						LoadItems();
					}
				});
			}
		}
コード例 #16
0
		public override void Delete(ICatalogRepository repository, InteractionRequest<Confirmation> commonConfirmRequest, InteractionRequest<Notification> errorNotifyRequest, Action onSuccess)
		{
			var content = string.Empty;

			// count: categories in VirtualCatalog
			var itemCount = repository.Categories
				.Where(x => x.CatalogId == InnerItem.CatalogId)
				.Count();

			if (itemCount > 0)
			{
				content = string.Format("ATTENTION: This Virtual Catalog contains {0} category(ies).\n\n", itemCount);
			}

			content += string.Format("Are you sure you want to delete Virtual Catalog '{0}'?", DisplayName);

			var item = repository.Catalogs.Where(x => x.CatalogId == InnerItem.CatalogId).Single();
			var itemVM = _catalogDeleteVmFactory.GetViewModelInstance(
				new KeyValuePair<string, object>("item", item),
				new KeyValuePair<string, object>("contentText", content));

			var confirmation = new ConditionalConfirmation(itemVM.Validate)
			{
				Content = itemVM,
				Title = "Delete confirmation"
			};
			commonConfirmRequest.Raise(confirmation, async (x) =>
			{
				if (x.Confirmed)
				{
					await Task.Run(() =>
						{
							repository.Remove(item);

							// report status
							var id = Guid.NewGuid().ToString();
							var statusUpdate = new StatusMessage { ShortText = string.Format("A Virtual Catalog '{0}' deletion in progress", DisplayName), StatusMessageId = id };
							EventSystem.Publish(statusUpdate);

							try
							{
								repository.UnitOfWork.Commit();
								statusUpdate = new StatusMessage { ShortText = string.Format("A Virtual Catalog '{0}' deleted successfully", DisplayName), StatusMessageId = id, State = StatusMessageState.Success };
								EventSystem.Publish(statusUpdate);
							}
							catch (Exception e)
							{
								statusUpdate = new StatusMessage
								{
									ShortText = string.Format("Failed to delete Virtual Catalog '{0}'", DisplayName),
									Details = e.ToString(),
									StatusMessageId = id,
									State = StatusMessageState.Error
								};
								EventSystem.Publish(statusUpdate);
							}
						});

					onSuccess();
				}
			});
		}
コード例 #17
0
		private void Cancel()
		{
			var confirmation = new ConditionalConfirmation { Content = Resources.ConfirmCancellation, Title = Resources.Cancellation };
			CancelConfirmRequest.Raise(confirmation, x =>
			{
				if (x.Confirmed)
				{
					// ERROR_CANCELLED
					// OnUIThread(() => Application.Current.Shutdown(0x4C7));
				}
			});
		}
コード例 #18
0
        public override void Delete(ICatalogRepository repository, InteractionRequest<Confirmation> commonConfirmRequest, InteractionRequest<Notification> errorNotifyRequest, Action onSuccess)
        {
            var countBuffer = new List<string>();

            // count: categories in Catalog
            int itemCount = repository.Categories.Where(x => x.CatalogId == InnerItem.CatalogId).Count();
            if (itemCount > 0)
            {
                countBuffer.Add(string.Format("contains {0} category(ies)".Localize(), itemCount));
            }

            // count: items in Catalog
            itemCount = repository.Items.Where(x => x.CatalogId == InnerItem.CatalogId).Count();
            if (itemCount > 0)
            {
                countBuffer.Add(string.Format("has {0} item(s)".Localize(), itemCount));
            }

            var content = string.Empty;
            var warnings = countBuffer.Select(x => "\n\t- " + x).ToArray();
            if (warnings.Length > 0)
            {
                content = string.Format("ATTENTION: This Catalog {0}.\n\n".Localize(), string.Join("", warnings));
            }
            content += string.Format("Are you sure you want to delete Catalog '{0}'?".Localize(), DisplayName);

            var item = LoadItem(InnerItem.CatalogId, repository);
            var itemVM = _catalogDeleteVmFactory.GetViewModelInstance(
                new KeyValuePair<string, object>("item", item),
                new KeyValuePair<string, object>("contentText", content));

            var confirmation = new ConditionalConfirmation(itemVM.Validate)
            {
                Content = itemVM,
                Title = "Delete confirmation".Localize(null, LocalizationScope.DefaultCategory)
            };
            commonConfirmRequest.Raise(confirmation, async (x) =>
            {
                if (x.Confirmed)
                {
                    await Task.Run(() =>
                    {
                        repository.Remove(item);

                        // report status
                        var id = Guid.NewGuid().ToString();
                        var statusUpdate = new StatusMessage { ShortText = string.Format("A Catalog '{0}' deletion in progress".Localize(), DisplayName), StatusMessageId = id };
                        EventSystem.Publish(statusUpdate);

                        try
                        {
                            repository.UnitOfWork.Commit();
                            statusUpdate = new StatusMessage { ShortText = string.Format("A Catalog '{0}' deleted successfully".Localize(), DisplayName), StatusMessageId = id, State = StatusMessageState.Success };
                            EventSystem.Publish(statusUpdate);
                        }
                        catch (Exception e)
                        {
                            statusUpdate = new StatusMessage
                            {
                                ShortText = string.Format("Failed to delete Catalog '{0}'".Localize(), DisplayName),
                                Details = e.ToString(),
                                StatusMessageId = id,
                                State = StatusMessageState.Error
                            };
                            EventSystem.Publish(statusUpdate);
                        }
                    });

                    onSuccess();
                }
            });
        }
コード例 #19
0
        public override void Delete(ICatalogRepository repository, InteractionRequest<Confirmation> commonConfirmRequest, InteractionRequest<Notification> errorNotifyRequest, Action onSuccess)
        {
            var countBuffer = new List<string>();
            int itemCount;

            // count: items in category. Don't try counting items for VirtualCatalog (nor linked category in it). 
            var isThisCategoryInRealCatalog = CatalogHomeViewModel.GetCatalog(this) is catalogModel.Catalog;
            if (isThisCategoryInRealCatalog)
            {
                // checking current category and level 1 (direct) subcategories.
                itemCount = repository.Items
                                      .Where(x =>
                                          x.CategoryItemRelations.Any(y =>
                                              y.CategoryId == InnerItem.CategoryId || y.Category.ParentCategoryId == InnerItem.CategoryId))
                                      .Count();

                if (itemCount > 0)
                {
                    countBuffer.Add(string.Format("has {0} item(s), won't be deleted".Localize(), itemCount));
                }
            }

            // count: direct sub-categories
            itemCount = repository.Categories
                .Where(x => x.ParentCategoryId == InnerItem.CategoryId)
                .Count();

            if (itemCount > 0)
            {
                countBuffer.Add(string.Format("has {0} sub-category(ies), will be deleted".Localize(), itemCount));
            }

            if (isThisCategoryInRealCatalog)
            {
                // count: linked categories			
                itemCount = repository.Categories
                    .OfType<LinkedCategory>()
                    .Where(x => x.LinkedCategoryId == InnerItem.CategoryId)
                    .Count();

                if (itemCount > 0)
                {
                    countBuffer.Add(string.Format("is coupled with {0} Linked Category(ies), will be deleted".Localize(), itemCount));
                }
            }

            // construct nice message
            var typeName = ((InnerItem is Category) ? "category" : "linked category").Localize();
            var content = string.Empty;
            var warnings = countBuffer.Select(x => "\n\t- " + x).ToArray();
            if (warnings.Length > 0)
            {
                content = string.Format("ATTENTION: This {0} {1}.\n\n".Localize(), typeName, string.Join("", warnings));
            }

            content += string.Format("Are you sure you want to delete {0} '{1}'?".Localize(), typeName, DisplayName);

            var confirmation = new ConditionalConfirmation
            {
                Content = content,
                Title = "Delete confirmation".Localize(null, LocalizationScope.DefaultCategory)
            };

            commonConfirmRequest.Raise(confirmation, async (x) =>
            {
                if (x.Confirmed)
                {
                    await Task.Run(() =>
                    {
                        // Removing item by attaching makes DataServiceRequest exception.
                        var categoryItem = repository.Categories.Where(c => c.CategoryId == InnerItem.CategoryId).FirstOrDefault();
                        //repository.Attach(InnerItem);
                        repository.Remove(categoryItem);

                        // report status
                        var id = Guid.NewGuid().ToString();
                        var item = new StatusMessage { ShortText = string.Format("A {0} '{1}' deletion in progress".Localize(), typeName, DisplayName), StatusMessageId = id };
                        EventSystem.Publish(item);

                        try
                        {
                            if (DeleteSeoKeywords())
                            {
                                repository.UnitOfWork.Commit();
                            }
                            item = new StatusMessage { ShortText = string.Format("A {0} '{1}' deleted successfully".Localize(), typeName, DisplayName), StatusMessageId = id, State = StatusMessageState.Success };
                            EventSystem.Publish(item);
                        }
                        catch (Exception e)
                        {
                            item = new StatusMessage
                            {
                                ShortText = string.Format("Failed to delete {0} '{1}'".Localize(), typeName, DisplayName),
                                Details = e.ToString(),
                                StatusMessageId = id,
                                State = StatusMessageState.Error
                            };
                            EventSystem.Publish(item);
                        }
                    });

                    var parentHierarchyVM = (HierarchyViewModelBase)Parent;
                    parentHierarchyVM.Refresh();
                }
            });
        }
コード例 #20
0
		private void AddAddress()
		{
			if (AddAddressPhoneEmailInteractioNRequest != null)
			{
				var countries = CountryRepository.Countries.Expand(c => c.Regions).ToArray();

				var parameters = new List<KeyValuePair<string, object>>
					{
						new KeyValuePair<string, object>("item", new Address()),
						new KeyValuePair<string, object>("countries", countries)
					};

				var itemVm = _addressVmFactory.GetViewModelInstance(parameters.ToArray());

				var confirmation = new ConditionalConfirmation { Title = "Enter address details", Content = itemVm };

				AddAddressPhoneEmailInteractioNRequest.Raise(confirmation,
					(x) =>
					{
						if (x.Confirmed)
						{
							var itemToAdd =
								(x.Content as IAddressDialogViewModel)
									.InnerItem;
							itemToAdd.MemberId = InnerItem.MemberId;

							ContactAddresses.Add(itemToAdd);
						}
					});
			}
		}
コード例 #21
0
		private bool RaiseStoreSettingEditInteractionRequest(StoreSetting item, string title)
		{
			bool result = false;
			var itemVM = _settingVmFactory.GetViewModelInstance(
				new KeyValuePair<string, object>("item", item)
				);
			var confirmation = new ConditionalConfirmation(itemVM.InnerItem.Validate);
			confirmation.Title = title;
			confirmation.Content = itemVM;

			CommonConfirmRequest.Raise(confirmation, (x) =>
			{
				result = x.Confirmed;
			});

			return result;
		}
コード例 #22
0
		private void AddEmail()
		{
			if (AddAddressPhoneEmailInteractioNRequest != null)
			{
				var itemVm = _emailVmFactory.GetViewModelInstance(new KeyValuePair<string, object>("item", new Email()));

				var confirmation = new ConditionalConfirmation { Title = "Enter email details", Content = itemVm };

				AddAddressPhoneEmailInteractioNRequest.Raise(confirmation,
					(x) =>
					{
						if (x.Confirmed)
						{
							var itemToAdd =
								(x.Content as IEmailDialogViewModel)
									.InnerItem;
							itemToAdd.MemberId = InnerItem.MemberId;

							if (ContactEmails.Count == 0 || ContactEmails.All(e => e.Type != EmailType.Primary.ToString()))
							{
								itemToAdd.Type =
									EmailType.Primary.ToString();
							}

							ContactEmails.Add(itemToAdd);
						}
					});
			}
		}
コード例 #23
0
		private void RaiseStoreSettingDeleteInteractionRequest(StoreSetting item)
		{
			var confirmation = new ConditionalConfirmation
			{
				Content = string.Format("Are you sure you want to delete Store Setting '{0}'?", item.Name),
				Title = "Delete confirmation"
			};

			CommonConfirmRequest.Raise(confirmation, (x) =>
			{
				if (x.Confirmed)
				{
					InnerItem.Settings.Remove(item);
				}
			});
		}
コード例 #24
0
		private void EditEmail(Email item)
		{
			if (AddAddressPhoneEmailInteractioNRequest != null)
			{
				var emailToEdit = item.DeepClone(_entityFactory as IKnownSerializationTypes);

				var itemVm = _emailVmFactory.GetViewModelInstance(new KeyValuePair<string, object>("item", emailToEdit));

				var confirmation = new ConditionalConfirmation { Title = "Enter email details", Content = itemVm };

				AddAddressPhoneEmailInteractioNRequest.Raise(confirmation,
					(x) =>
					{
						if (x.Confirmed)
						{
							var itemTUpdate =
								(x.Content as IEmailDialogViewModel)
									.InnerItem;

							var itemFromInnerItem =
								ContactEmails.SingleOrDefault(
									e => e.EmailId == itemTUpdate.EmailId);

							if (itemFromInnerItem != null)
							{
								itemFromInnerItem.InjectFrom(itemTUpdate);
								_parentViewModel.IsModified = true;
							}
						}
					});
			}
		}
コード例 #25
0
		private void RaiseValueDeleteInteractionRequest(PropertyValueBase item)
		{
			var confirmation = new ConditionalConfirmation
			{
				Content = string.Format("Are you sure you want to delete dictionary Property value '{0}'?", item),
				Title = "Delete confirmation"
			};

			CommonConfirmRequest.Raise(confirmation, (x) =>
			{
				if (x.Confirmed)
				{
					InnerItem.PropertyValues.Remove((PropertyValue)item);
				}
			});
		}
コード例 #26
0
		private void ResetCustomerPassword()
		{
			if (SelectStoreRequest != null)
			{

				var itemVm =
					_wizardUserVmFactory.GetViewModelInstance(new KeyValuePair<string, object>("operationType",
						CreateUserDialogOperationType
							.ResetPassword));

				var confirmation = new ConditionalConfirmation { Title = "Enter new password", Content = itemVm };

				SelectStoreRequest.Raise(confirmation,
					async (x) =>
					{
						if (x.Confirmed)
						{
							var newPass = (x.Content as ICreateUserDialogViewModel).Password;

							try
							{
								await Task.Run(() => _securityService.ResetPassword(CurrentContactLoginUserName, newPass));
								HasCurrentContactLoginAndSuspendAccessCheck();
							}
							catch (Exception ex)
							{
								ShowErrorDialog(ex,
									string.Format("An error occurred when trying to reset the password: {0}", ex.InnerException.Message));
							}
						}
					});

			}
		}
コード例 #27
0
		private bool RaisePropertyValueEditInteractionRequest(StorageEntity item, string title)
		{
			bool result = false;
			var itemVM = _propertyValueVmFactory.GetViewModelInstance(
				new KeyValuePair<string, object>("item", item),
				new KeyValuePair<string, object>("parent", this)
				);
			var confirmation = new ConditionalConfirmation(itemVM.Validate);
			confirmation.Title = title;
			confirmation.Content = itemVM;

			CommonConfirmRequest.Raise(confirmation, (x) =>
			{
				result = x.Confirmed;
			});

			return result;
		}
コード例 #28
0
		private void RaiseCompleteShipment()
		{
			var shipmentId = "";
			if (CurrentTab.IdTab == NavigationNames.PicklistHomeName)
			{
				var x = (PicklistHomeViewModel)CurrentTab.ViewModel;
				if (x.SelectedItem != null)
				{
					shipmentId=x.SelectedItem.Data.Picklist.Shipments[0].ShipmentId;
				}
			}
			var vm = _completeShipmentVmFactory.GetViewModelInstance(new KeyValuePair<string, object>("shipmentId", shipmentId));
			
			var confirmation = new ConditionalConfirmation {Title = "Complete shipment", Content = vm};

			CommonConfirmRequest.Raise(confirmation, x =>
			{
				if (x.Confirmed)
				{
					using (var orderRepository = _orderRepositoryFactory.GetRepositoryInstance())
					{
						var query = orderRepository.Shipments.Expand("OrderForm").Where(ship => ship.ShipmentId == vm.ShipmentId);
						var current = query.FirstOrDefault();
						if (current != null)
						{
							var res = true;
							try
							{
								current.ShipmentTrackingNumber = vm.TrackingNumber;
								current.Status = ShipmentStatus.Shipped.ToString();
								// Load complete item here

								var q = orderRepository.Orders
														.Expand("OrderForms/Shipments/ShipmentItems/LineItem")
														.Where(order => order.OrderGroupId == current.OrderForm.OrderGroupId);
								var originalItem = q.SingleOrDefault();

								if (originalItem != null)
								{
									var result = _orderService.ExecuteWorkflow(RecalculateWorkflowName, originalItem);
									OnUIThread(()=>originalItem.InjectFrom<CloneInjection>(result.OrderGroup));
								}

								orderRepository.UnitOfWork.Commit();
							}
							catch (Exception)
							{
								res = false;
							}

							if (res)
							{
								var notification = new Notification
									{
										Title = "Shipment completed",
										Content = string.Format("Shipment: {0}{1}{2}{3}Completed successfully",
																vm.ShipmentId,
																Environment.NewLine,
																string.IsNullOrEmpty(vm.TrackingNumber)
																	? string.Empty
																	: string.Format("TrackingNumber: {0}", vm.TrackingNumber),
																Environment.NewLine)
									};
								CommonNotifyRequest.Raise(notification);
							}
							else
							{
								current.ShipmentTrackingNumber = null;
								current.Status = ShipmentStatus.Packing.ToString();
								orderRepository.UnitOfWork.Commit();
								var notification = new Notification
									{
										Title = "Shipment not completed",
										Content = string.Format("Shipment: {0}\nNot completed",
																vm.ShipmentId)
									};
								CommonNotifyRequest.Raise(notification);
							}
						}
					}
				}
			});
			
		}
コード例 #29
0
		private bool RaisePropertyAttributeEditInteractionRequest(StorageEntity item, string title)
		{
			var result = false;
			var itemVM = _attributeVmFactory.GetViewModelInstance(new KeyValuePair<string, object>("item", item));
			var confirmation = new ConditionalConfirmation(itemVM.Validate) { Title = title, Content = itemVM };

			CommonConfirmRequest.Raise(confirmation, (x) =>
			{
				result = x.Confirmed;
			});

			return result;
		}
コード例 #30
0
		private void RaiseRenameRequest()
		{
			if (ItemListSelectedItem is FileSearchViewModel ||
				ItemListSelectedItem is FolderSearchViewModel)
			{
				var item = (AssetEntitySearchViewModelBase)ItemListSelectedItem;
				var title = ItemListSelectedItem is FileSearchViewModel
				   ? "Enter new file name".Localize()
				   : "Enter new folder name".Localize();
				var inputVm = _inputNameVmFactory.GetViewModelInstance();
				inputVm.InputText = item.DisplayName;
				var confirmation = new ConditionalConfirmation { Title = title, Content = inputVm };

				InputNameDialogRequest.Raise(confirmation, (x) =>
				{
					if (x.Confirmed)
					{
						var inputNameDialogViewModel = x.Content as IInputNameDialogViewModel;
						if (inputNameDialogViewModel != null)
						{
							var newFolderName = inputNameDialogViewModel.InputText;
							_assetRepository.Rename(item.InnerItemID, newFolderName);
							LoadItems();
						}
					}
				});
			}
		}
コード例 #31
0
		private void RaiseAttributeDeleteInteractionRequest(PropertyAttribute item)
		{
			var confirmation = new ConditionalConfirmation
			{
				Content = string.Format("Are you sure you want to delete Property attribute '{0}({1})'?", item.PropertyAttributeName, item.PropertyAttributeValue),
				Title = "Delete confirmation"
			};

			CommonConfirmRequest.Raise(confirmation, (x) =>
			{
				if (x.Confirmed)
				{
					InnerItem.PropertyAttributes.Remove(item);
				}
			});
		}
コード例 #32
0
		private void RaisePropertyValueEditInteractionRequest(DynamicContentItemProperty originalItem)
		{
			var item = originalItem.DeepClone(_entityFactory as IKnownSerializationTypes);
			var itemVM = _propertyEditVmFactory.GetViewModelInstance(
				new KeyValuePair<string, object>("item", item)
				);
			var confirmation = new ConditionalConfirmation { Title = "Enter property value".Localize(), Content = itemVM };

			CommonConfirmRequest.Raise(confirmation, (x) =>
			{
				if (x.Confirmed)
				{
					switch ((coreModel.PropertyValueType)item.ValueType)
					{
						case coreModel.PropertyValueType.ShortString:
							InnerItem.PropertyValues.First(y => y.Name == item.Name).ShortTextValue = item.ShortTextValue;
							break;
						case coreModel.PropertyValueType.Category:
						case coreModel.PropertyValueType.Image:
						case coreModel.PropertyValueType.LongString:
							InnerItem.PropertyValues.First(y => y.Name == item.Name).LongTextValue = item.LongTextValue;
							break;
						case coreModel.PropertyValueType.Decimal:
							InnerItem.PropertyValues.First(y => y.Name == item.Name).DecimalValue = item.DecimalValue;
							break;
						case coreModel.PropertyValueType.Integer:
							InnerItem.PropertyValues.First(y => y.Name == item.Name).IntegerValue = item.IntegerValue;
							break;
						case coreModel.PropertyValueType.Boolean:
							InnerItem.PropertyValues.First(y => y.Name == item.Name).BooleanValue = item.BooleanValue;
							break;
					}

					OnPropertyChanged("InnerItem");
				}
			});
		}
 // This method will delete soon
 protected virtual void ItemDelete(T item, ConditionalConfirmation confirmation, IRepository repository)
 {
     ItemDelete(item, confirmation, repository, item);
 }