public async Task Should_Save_AValidClientValue()
        {
            using (IDbConnection dbConnection = SqlExecutor.OpenNewDbConnection())
            {
                // Arrange
                IEnumerable <CLIENTES1> value = await dbConnection.GetAllAsync <CLIENTES1>();

                var         singleValue = value.FirstOrDefault();
                IClientData data        = await _clientDataServices.GetDoAsync(singleValue.NUMERO_CLI);

                ClientViewObject viewObjectClient = data.Value;
                Assert.AreEqual(viewObjectClient.NUMERO_CLI, singleValue.NUMERO_CLI);
                viewObjectClient.APELLIDO2 = "Zoppi";
                data.Value = viewObjectClient;
                // Act
                bool retValue = await _clientDataServices.SaveAsync(data);

                IClientData dataValue = await _clientDataServices.GetDoAsync(viewObjectClient.NUMERO_CLI);

                // Assert
                Assert.IsTrue(retValue);
                Assert.AreEqual(dataValue.Value.NUMERO_CLI, data.Value.NUMERO_CLI);
                Assert.AreEqual(dataValue.Value.APELLIDO2, viewObjectClient.APELLIDO2);
            }
        }
        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);
            }
        }
Ejemplo n.º 3
0
 public VisitsViewObject()
 {
     VisitType      = new VisitTypeViewObject();
     ContactsSource = new ContactsViewObject();
     SellerSource   = new ResellerViewObject();
     ClientSource   = new ClientViewObject();
 }
Ejemplo n.º 4
0
        public async Task Should_Load_Client_Correctly()
        {
            // arrange
            string currentCode = string.Empty;

            using (IDbConnection db = _sqlExecutor.OpenNewDbConnection())
            {
                var cli = await db.GetPagedAsync <DataAccessLayer.DataObjects.CLIENTES1>(1, 2).ConfigureAwait(false);

                var value = cli.OrderByDescending(p => p.NUMERO_CLI).FirstOrDefault();
                if (value != null)
                {
                    currentCode = value.NUMERO_CLI;
                }
            }
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            ClientViewObject viewObject = await _clientDataLoader.LoadValueAsync(currentCode);

            stopwatch.Stop();
            var elapesed = stopwatch.ElapsedMilliseconds;

            Assert.AreEqual(viewObject.NUMERO_CLI, currentCode);
            Assert.NotNull(viewObject);
            Assert.NotNull(viewObject.Helper);
            Assert.Greater(viewObject.Helper.ClientPaymentForm.Count(), 0, "ClientPaymentForm");
            Assert.Greater(viewObject.Helper.LanguageDto.Count(), 0, "Language");
        }
Ejemplo n.º 5
0
        public IClientData GetNewDo(string code)
        {
            var value = new ClientViewObject {
                NUMERO_CLI = code, Numero = code, Code = code
            };
            IClientData varClientData = new Client(value);

            varClientData.Valid         = true;
            varClientData.Value.IsValid = true;
            varClientData.Value.IsNew   = true;
            return(varClientData);
        }
Ejemplo n.º 6
0
        private async Task <ObservableCollection <ClientTypeViewObject> > HandleUpperBar(object dataObject)
        {
            IHelperDataServices helperDataServices = DataServices.GetHelperDataServices();
            ClientViewObject    data = dataObject as ClientViewObject;
            var view = new ObservableCollection <ClientTypeViewObject>();

            if (data != null)
            {
                var value = await helperDataServices.GetSingleMappedAsyncHelper <ClientTypeViewObject, TIPOCLI>(data.NUMERO_CLI);

                view.Add(value);
            }
            return(view);
        }
Ejemplo n.º 7
0
        protected override async Task <DataPayLoad> HandleSaveOrUpdate(DataPayLoad payLoad)
        {
            bool             result     = false;
            bool             isInsert   = payLoad.PayloadType == DataPayLoad.Type.Insert;
            ClientViewObject clientData = payLoad.DataObject as ClientViewObject;

            // pre: DataServices and vehicle shall be present.
            if ((DataServices == null))
            {
                DataPayLoad nullDataPayLoad = new NullDataPayload();
                return(nullDataPayLoad);
            }
            if (clientData == null)
            {
                string message = (isInsert) ? "Error during the insert" : "Error during the update";
                SendError(message);
                // i return a null payload.
                return(new NullDataPayload());
            }
            // FIXME: check for the law of demeter.
            var clientDo = await DataServices.GetClientDataServices().GetDoAsync(clientData.NUMERO_CLI);

            if (clientDo == null)
            {
                payLoad.PayloadType = DataPayLoad.Type.Insert;
            }
            AbstractDomainWrapperFactory factory = AbstractDomainWrapperFactory.GetFactory(DataServices);
            IClientData clientWrapper            = await factory.CreateClientAsync(clientData).ConfigureAwait(false);

            clientWrapper.Value = clientData;
            result = await DataServices.GetClientDataServices().SaveAsync(clientWrapper).ConfigureAwait(false);             if (result)
            {
                payLoad.Sender               = ToolBarModule.NAME;
                payLoad.PayloadType          = DataPayLoad.Type.UpdateView;
                CurrentPayload               = payLoad;
                CurrentPayload.HasDataObject = true;
                CurrentPayload.DataObject    = clientDo;
                CurrentPayload.Subsystem     = payLoad.Subsystem;
            }
            else
            {
                string message = isInsert ? "Error during the insert" : "Error during the update";
                SendError(message);
            }
            return(payLoad);
        }
Ejemplo n.º 8
0
        /// <summary>
        ///  Create a client wrapper from a data transfer object.
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        static IClientData CreateClient(ClientViewObject dto)
        {
            var value = new Client(dto);

            return(value);
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Constructor of the client
 /// </summary>
 /// <param name="dto">Data object of the client</param>
 public Client(ClientViewObject dto)
 {
     _dto  = dto;
     Code  = dto.NUMERO_CLI;
     Valid = true;
 }
Ejemplo n.º 10
0
        public override async Task <IClientData> CreateClientAsync(ClientViewObject viewObject)
        {
            IClientData data = await _services.GetClientDataServices().GetDoAsync(viewObject.NUMERO_CLI).ConfigureAwait(false);

            return(data);
        }
Ejemplo n.º 11
0
        /// <summary>
        ///  Create a domain wrapper from a data transfer object. A domain wrapper has the responsability to handle ///thelifecycle of
        /// a data transfer object.
        /// </summary>
        /// <param name="viewObject">Data transfer object for clients</param>
        /// <returns></returns>
        public virtual async Task <IClientData> CreateClientAsync(ClientViewObject viewObject)
        {
            IClientData data = await _services.GetClientDataServices().GetDoAsync(viewObject.NUMERO_CLI);

            return(data);
        }