This commit is contained in:
Frede Hundewadt 2022-06-23 16:56:33 +02:00
parent 1225760d7f
commit f1deb49d0d
13 changed files with 222 additions and 4 deletions

View file

@ -0,0 +1,52 @@
@if (History.Any())
{
<table class="table">
<thead>
<tr>
<th scope="col">
Dato
</th>
<th scope="col">
Antal
</th>
<th scope="col">
Vare
</th>
<th scope="col">
Varenummer
</th>
<th scope="col" class="align-content-end">
Rabat
</th>
<th scope="col" class="align-content-end">
Pris
</th>
</tr>
</thead>
<tbody>
@foreach (var line in History)
{
<tr class="align-content-center">
<td>
@line.DeliverDate
</td>
<td>
@line.Quantity
</td>
<td>
@line.Name
</td>
<td>
@line.Sku
</td>
<td class="align-content-end">
@(line.Discount)%
</td>
<td class="align-content-end">
@line.Price
</td>
</tr>
}
</tbody>
</table>
}

View file

@ -0,0 +1,9 @@
using Microsoft.AspNetCore.Components;
using Wonky.Entity.DTO;
namespace Wonky.Client.Components;
public partial class HistoryTableComponent
{
[Parameter] public List<ProductHistoryView> History { get; set; }
}

View file

@ -0,0 +1,34 @@
@if (Products.Any())
{
<table class="table">
<thead>
<tr>
<th scope="col">
Product
</th>
<th scope="col">
Varenummer
</th>
<th scope="col">
Antal
</th>
</tr>
</thead>
<tbody>
@foreach (var product in Products)
{
<tr class="align-content-center">
<td>
@product.Name
</td>
<td>
@product.Sku
</td>
<td>
@product.Quantity
</td>
</tr>
}
</tbody>
</table>
}

View file

@ -0,0 +1,9 @@
using Microsoft.AspNetCore.Components;
using Wonky.Entity.DTO;
namespace Wonky.Client.Components;
public partial class InventoryTableComponent
{
[Parameter] public List<ProductInventoryView> Products { get; set; }
}

View file

@ -0,0 +1,72 @@
using System.Net.Http.Json;
using System.Text.Json;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Options;
using Wonky.Client.Pages;
using Wonky.Entity.Configuration;
using Wonky.Entity.DTO;
using Wonky.Entity.Views;
namespace Wonky.Client.HttpRepository;
public class HistoryHttpRepository : IHistoryHttpRepository
{
private readonly JsonSerializerOptions _options = new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
};
private readonly NavigationManager _navigation;
private ILogger<HistoryHttpRepository> _logger;
private readonly HttpClient _client;
private readonly ApiConfig _apiConfig;
public HistoryHttpRepository(HttpClient client,
ILogger<HistoryHttpRepository> logger,
NavigationManager navigation, IOptions<ApiConfig> configuration)
{
_client = client;
_logger = logger;
_navigation = navigation;
_apiConfig = configuration.Value;
}
// public async Task<List<TaskItemView>> GetTaskList()
// {
// return await _client.GetFromJsonAsync<List<TaskItemView>>($"{_apiConfig.TaskItemEndpoint}");
// }
//
// public async Task CreateTaskItem(TaskItemView taskItem)
// {
// await _client.PostAsJsonAsync($"{_apiConfig.TaskItemEndpoint}", taskItem);
// }
//
// public async Task<TaskItemView> GetTaskItem(string taskItemId)
// {
// return await _client.GetFromJsonAsync<TaskItemView>($"{_apiConfig.TaskItemEndpoint}/{taskItemId}");
// }
public async Task<List<ProductInventoryView>> GetProductInventory(string companyId)
{
return await _client.GetFromJsonAsync<List<ProductInventoryView>>(
$"{_apiConfig.CompanyEndpoint}/{companyId}/{_apiConfig.HistoryEndpoint}/products");
}
public async Task<List<ProductHistoryView>> GetProductHistory(string companyId)
{
return await _client.GetFromJsonAsync<List<ProductHistoryView>>(
$"{_apiConfig.CompanyEndpoint}/{companyId}/{_apiConfig.HistoryEndpoint}/products");
}
public async Task<List<ProductHistoryView>> GetProductHistory(string companyId, string sku)
{
return await _client.GetFromJsonAsync<List<ProductHistoryView>>(
$"{_apiConfig.CompanyEndpoint}/{companyId}/{_apiConfig.HistoryEndpoint}/products");
}
public async Task<string> UpdateProductHistory(string companyId, string syncDate)
{
return await _client.GetStringAsync($"{_apiConfig.CompanyEndpoint}/{companyId}/{syncDate}");
}
}

View file

@ -0,0 +1,12 @@
using Wonky.Client.Pages;
using Wonky.Entity.DTO;
namespace Wonky.Client.HttpRepository;
public interface IHistoryHttpRepository
{
Task<List<ProductInventoryView>> GetProductInventory(string companyId);
Task<List<ProductHistoryView>> GetProductHistory(string companyId);
Task<List<ProductHistoryView>> GetProductHistory(string companyId, string sku);
Task<string> UpdateProductHistory(string companyId, string syncDate);
}

View file

@ -200,6 +200,12 @@
<div class="col">
<a class="btn btn-primary" href="/companies">Til Oversigt</a>
</div>
<div class="col">
<a class="btn btn-success" href="/companies/@_company.CompanyId/products">Produktkøb</a>
</div>
<div class="col">
<a class="btn btn-success" href="/companies/@_company.CompanyId/history">Varelinjer</a>
</div>
<div class="col">
<ActivityButton CompanyId="@_company.CompanyId" Enabled="@_company.ValidVat"></ActivityButton>
</div>

View file

@ -0,0 +1 @@
@page "/companies/{CompanyId}/products"

View file

@ -0,0 +1,6 @@
namespace Wonky.Client.Pages;
public partial class ProductInventory
{
}

View file

@ -36,7 +36,6 @@
"activityEndpoint": "api/v2/crm/salesReps/sales",
"reportEndpoint": "api/v2/crm/salesReps/reports",
"taskItemEndpoint": "api/v2/crm/salesRps/tasks",
"productHistoryEndpoint": "products",
"accountHistoryEndpoint": "account"
"historyEndpoint": "products"
}
}

View file

@ -33,6 +33,5 @@ public class ApiConfig
public string ActivityEndpoint { get; set; } = "";
public string ReportEndpoint { get; set; } = "";
public string TaskItemEndpoint { get; set; } = "";
public string ProductHistoryEndpoint { get; set; } = "";
public string AccountHistoryEndpoint { get; set; } = "";
public string HistoryEndpoint { get; set; } = "";
}

View file

@ -0,0 +1,11 @@
namespace Wonky.Entity.DTO;
public class ProductHistoryView
{
public string DeliverDate { get; set; } = "";
public string Name { get; set; } = "";
public string Sku { get; set; } = "";
public int Quantity { get; set; }
public decimal Price { get; set; }
public decimal Discount { get; set; }
}

View file

@ -0,0 +1,8 @@
namespace Wonky.Entity.DTO;
public class ProductInventoryView
{
public string Name { get; set; } = "";
public string Sku { get; set; } = "";
public int Quantity { get; set; }
}