Example #1
0
        /// <summary>
        /// Dictionary of events.
        /// </summary>
        /// <param name="eventDictionary"></param>
        private void OnChangedField(IDictionary <string, object> eventDictionary)
        {
            object      dataObject = DataObject;
            DataPayLoad payLoad    = BuildDataPayload(eventDictionary);

            ChangeFieldHandlerDo <ClientDto> handlerDo = new ChangeFieldHandlerDo <ClientDto>(EventManager,
                                                                                              DataSubSystem.ClientSubsystem);
            var fixedValue = DataObject;

            FixCreditCardInfo(ref fixedValue, ExpireMonth, ExpireYear);
            DataObject = fixedValue;

            if (string.IsNullOrEmpty(payLoad.PrimaryKeyValue))
            {
                payLoad.PrimaryKeyValue = PrimaryKeyValue;
            }

            SetBasePayLoad(eventDictionary, ref payLoad);
            if (CurrentOperationalState == DataPayLoad.Type.Insert)
            {
                handlerDo.OnInsert(payLoad, eventDictionary);
            }
            else
            {
                payLoad.PayloadType = DataPayLoad.Type.Update;
                handlerDo.OnUpdate(payLoad, eventDictionary);
            }
        }
        private void OnChangedField(IDictionary <string, object> eventDictionary)
        {
            DataPayLoad payLoad = BuildDataPayload(eventDictionary);

            payLoad.Subsystem     = DataSubSystem.SupplierSubsystem;
            payLoad.SubsystemName = MasterModuleConstants.ProviderSubsystemName;
            payLoad.PayloadType   = DataPayLoad.Type.Update;
            ChangeFieldHandlerDo <ISupplierData> handlerDo = new ChangeFieldHandlerDo <ISupplierData>(EventManager,
                                                                                                      DataSubSystem.SupplierSubsystem);

            var fieldName = string.Empty;

            SetBasePayLoad(eventDictionary, ref payLoad);
            // FIXME: replace conditional with polymorphism.
            if (CurrentOperationalState == DataPayLoad.Type.Insert)
            {
                payLoad.PayloadType = DataPayLoad.Type.Insert;
                handlerDo.OnInsert(payLoad, eventDictionary);
            }
            else
            {
                payLoad.PayloadType = DataPayLoad.Type.Update;
                handlerDo.OnUpdate(payLoad, eventDictionary);
            }
        }
Example #3
0
        /// <summary>
        /// Function associated to a changed command. When the you user thought the UI changes
        /// a control, it will trigger an ItemChangedCommand to be executed.
        /// </summary>
        /// <param name="dataObject">
        /// Object exposed to the view
        /// </param>
        /// <param name="eventDictionary">
        /// Dictionary related to the object
        /// </param>
        /// <param name="subSystem">
        /// Subsystem type: ie. BookingSubsystem
        /// </param>
        /// <param name="subsystemName">
        /// Subsystem name
        /// </param>
        /// <param name="objectPath">
        /// Path of the object
        /// </param>
        /// <typeparam name="DtoType">
        /// Exposed object type
        /// </typeparam>
        protected void OnChangedCommand <DtoType>(
            DtoType dataObject,
            IDictionary <string, object> eventDictionary,
            DataSubSystem subSystem,
            string subsystemName,
            string objectPath)
            where DtoType : class
        {
            var payLoad = BuildDataPayload(eventDictionary);

            payLoad.PayloadType     = DataPayLoad.Type.Update;
            payLoad.PrimaryKeyValue = PrimaryKeyValue;
            payLoad.HasDataObject   = true;
            payLoad.DataObject      = dataObject;
            payLoad.Sender          = ViewModelUri.ToString();
            payLoad.ObjectPath      = ViewModelUri;
            var handlerDo = new ChangeFieldHandlerDo <DtoType>(EventManager, subSystem);

            if (OperationalState == DataPayLoad.Type.Insert)
            {
                handlerDo.OnInsert(payLoad, eventDictionary);
            }
            else
            {
                payLoad.PayloadType = DataPayLoad.Type.Update;

                handlerDo.OnUpdate(payLoad, eventDictionary);
            }
        }
        public void Should_ReceiveAVehicle_InsertMessage()
        {
            // arrange
            var data = _veichleDataServices.Object.GetNewDo("123");

            IDictionary <string, string> viewModelQueries = new Dictionary <string, string>();
            var handlerDo = new ChangeFieldHandlerDo <IVehicleData>(_eventManager.Object,
                                                                    viewModelQueries, DataSubSystem.VehicleSubsystem);
            var payLoad = new DataPayLoad();
            IDictionary <string, object> eventDictionary = new Dictionary <string, object>();

            // act.
            handlerDo.OnInsert(payLoad, eventDictionary);
            // assert
            Assert.AreSame(payLoad, _carveBarViewModel.CurrentPayLoad);
        }
Example #5
0
        private void OnChangedField(IDictionary <string, object> eventDictionary)
        {
            DataPayLoad payLoad = BuildDataPayload(eventDictionary);

            payLoad.Subsystem     = DataSubSystem.CompanySubsystem;
            payLoad.SubsystemName = MasterModuleConstants.CompanySubSystemName;
            payLoad.PayloadType   = DataPayLoad.Type.Update;
            var uid = "client://" + Guid.ToString();

            payLoad.ObjectPath = new Uri(uid);
            ChangeFieldHandlerDo <CompanyDto> handlerDo = new ChangeFieldHandlerDo <CompanyDto>(EventManager, DataSubSystem.CompanySubsystem);


            if (CurrentOperationalState == DataPayLoad.Type.Insert)
            {
                handlerDo.OnInsert(payLoad, eventDictionary);
            }
            else
            {
                payLoad.PayloadType = DataPayLoad.Type.Update;
                handlerDo.OnUpdate(payLoad, eventDictionary);
            }
        }