/// <summary> /// ClientsInfoViewModel constructor. /// </summary> /// <param name="eventManager">Event manager</param> /// <param name="configurationService">Configuration service</param> /// <param name="dataServices">Data Service</param> /// <param name="manager">Region Manager</param> public ClientsInfoViewModel(IEventManager eventManager, IConfigurationService configurationService, IDataServices dataServices, IDialogService dialogService, IRegionManager manager, IInteractionRequestController controller) : base(eventManager, configurationService, dataServices, dialogService, manager, controller) { base.ConfigureAssist(); ConfigurationService = configurationService; MailBoxHandler += MessageHandler; IsVisible = Visibility.Collapsed; EventManager.RegisterObserverSubsystem(MasterModuleConstants.ClientSubSystemName, this); InitVmCommands(); ClientInfoRightRegionName = CreateNameRegion("RightRegion"); DriverZoneRegionName = CreateNameRegion("DriverZoneRegion"); StateVisible = true; _onBranchesPrimaryKey += ClientOnBranchesPrimaryKey; _onContactsPrimaryKey += ClientOnContactsPrimaryKey; _clientDataServices = dataServices.GetClientDataServices(); _clientData = _clientDataServices.GetNewDo("0"); eventHandler += OnDriverUpdate; DefaultPageSize = 50; ViewModelUri = new Uri("karve://client/viewmodel?id=" + Guid.ToString()); ActiveSubSystem(); _initialized = false; }
public async Task Should_Insert_A_NewClient() { using (IDbConnection dbConnection = SqlExecutor.OpenNewDbConnection()) { IEnumerable <CLIENTES1> value = await dbConnection.GetPagedAsync <CLIENTES1>(1, 10); var singleValue = value.FirstOrDefault(); IClientData data = await _clientDataServices.GetDoAsync(singleValue.NUMERO_CLI); ClientViewObject viewObjectClient = data.Value; var identifier = _clientDataServices.GetNewId(); IClientData newClient = _clientDataServices.GetNewDo(identifier); newClient.Value.NOMBRE = "Giorgio"; newClient.Value.APELLIDO1 = "Zoppi"; newClient.Value.APELLIDO2 = "Pietra"; bool retValue = await _clientDataServices.SaveAsync(newClient); Assert.IsTrue(retValue); IClientData newClientData = await _clientDataServices.GetDoAsync(newClient.Value.NUMERO_CLI); // assert ClientViewObject viewObject = newClientData.Value; Assert.AreEqual(viewObject.NUMERO_CLI, newClient.Value.NUMERO_CLI); Assert.AreEqual(viewObject.NOMBRE, newClient.Value.NOMBRE); Assert.AreEqual(viewObject.APELLIDO1, newClient.Value.APELLIDO1); Assert.AreEqual(viewObject.APELLIDO2, newClient.Value.APELLIDO2); } }
/// <summary> /// Craft a new item in the view model. Opening a new form. /// </summary> protected override void NewItem() { var name = KarveLocale.Properties.Resources.ClientsControlViewModel_NewItem_NuevoCliente; var code = _clientDataServices.GetNewId(); var viewNameValue = name + "." + code; Navigate(code, viewNameValue); var currentPayload = BuildShowPayLoadDo(viewNameValue); currentPayload.Subsystem = DataSubSystem.ClientSubsystem; currentPayload.PayloadType = DataPayLoad.Type.Insert; currentPayload.PrimaryKeyValue = code; currentPayload.HasDataObject = true; currentPayload.DataObject = _clientDataServices.GetNewDo(code); currentPayload.Sender = EventSubsystem.ClientSummaryVm; EventManager.NotifyObserverSubsystem(MasterModuleConstants.ClientSubSystemName, currentPayload); }