Example #1
0
 private void UpdatedBusinessEventManager(BusinessEventManager businessEventManager)
 {
     if (!_eventSuscribed)
     {
         _eventSuscribed = true;
         businessEventManager.OnCreatedEntity += BusinessEventManager_OnCreatedEntity;
         businessEventManager.OnUpdatedEntity += BusinessEventManager_OnUpdatedEntity;
         businessEventManager.OnDeletedEntity += BusinessEventManager_OnDeletedEntity;
     }
 }
Example #2
0
        private void InitializeCommands()
        {
            SaveCommand = new RelayCommand((data) =>
            {
                if (Mode == DetailMode.Creating)
                {
                    var id      = GenericManager.Create(Entity.LogicalName, Values);
                    var newData = GenericManager.Retrieve(Entity.LogicalName, id);
                    Id          = id;
                    Values      = newData.Values;
                    Mode        = DetailMode.Updating;
                    BusinessEventManager.RaiseOnCreatedEntity(Entity, newData.Values);
                }
                else if (Mode == DetailMode.Updating)
                {
                    GenericManager.Update(Entity.LogicalName, Id, Values);
                    BusinessEventManager.RaiseOnUpdatedEntity(Entity, Id, Values);
                }
            },
                                           (data) =>
            {
                return(IsCompleted);
            });

            DeleteCommand = new RelayCommand((data) =>
            {
                var dialog = new OkCancelMessageBox("Confirm the delete? This operation cannot be undone", "Delete operation");
                dialog.ShowDialog();
                if (dialog.Response == OkCancelMessageBox.InputTextBoxResponse.OK)
                {
                    GenericManager.Delete(Entity.LogicalName, Id);
                    BusinessEventManager.RaiseOnDeletedEntity(Entity, Id);
                }
            },
                                             (data) =>
            {
                return(Mode == DetailMode.Updating);
            });

            RegisterCommand(SaveCommand);
            RegisterCommand(DeleteCommand);
        }
Example #3
0
        public MainControlViewModel()
        {
            GenericManager          = new GenericManager();
            BusinessWorkflowManager = new BusinessWorkflowManager(GenericManager);
            FileService             = new FileService();
            JsonParserService       = new JsonParserService();
            StoredMetadataModel     = new StoredMetadataSchemaService(JsonParserService, FileService);
            StoredDataModel         = new StoredGenericValuesService(JsonParserService, FileService);
            BusinessEventManager    = new BusinessEventManager();
            var currentModel = StoredMetadataModel
                               .GetStoredData()
                               .CompleteModel();

            GenericManager.InitializeModel(currentModel);

            GenericManager.CreateHandler                = new CreateService(StoredDataModel);
            GenericManager.UpdateHandler                = new UpdateService(StoredDataModel);
            GenericManager.DeleteHandler                = new DeleteService(StoredDataModel);
            GenericManager.RetrieveHandler              = new RetrieveService(StoredDataModel);
            GenericManager.RetrieveAllHandler           = new RetrieveAllService(StoredDataModel);
            GenericManager.AssociateHandler             = new AssociateService(StoredDataModel);
            GenericManager.DisassociateHandler          = new DisassociateService(StoredDataModel);
            GenericManager.RetrieveAllAssociatedHandler = new RetrieveAllAssociatedService(StoredDataModel);

            Entities      = GenericManager.Model.Entities.OrderBy(k => k.DisplayName).ToList();
            Relationships = GenericManager.Model.Relationships;

            CurrentEntity = !string.IsNullOrEmpty(currentModel.MainEntity)
                 ? Entities.First(k => k.LogicalName == currentModel.MainEntity)
                 : Entities.First();
            CurrentViewType = ViewType.List;

            BusinessEventManager.OnCreateRequested += BusinessEventManager_OnCreateRequested;
            BusinessEventManager.OnUpdatedEntity   += BusinessEventManager_OnUpdatedEntity;
            BusinessEventManager.OnSelectedEntity  += BusinessEventManager_OnSelectedEntity;
            BusinessEventManager.OnDeletedEntity   += BusinessEventManager_OnDeletedEntity;
            InitializeCommands();
        }
Example #4
0
        private void InitializeCommands()
        {
            CreateCommand = new RelayCommand((data) =>
            {
                BusinessEventManager.RaiseOnCreateRequested(Entity);
            });

            AddNewRelatedCommand = new RelayCommand((data) =>
            {
                var initialValues = new Dictionary <string, object>();
                initialValues.Add(FilterRelationsip.RelatedAttribute, new EntityReferenceValue()
                {
                    Id = FilterRelationsipId
                });
                BusinessEventManager.RaiseOnCreateRequested(Entity, initialValues);
            });

            AssociateCommand = new RelayCommand((data) =>
            {
                var availableValues            = GenericManager.RetrieveAll(FirstEntityAssociation);
                var availablesEntityReferences = availableValues
                                                 .Values
                                                 .Select(k => new EntityReferenceValue()
                {
                    Id = k.Id, DisplayName = (string)k.Values["Name"]
                })
                                                 .ToList();

                var initialEntityReferences = DataSetModel
                                              .Values
                                              .Select(k => new EntityReferenceValue()
                {
                    Id = k.Id, DisplayName = (string)k.Values["Name"]
                })
                                              .ToList();

                var associateWindow = new MultipleAssociationWindow(
                    $"Associate {FirstEntityAssociation}(s) to this {SecondEntityAssociation}",
                    "Association",
                    availablesEntityReferences,
                    initialEntityReferences);

                associateWindow.ShowDialog();
                var response = associateWindow.Response;
                if (response == MultipleAssociationWindow.MultipleAssociationResponse.OK)
                {
                    var selectedValues = associateWindow.SelectedValues;
                    foreach (var item in initialEntityReferences)
                    {
                        GenericManager.Disassociate(FilterRelationsip.MainEntity, FilterRelationsipId, FilterRelationsip.IntersectionName, FilterRelationsip.RelatedEntity, item.Id);
                    }
                    foreach (var item in selectedValues)
                    {
                        GenericManager.Associate(FilterRelationsip.MainEntity, FilterRelationsipId, FilterRelationsip.IntersectionName, FilterRelationsip.RelatedEntity, item.Id);
                    }
                    GetValues();
                }
            });

            RegisterCommand(AddNewRelatedCommand);
            RegisterCommand(CreateCommand);
            RegisterCommand(AssociateCommand);
        }
Example #5
0
 public void SelectedDataRow(DataRowModel dataRowModel)
 {
     BusinessEventManager.RaiseOnSelectedEntity(Entity, dataRowModel.Id);
 }
Example #6
0
 private void SetBusinessEventManager(BusinessEventManager data)
 {
     _viewModel.BusinessEventManager = data;
 }