Skip to content

Commit

Permalink
Initial add stock sample app
Browse files Browse the repository at this point in the history
  • Loading branch information
Lakerfield committed Aug 18, 2020
1 parent c767856 commit eaf5784
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 0 deletions.
Binary file added assets/alstroemeria-sansa.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions floriapp-webapi-examples.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30114.105
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FloriApp.ExampleApp", "src\FloriApp.ExampleApp\FloriApp.ExampleApp.csproj", "{4758FF02-FD17-4C8D-991E-F44F5745AB77}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4758FF02-FD17-4C8D-991E-F44F5745AB77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4758FF02-FD17-4C8D-991E-F44F5745AB77}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4758FF02-FD17-4C8D-991E-F44F5745AB77}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4758FF02-FD17-4C8D-991E-F44F5745AB77}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {EA37B974-EBFE-483D-B93F-CE43FF46750F}
EndGlobalSection
EndGlobal
20 changes: 20 additions & 0 deletions src/FloriApp.ExampleApp/Extensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Text;
using FloriApp.WebApi.Models;

namespace FloriApp.ExampleApp
{
public static class Extensions
{

public static void Add(this List<Feature> features, string key, string value)
{
features.Add(new Feature()
{
Key = key,
Value = value
});
}
}
}
12 changes: 12 additions & 0 deletions src/FloriApp.ExampleApp/FloriApp.ExampleApp.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FloriApp.WebApi" Version="1.0.0-CI-20200818-160935" />
</ItemGroup>

</Project>
83 changes: 83 additions & 0 deletions src/FloriApp.ExampleApp/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
using System;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using FloriApp.WebApi;
using FloriApp.WebApi.Models;

namespace FloriApp.ExampleApp
{
class Program
{
static async Task Main(string[] args)
{
Console.WriteLine("Hello FloriApp!");
Console.WriteLine();
var client = new FloriAppApiClient(new FloriAppApiOptions()
{
ApiBaseUrl = "https://testflori.app/",
ApiKey = "xxx",
});

var allowedCompanies = await client.CompaniesGet();
Console.WriteLine("The ApiKey has access to the following companies:");
foreach (var allowedCompany in allowedCompanies)
Console.WriteLine($"- {allowedCompany.Name} ({allowedCompany.Id})");
Console.WriteLine();

var company = allowedCompanies.First();
Console.WriteLine($"Using {company.Name} to create example stock");
var companyClient = client.AsCompany(company);

var stock = new Stock()
{
Vbn = "124039", // Alstroemeria Sansa
Date = DateTime.Today,
//Description = // override article name
//AddText = "super!", // additional text
Manufacturer = "8713783295847", // kweker
//Supplier = "",
Amount = 2,
ApE = 50,
Packing = "998", // emballage
Price = 0.29m, // piece price
Foto = "https://raw.githubusercontent.com/floriapp/webapi-examples/master/assets/alstroemeria-sansa.jpg",
};
stock.Features.Add("S20", "075"); // steellengte
stock.Features.Add("S21", "090"); // gewicht
stock.Features.Add("S05", "023"); // rijpheid
stock.Features.Add("L11", "010"); // stelen per bos
stock.Features.Add("S22", "005"); // aantal bloemknoppen
stock.Features.Add("S65", "008"); // voorbehandeling
stock.Features.Add("S97", "004"); // mps-a
stock.Features.Add("S62", "NL"); // country of origin
stock.Features.Add("S98", "A1"); // quality
stock.Features.Add("P02", "001"); // belicht
stock.Features.Add("V22", "005"); // exclusief


// send stock to server, and update local stock object
stock = await companyClient.StockPost(stock);

Console.WriteLine($"Created new stock with the following information:");
Console.WriteLine($"- Id: {stock.Id}");
Console.WriteLine($"- Date: {stock.Date}");
Console.WriteLine($"- Article: {stock.Description} / {stock.Article.Name}");
Console.WriteLine($"- Article trade name: {stock.Article.TradeName}");
Console.WriteLine($"- Vbn number: {stock.Vbn}");
Console.WriteLine($"- Vbn group: {stock.VbnGroup}");
Console.WriteLine($"- Additional text: {stock.AddText}");
Console.WriteLine($"- Manufacturer GLN: {stock.Manufacturer}");
Console.WriteLine($"- Supplier: {stock.Supplier}");
Console.WriteLine($"- Available pieces: {stock.PiecesAvailable}");
Console.WriteLine($"- Available: {stock.PiecesAvailable/stock.ApE} x {stock.ApE}");
Console.WriteLine($"- Price: {stock.Price}");
Console.WriteLine($"- Packing: {stock.Packing}");
foreach (var feature in stock.Features)
Console.WriteLine($"- {feature.Key}: {feature.Value}");
Console.WriteLine();


}
}
}

0 comments on commit eaf5784

Please sign in to comment.