Ejemplo n.º 1
0
 public async Task <Vendor> SaveVendor(Vendor pVendor)
 {
     if (pVendor.Id == Guid.Empty)
     {
         return(await mAsyncCLient.AddVendorAsync(pVendor));
     }
     return(await mAsyncCLient.EditVendorAsync(pVendor));
 }
Ejemplo n.º 2
0
        public async Task <BaseResultModel <Vendor> > CreateOrUpdate(
            Vendor pVendor)
        {
            var fErrors = Validate(pVendor);

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


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

            pVendor.Id = Guid.NewGuid();
            return(await TryVendorTask(_blue10.AddVendorAsync(pVendor)));
        }
Ejemplo n.º 3
0
        public async Task CreateOrUpdate_Create_Success(
            Vendor pVendorInput,
            Vendor pVendorResult,
            [Frozen] IBlue10AsyncClient pBlue10AsyncCLient,
            VendorService pVendorService)
        {
            // Setup data
            pVendorInput.Id = Guid.Empty;

            // Setup services
            pBlue10AsyncCLient.AddVendorAsync(Arg.Any <Vendor>()).Returns(pVendorResult);

            // Test
            var fResult = await pVendorService.CreateOrUpdate(pVendorInput);

            // Validate
            pBlue10AsyncCLient.Received(1);
            await pBlue10AsyncCLient.Received().AddVendorAsync(Arg.Is <Vendor>(x => x.Equals(pVendorInput)));

            fResult.Should().BeOfType <BaseResultModel <Vendor> >();
            fResult.ErrorMessage.Should().BeNull();
            fResult.Object.Should().Be(pVendorResult);
        }
Ejemplo n.º 4
0
 public Vendor AddVendor(Vendor pVendor) => mBlue10Async.AddVendorAsync(pVendor).Sync();