示例#1
0
        public async Task <InvoiceFileConnection> CreateAsync(InvoiceFileConnection invoiceFileConnection)
        {
            RequestInfo = new RequestInfo()
            {
                BaseUrl      = BaseUrl,
                Resource     = Resource,
                Indices      = Array.Empty <string>(),
                Method       = RequestMethod.Post,
                ResponseType = RequestResponseType.JSON
            };

            var entity = new List <InvoiceFileConnection>()
            {
                invoiceFileConnection
            };
            var result = await DoEntityRequest(entity).ConfigureAwait(false);

            return(result?.FirstOrDefault());
        }
示例#2
0
        public async Task <InvoiceFileConnection> UpdateAsync(InvoiceFileConnection invoiceFileConnection)
        {
            RequestInfo = new RequestInfo()
            {
                BaseUrl      = BaseUrl,
                Resource     = Resource,
                Indices      = new[] { invoiceFileConnection.Id },
                Method       = RequestMethod.Put,
                ResponseType = RequestResponseType.JSON
            };

            var limitedEntity = new InvoiceFileConnection()
            {
                IncludeOnSend = invoiceFileConnection.IncludeOnSend
            };

            var result = await DoEntityRequest(limitedEntity).ConfigureAwait(false);

            return(result);
        }
示例#3
0
        public void Test_InvoiceFileConnection_CRUD()
        {
            #region Arrange
            var tmpCustomer = new CustomerConnector().Create(new Customer()
            {
                Name = "TmpCustomer", CountryCode = "SE", City = "Testopolis"
            });
            var tmpArticle = new ArticleConnector().Create(new Article()
            {
                Description = "TmpArticle", Type = ArticleType.Stock, PurchasePrice = 10
            });
            var invoiceConnector = new InvoiceConnector();
            var tmpInvoice       = invoiceConnector.Create(new Invoice()
            {
                CustomerNumber = tmpCustomer.CustomerNumber,
                InvoiceDate    = new DateTime(2020, 1, 20),
                DueDate        = new DateTime(2020, 6, 20),
                InvoiceRows    = new List <InvoiceRow>()
                {
                    new InvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, DeliveredQuantity = 2, Price = 10
                    },
                }
            });
            var inboxConnector = new InboxConnector();
            var tmpFile        = inboxConnector.UploadFile("tmpInvoiceFile.pdf", Resource.invoice_example, StaticFolders.CustomerInvoices);
            #endregion Arrange

            IInvoiceFileConnectionConnector connector = new InvoiceFileConnectionConnector();

            #region CREATE
            var newInvoiceFileConnection = new InvoiceFileConnection()
            {
                EntityId      = tmpInvoice.DocumentNumber,
                FileId        = tmpFile.ArchiveFileId,
                IncludeOnSend = false,
                EntityType    = EntityType.Invoice
            };

            var createdInvoiceFileConnection = connector.Create(newInvoiceFileConnection);
            MyAssert.HasNoError(connector);
            Assert.AreEqual(false, createdInvoiceFileConnection.IncludeOnSend);

            #endregion CREATE

            #region UPDATE

            createdInvoiceFileConnection.IncludeOnSend = true;

            var updatedInvoiceFileConnection = connector.Update(createdInvoiceFileConnection);
            MyAssert.HasNoError(connector);
            Assert.AreEqual(true, updatedInvoiceFileConnection.IncludeOnSend);

            #endregion UPDATE

            #region READ / GET

            var retrievedInvoiceFileConnection = connector.GetConnections(createdInvoiceFileConnection.EntityId, createdInvoiceFileConnection.EntityType)?.FirstOrDefault();
            MyAssert.HasNoError(connector);
            Assert.AreEqual(true, retrievedInvoiceFileConnection?.IncludeOnSend);

            #endregion READ / GET

            #region DELETE

            connector.Delete(createdInvoiceFileConnection.Id);
            MyAssert.HasNoError(connector);

            retrievedInvoiceFileConnection = connector.GetConnections(createdInvoiceFileConnection.EntityId, createdInvoiceFileConnection.EntityType)?.FirstOrDefault();
            Assert.AreEqual(null, retrievedInvoiceFileConnection, "Entity still exists after Delete!");

            #endregion DELETE

            #region Delete arranged resources
            new CustomerConnector().Delete(tmpCustomer.CustomerNumber);
            new ArticleConnector().Delete(tmpArticle.ArticleNumber);
            new InboxConnector().DeleteFile(tmpFile.Id);
            #endregion Delete arranged resources
        }
示例#4
0
 /// <summary>
 /// Creates a new invoiceFileConnection
 /// </summary>
 /// <param name="invoiceFileConnection">The invoiceFileConnection to create</param>
 /// <returns>The created invoiceFileConnection</returns>
 public InvoiceFileConnection Create(InvoiceFileConnection invoiceFileConnection)
 {
     return(CreateAsync(invoiceFileConnection).Result);
 }