Ejemplo n.º 1
0
        public async Task Should_Update_AValidVehicle()
        {
            // arrange.
            var vehicles = await _vehicleDataServices.GetPagedSummaryDoAsync(1, 2).ConfigureAwait(false);

            var vehicle        = vehicles.FirstOrDefault();
            var code           = vehicle.Code;
            var currentVehicle = await _vehicleDataServices.GetDoAsync(code).ConfigureAwait(false);

            // act
            currentVehicle.Value.DANOS = "UpperData not corrected";
            var configure = await _vehicleDataServices.SaveAsync(currentVehicle).ConfigureAwait(false);

            // now we can see if the currentVehicle is correct or not.
            var savedCheck = await _vehicleDataServices.GetDoAsync(vehicle.Code).ConfigureAwait(false);

            Assert.AreEqual(currentVehicle.Value.DANOS, savedCheck.Value.DANOS);
        }
Ejemplo n.º 2
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);
        }