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); }