public async Task <Vendor> SaveVendor(Vendor pVendor) { if (pVendor.Id == Guid.Empty) { return(await mAsyncCLient.AddVendorAsync(pVendor)); } return(await mAsyncCLient.EditVendorAsync(pVendor)); }
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))); }
public async Task CreateOrUpdate_Update_Success( Vendor pVendorInput, Vendor pVendorResult, [Frozen] IBlue10AsyncClient pBlue10AsyncCLient, VendorService pVendorService) { // Setup services pBlue10AsyncCLient.EditVendorAsync(Arg.Any <Vendor>()).Returns(pVendorResult); // Test var fResult = await pVendorService.CreateOrUpdate(pVendorInput); // Validate pBlue10AsyncCLient.Received(1); await pBlue10AsyncCLient.Received().EditVendorAsync(Arg.Is <Vendor>(x => x.Equals(pVendorInput))); fResult.Should().BeOfType <BaseResultModel <Vendor> >(); fResult.ErrorMessage.Should().BeNull(); fResult.Object.Should().Be(pVendorResult); }
public Vendor EditVendor(Vendor pVendor) => mBlue10Async.EditVendorAsync(pVendor).Sync();