Beispiel #1
0
 /// <summary>
 ///  Reitinialize the sql executor and all the services provided by this interface with
 ///  a new connection string.
 /// </summary>
 /// <param name="sqlExecutor">Executor to be used.</param>
 /// <param name="connectionValue">Connection value.</param>
 private void InitServices(ISqlExecutor sqlExecutor, string connectionValue = "")
 {
     if (!string.IsNullOrEmpty(connectionValue))
     {
         sqlExecutor.ConnectionString = connectionValue;
         TestConnection(sqlExecutor, connectionValue);
     }
     _executor                      = sqlExecutor;
     _supplierDataServices          = new SupplierDataAccessLayer(sqlExecutor);
     _helperDataServices            = new HelperDataAccessLayer(sqlExecutor);
     _commissionAgentDataServices   = new CommissionAgentAccessLayer(sqlExecutor);
     _vehicleDataServices           = new VehiclesDataAccessLayer(sqlExecutor);
     _settingsDataService           = new SettingsDataService(sqlExecutor);
     _clientDataServices            = new ClientDataAccessLayer(sqlExecutor);
     _officeDataService             = new OfficeDataService(sqlExecutor);
     _companyDataService            = new CompanyDataServices(sqlExecutor);
     _contractDataService           = new ContractDataServices(sqlExecutor);
     _invoiceDataService            = new InvoiceDataServices(sqlExecutor);
     _bookingDataService            = new BookingDataAccessLayer(sqlExecutor, null);
     _fareDataService               = new FareDataServices(sqlExecutor);
     _reservationRequestDataService = new ReservationRequestDataAccessLayer(sqlExecutor);
     _budgetDataService             = new BudgetDataAccessLayer(sqlExecutor);
     _bookingIncidentDataService    = new BookingIncidentDataAccessLayer(sqlExecutor);
     _userDataService               = new UserDataService(sqlExecutor);
 }
Beispiel #2
0
        /// <summary>
        ///  Constructor
        /// </summary>
        /// <param name="configurationService">This is the configurartion service</param>
        /// <param name="eventManager"> The event manager for sending/recieving messages from the view model</param>
        /// <param name="dialogService"></param>
        /// <param name="services">Data access layer interface</param>
        public VehicleInfoViewModel(IConfigurationService configurationService, IEventManager eventManager,
                                    IDialogService dialogService,
                                    IDataServices services, IRegionManager regionManager, IInteractionRequestController requestController) :
            base(eventManager, configurationService, services, dialogService, regionManager, requestController)
        {
            // by default is not initialized until it comes to Init completed.
            IsViewModelInitialized = false;
            SubSystem             = DataSubSystem.VehicleSubsystem;
            MailBoxHandler       += MessageHandler;
            _vehicleDataServices  = services.GetVehicleDataServices();
            _assistDataService    = services.GetAssistDataServices();
            ItemChangedCommand    = new DelegateCommand <object>(ChangeUnpack);
            MetaDataObject        = InitAssuranceObject();
            DataFieldCollection   = InitDataField();
            RevisionObject        = InitRevisionComposedFieldObjects();
            MaintenanceCollection = _maintenaince;
            _regionManager        = regionManager;
            _deleteEventHandler  += DeleteEventHandler;
            EventManager.RegisterObserverSubsystem(MasterModuleConstants.VehiclesSystemName, this);
            AssistCommand      = new DelegateCommand <object>(AssistCommandHelper);
            _queryStoreFactory = new QueryStoreFactory();
            _saveCommand       = new DelegateCommand <object>(OnSaveCommand);
            var gid = Guid.NewGuid();

            ViewModelUri = new Uri("karve://vehicle/viewmodel?id=" + gid.ToString());

            ActiveSubSystem();
        }
Beispiel #3
0
 /// <summary>
 ///  Save or execute a payload
 /// </summary>
 /// <param name="services"></param>
 /// <param name="manager"></param>
 /// <param name="payLoad"></param>
 public override void ExecutePayload(IDataServices services, IEventManager manager, ref DataPayLoad payLoad)
 {
     _vehicleDataServices    = services.GetVehicleDataServices();
     _payload                = payLoad;
     EventManager            = manager;
     DataServices            = services;
     _initializationNotifier = NotifyTaskCompletion.Create <DataPayLoad>(HandleSaveOrUpdate(payLoad), ExecutedPayloadHandler);
 }
Beispiel #4
0
        /// <summary>
        ///  This is the vehicle control view model.
        /// This is responsable for the opening new tabs.
        /// </summary>
        /// <param name="configurationService">Configuration service. It give us the global configuration</param>
        /// <param name="eventManager">EventManager. This is the eventManager</param>
        /// <param name="services">DataServices. This are the dataservices for this stuff.</param>
        /// <param name="container"></param>
        /// <param name="regionManager"></param>
        public VehiclesControlViewModel(IConfigurationService configurationService,
                                        IEventManager eventManager,
                                        IDataServices services,
                                        UnityContainer container,
                                        IRegionManager regionManager) : base(configurationService, eventManager, services, regionManager)
        {
            base.GridIdentifier  = KarveCommon.Generic.GridIdentifiers.VehicleGrid;
            _container           = container;
            _regionManager       = regionManager;
            _vehicleDataServices = DataServices.GetVehicleDataServices();
            OpenItemCommand      = new DelegateCommand <object>(OpenCurrentItem);
            AllowedGridColumns   = GenerateAllowedColumns();

            InitViewModel();
        }
Beispiel #5
0
 public void SetUp()
 {
     _dataServices = null;
     _serviceConf  = base.SetupConfigurationService();
     try
     {
         _sqlExecutor         = SetupSqlQueryExecutor();
         _dataServices        = new DataServiceImplementation(_sqlExecutor);
         _vehicleDataServices = _dataServices.GetVehicleDataServices();
     }
     catch (Exception e)
     {
         Assert.Fail(e.Message);
     }
 }
Beispiel #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="payLoad"></param>
        /// <returns></returns>
        protected override async Task <DataPayLoad> HandleSaveOrUpdate(DataPayLoad payLoad)
        {
            bool         result      = false;
            bool         isInsert    = payLoad.PayloadType == DataPayLoad.Type.Insert;
            IVehicleData vehicleData = (IVehicleData)payLoad.DataObject;

            // pre: DataServices and vehicle shall be present.
            if (DataServices == null)
            {
                DataPayLoad nullDataPayLoad = new NullDataPayload();
                return(nullDataPayLoad);
            }
            _vehicleDataServices = DataServices.GetVehicleDataServices();
            if (vehicleData == null)
            {
                string message = (payLoad.PayloadType == DataPayLoad.Type.Insert) ? "Error during the insert" : "Error during the update";
                ShowErrorMessage(message);
                // OnErrorExecuting?.Invoke(message);
            }
            // FIXME: unify the update and the insert.
            switch (payLoad.PayloadType)
            {
            case DataPayLoad.Type.Update:
            case DataPayLoad.Type.Insert:
            {
                result = await _vehicleDataServices.SaveAsync(vehicleData).ConfigureAwait(false);

                break;
            }
            }
            if (result)
            {
                payLoad.Sender      = ToolBarModule.NAME;
                payLoad.PayloadType = DataPayLoad.Type.UpdateView;
                CurrentPayload      = payLoad;
            }
            else
            {
                string message = isInsert ? "Error during the insert" : "Error during the update";
                ShowErrorMessage(message);
                //  OnErrorExecuting?.Invoke(message);
            }
            return(payLoad);
        }
Beispiel #7
0
 /// <summary>
 ///  Reitinialize the sql executor and all the services provided by this interface with
 ///  a new connection string.
 /// </summary>
 /// <param name="sqlExecutor">Executor to be used.</param>
 /// <param name="connectionValue">Connection value.</param>
 private void InitServices(ISqlExecutor sqlExecutor, string connectionValue = "")
 {
     if (!string.IsNullOrEmpty(connectionValue))
     {
         sqlExecutor.ConnectionString = connectionValue;
     }
     _executor                    = sqlExecutor;
     _supplierDataServices        = new SupplierDataAccessLayer(sqlExecutor);
     _helperDataServices          = new HelperDataAccessLayer(sqlExecutor);
     _commissionAgentDataServices = new CommissionAgentAccessLayer(sqlExecutor);
     _vehicleDataServices         = new VehiclesDataAccessLayer(sqlExecutor);
     _settingsDataService         = new SettingsDataService(sqlExecutor);
     _clientDataServices          = new ClientDataAccessLayer(sqlExecutor);
     _officeDataService           = new OfficeDataService(sqlExecutor);
     _companyDataService          = new CompanyDataServices(sqlExecutor);
     _contractDataService         = new ContractDataServices(sqlExecutor);
     _invoiceDataService          = new InvoiceDataServices(sqlExecutor);
     _assistDataService           = new AssistDataService(this);
 }