Exemple #1
0
 public async Task <VatCode> SaveVatCode(VatCode pVatCode)
 {
     if (pVatCode.Id == Guid.Empty)
     {
         return(await mAsyncCLient.AddVatCodeAsync(pVatCode));
     }
     return(await mAsyncCLient.EditVatCodeAsync(pVatCode));
 }
Exemple #2
0
        public async Task <BaseResultModel <VatCode> > CreateOrUpdate(VatCode pVatCode)
        {
            var fErrors = Validate(pVatCode);

            if (fErrors.Count > 0)
            {
                return(new BaseResultModel <VatCode>(null, string.Join(", ", fErrors)));
            }


            if (pVatCode.Id != Guid.Empty)
            {
                return(await TryVendorTask(_blue10.EditVatCodeAsync(pVatCode)));
            }

            pVatCode.Id = Guid.NewGuid();
            return(await TryVendorTask(_blue10.AddVatCodeAsync(pVatCode)));
        }
Exemple #3
0
        public async Task CreateOrUpdate_Update_Success(
            VatCode pVatCodeInput,
            VatCode pVatCodeResult,
            [Frozen] IBlue10AsyncClient pBlue10AsyncCLient,
            VatCodeService pVatCodeService)
        {
            // Setup services
            pBlue10AsyncCLient.EditVatCodeAsync(Arg.Any <VatCode>()).Returns(pVatCodeResult);

            // Test
            var fResult = await pVatCodeService.CreateOrUpdate(pVatCodeInput);

            // Validate
            pBlue10AsyncCLient.Received(1);
            await pBlue10AsyncCLient.Received().EditVatCodeAsync(Arg.Is <VatCode>(x => x.Equals(pVatCodeInput)));

            fResult.Should().BeOfType <BaseResultModel <VatCode> >();
            fResult.ErrorMessage.Should().BeNull();
            fResult.Object.Should().Be(pVatCodeResult);
        }
Exemple #4
0
 public VatCode EditVatCode(VatCode pVatCode) => mBlue10Async.EditVatCodeAsync(pVatCode).Sync();