public async Task <GLAccount> SaveGLAccount(GLAccount pGLAccount) { if (pGLAccount.Id == Guid.Empty) { return(await mAsyncCLient.AddGLAccountAsync(pGLAccount)); } return(await mAsyncCLient.EditGLAccountAsync(pGLAccount)); }
public async Task <BaseResultModel <GLAccount> > CreateOrUpdate(GLAccount pGlAccount) { var fErrors = Validate(pGlAccount); if (fErrors.Count > 0) { return(new BaseResultModel <GLAccount>(null, string.Join(", ", fErrors))); } if (pGlAccount.Id != Guid.Empty) { return(await TryVendorTask(_blue10.EditGLAccountAsync(pGlAccount))); } pGlAccount.Id = Guid.NewGuid(); return(await TryVendorTask(_blue10.AddGLAccountAsync(pGlAccount))); }
public async Task CreateOrUpdate_Create_Success( GLAccount pGLAccountInput, GLAccount pGLAccountResult, [Frozen] IBlue10AsyncClient pBlue10AsyncCLient, GLAccountService pGLAccountService) { // Setup data pGLAccountInput.Id = Guid.Empty; // Setup services pBlue10AsyncCLient.AddGLAccountAsync(Arg.Any <GLAccount>()).Returns(pGLAccountResult); // Test var fResult = await pGLAccountService.CreateOrUpdate(pGLAccountInput); // Validate pBlue10AsyncCLient.Received(1); await pBlue10AsyncCLient.Received().AddGLAccountAsync(Arg.Is <GLAccount>(x => x.Equals(pGLAccountInput))); fResult.Should().BeOfType <BaseResultModel <GLAccount> >(); fResult.ErrorMessage.Should().BeNull(); fResult.Object.Should().Be(pGLAccountResult); }
public GLAccount AddGLAccount(GLAccount pGLAccount) => mBlue10Async.AddGLAccountAsync(pGLAccount).Sync();