This commit is contained in:
Frede Hundewadt 2022-04-18 11:02:03 +02:00
parent 8ea978668d
commit 6724c2b6b7
43 changed files with 244 additions and 390 deletions

View file

@ -22,7 +22,7 @@ namespace Wonky.Client.Components
{
public partial class CompanyTable
{
[Parameter] public List<CompanyDto> Companies { get; set; } = new();
[Parameter] public List<DtoNgCrmCompany> Companies { get; set; } = new();
[Parameter] public EventCallback<string> OnDelete { get; set; }
[Parameter] public EventCallback<string> OnSelect { get; set; }
[Inject] public NavigationManager NavManager { get; set; }

View file

@ -22,7 +22,7 @@ namespace Wonky.Client.Components;
public partial class ItemTable
{
[Parameter] public List<SalesItemDto> SalesItems { get; set; } = new();
[Parameter] public List<NgSalesItemView> SalesItems { get; set; } = new();
[Inject] private IToastService ToastService { get; set; }
private void AddToDraft()
{

View file

@ -54,7 +54,7 @@ public class CompanyHttpRepository : ICompanyHttpRepository
_apiConfig = apiConfig.Value;
}
public async Task<PagingResponse<CompanyDto>> GetCompaniesPaged(CompanyPagingParams pagingParameters)
public async Task<PagingResponse<DtoNgCrmCompany>> GetCompaniesPaged(CompanyPagingParams pagingParameters)
{
var queryString = new Dictionary<string, string>
{
@ -70,37 +70,37 @@ public class CompanyHttpRepository : ICompanyHttpRepository
var content = await response.Content.ReadAsStringAsync();
var pagingResponse = new PagingResponse<CompanyDto>
var pagingResponse = new PagingResponse<DtoNgCrmCompany>
{
Items = JsonSerializer.Deserialize<List<CompanyDto>>(content, _options),
Items = JsonSerializer.Deserialize<List<DtoNgCrmCompany>>(content, _options),
MetaData = JsonSerializer.Deserialize<MetaData>(response.Headers.GetValues("X-Pagination").First(), _options)
};
return pagingResponse;
}
public async Task<CompanyDto> GetCompanyByAccount(string accountNumber)
public async Task<DtoNgCrmCompany> GetCompanyByAccount(string accountNumber)
{
var company = await _client.GetFromJsonAsync<CompanyDto>($"{_apiConfig.CrmCompanies}/account/{accountNumber}");
return company ?? new CompanyDto();
var company = await _client.GetFromJsonAsync<DtoNgCrmCompany>($"{_apiConfig.CrmCompanies}/account/{accountNumber}");
return company ?? new DtoNgCrmCompany();
}
public async Task<CompanyDto> GetCompanyById(string companyId)
public async Task<DtoNgCrmCompany> GetCompanyById(string companyId)
{
var company = await _client.GetFromJsonAsync<CompanyDto>($"{_apiConfig.CrmCompanies}/{companyId}");
return company ?? new CompanyDto();
var company = await _client.GetFromJsonAsync<DtoNgCrmCompany>($"{_apiConfig.CrmCompanies}/{companyId}");
return company ?? new DtoNgCrmCompany();
}
public async Task<string> CreateCompany(CompanyDto companyDto)
public async Task<string> CreateCompany(DtoNgCrmCompany dtoNgCrmCompany)
{
var response = await _client.PostAsJsonAsync($"{_apiConfig.CrmCompanies}", companyDto);
var response = await _client.PostAsJsonAsync($"{_apiConfig.CrmCompanies}", dtoNgCrmCompany);
var content = await response.Content.ReadAsStringAsync();
var result = JsonSerializer.Deserialize<CompanyDto>(content);
var result = JsonSerializer.Deserialize<DtoNgCrmCompany>(content);
return result.CompanyId;
}
public async Task UpdateCompany(CompanyDto companyDto)
public async Task UpdateCompany(DtoNgCrmCompany dtoNgCrmCompany)
{
await _client.PutAsJsonAsync($"{_apiConfig.CrmCompanies}/{companyDto.CompanyId}", companyDto);
await _client.PutAsJsonAsync($"{_apiConfig.CrmCompanies}/{dtoNgCrmCompany.CompanyId}", dtoNgCrmCompany);
}
public async Task DeleteCompany(string companyId)

View file

@ -22,10 +22,10 @@ namespace Wonky.Client.HttpRepository;
public interface ICompanyHttpRepository
{
Task<PagingResponse<CompanyDto>> GetCompaniesPaged(CompanyPagingParams pagingParameters);
Task<CompanyDto> GetCompanyByAccount(string accountNumber);
Task<CompanyDto> GetCompanyById(string companyId);
Task<string> CreateCompany(CompanyDto companyDto);
Task UpdateCompany(CompanyDto companyDto);
Task<PagingResponse<DtoNgCrmCompany>> GetCompaniesPaged(CompanyPagingParams pagingParameters);
Task<DtoNgCrmCompany> GetCompanyByAccount(string accountNumber);
Task<DtoNgCrmCompany> GetCompanyById(string companyId);
Task<string> CreateCompany(DtoNgCrmCompany dtoNgCrmCompany);
Task UpdateCompany(DtoNgCrmCompany dtoNgCrmCompany);
Task DeleteCompany(string companyId);
}

View file

@ -22,6 +22,6 @@ namespace Wonky.Client.HttpRepository;
public interface ISalesItemHttpRepository
{
Task<PagingResponse<SalesItemDto>> GetSalesItemsPaged(CatalogPagingParams pagingParameters);
Task<SalesItemDto> GetSalesItem(string id);
Task<PagingResponse<NgSalesItemView>> GetSalesItemsPaged(CatalogPagingParams pagingParameters);
Task<NgSalesItemView> GetSalesItem(string id);
}

View file

@ -51,7 +51,7 @@ public class SalesItemHttpRepository : ISalesItemHttpRepository
_apiConfig = configuration.Value;
}
public async Task<PagingResponse<SalesItemDto>> GetSalesItemsPaged(CatalogPagingParams pagingParameters)
public async Task<PagingResponse<NgSalesItemView>> GetSalesItemsPaged(CatalogPagingParams pagingParameters)
{
var queryString = new Dictionary<string, string>
{
@ -67,19 +67,19 @@ public class SalesItemHttpRepository : ISalesItemHttpRepository
var content = await response.Content.ReadAsStringAsync();
var pagingResponse = new PagingResponse<SalesItemDto>
var pagingResponse = new PagingResponse<NgSalesItemView>
{
Items = JsonSerializer.Deserialize<List<SalesItemDto>>(content, _options),
Items = JsonSerializer.Deserialize<List<NgSalesItemView>>(content, _options),
MetaData = JsonSerializer.Deserialize<MetaData>(
response.Headers.GetValues("X-Pagination").First(), _options)
};
return pagingResponse;
}
public async Task<SalesItemDto> GetSalesItem(string id)
public async Task<NgSalesItemView> GetSalesItem(string id)
{
var salesItem = await _client
.GetFromJsonAsync<SalesItemDto>($"{_apiConfig.PriceCatalog}/{id}");
return salesItem ?? new SalesItemDto();
.GetFromJsonAsync<NgSalesItemView>($"{_apiConfig.PriceCatalog}/{id}");
return salesItem ?? new NgSalesItemView();
}
}

View file

@ -5,31 +5,20 @@ namespace Wonky.Client.Models;
public class DraftItem
{
public int Quantity { get; set; }
public SalesItemDto Item { get; set; }
public NgSalesItemView Item { get; set; }
public decimal Price { get; set; }
public decimal Discount { get; set; }
public decimal Total
{
get
{
var price = (from x in Item.Rates where x.Quantity == Quantity.ToString() select x.Rate).First();
if (string.IsNullOrWhiteSpace(price))
price = Item.Rates[0].Rate;
Price = Convert.ToDecimal(price);
return (Price - Price * Discount / 100) * Quantity;
}
}
public decimal LineTotal => (Price - Price * Discount / 100) * Quantity;
}
public class Draft
{
public List<DraftItem> Items { get; set; } = new List<DraftItem>();
public List<DraftItem> Items { get; set; } = new ();
public decimal Total
{
get
{
return Items.Sum(item => item.Total);
return Items.Sum(item => item.LineTotal);
}
}
public DateTime LastAccessed { get; set; }

View file

@ -1,28 +0,0 @@
// Copyright (C) 2022 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the Affero GNU General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// Affero GNU General Public License for more details.
//
// You should have received a copy of the Affero GNU General Public License
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
//
using System.Collections.Generic;
namespace Wonky.Client.Models
{
public class Quote
{
public int QuoteId { get; set; }
public string CompanyId { get; set; } = "";
public string Name { get; set; } = "";
public string EMail { get; set; } = "";
public List<QuoteItem> Items { get; set; } = new();
}
}

View file

@ -1,24 +0,0 @@
// Copyright (C) 2022 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the Affero GNU General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// Affero GNU General Public License for more details.
//
// You should have received a copy of the Affero GNU General Public License
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
//
namespace Wonky.Client.Models;
public class QuoteItem
{
public string Sku { get; set; } = "";
public string Text { get; set; } = "";
public int Qty { get; set; }
public decimal Price { get; set; }
}

View file

@ -57,7 +57,7 @@
<div class="card bg-light">
<EditForm EditContext="_createCompany" OnValidSubmit="Create" class="card-body">
<DataAnnotationsValidator />
<InputText type="hidden" id="salesRepId" @bind-Value="_companyDto.SalesRepId"/>
<InputText type="hidden" id="salesRepId" @bind-Value="_dtoNgCrmCompany.SalesRepId"/>
<table class="table">
<thead>
@ -67,73 +67,73 @@
<th scope="row">Reg.nr.</th>
<td class="state"><DisplayStateComponent StateClass="@RegState"></DisplayStateComponent></td>
<td>
<InputText id="vatNumber" class="form-control" @bind-Value="_companyDto.VatNumber"/>
<InputText id="vatNumber" class="form-control" @bind-Value="_dtoNgCrmCompany.VatNumber"/>
</td>
</tr>
<tr>
<th scope="row">Firmanavn</th>
<td></td>
<td>
<InputText id="name" class="form-control" @bind-Value="_companyDto.Name"/>
<ValidationMessage For="@(() => _companyDto.Name)"></ValidationMessage>
<InputText id="name" class="form-control" @bind-Value="_dtoNgCrmCompany.Name"/>
<ValidationMessage For="@(() => _dtoNgCrmCompany.Name)"></ValidationMessage>
</td>
</tr>
<tr>
<th scope="row">Conavn</th>
<td></td>
<td>
<InputText id="address1" class="form-control" @bind-Value="_companyDto.Address1"/>
<InputText id="address1" class="form-control" @bind-Value="_dtoNgCrmCompany.Address1"/>
</td>
</tr>
<tr>
<th scope="row">Adresse</th>
<td></td>
<td>
<InputText id="address2" class="form-control" @bind-Value="_companyDto.Address2"/>
<InputText id="address2" class="form-control" @bind-Value="_dtoNgCrmCompany.Address2"/>
</td>
</tr>
<tr>
<th scope="row">Postnr</th>
<td></td>
<td>
<InputText id="zipCode" class="form-control" @bind-Value="_companyDto.ZipCode"/>
<ValidationMessage For="@(() => _companyDto.ZipCode)"></ValidationMessage>
<InputText id="zipCode" class="form-control" @bind-Value="_dtoNgCrmCompany.ZipCode"/>
<ValidationMessage For="@(() => _dtoNgCrmCompany.ZipCode)"></ValidationMessage>
</td>
</tr>
<tr>
<th scope="row">Bynavn</th>
<td></td>
<td>
<InputText id="city" class="form-control" @bind-Value="_companyDto.City"/>
<ValidationMessage For="@(() => _companyDto.City)"></ValidationMessage>
<InputText id="city" class="form-control" @bind-Value="_dtoNgCrmCompany.City"/>
<ValidationMessage For="@(() => _dtoNgCrmCompany.City)"></ValidationMessage>
</td>
</tr>
<tr>
<th scope="row">Telefon</th>
<td></td>
<td>
<InputText id="phone" class="form-control" @bind-Value="_companyDto.Phone"/>
<InputText id="phone" class="form-control" @bind-Value="_dtoNgCrmCompany.Phone"/>
</td>
</tr>
<tr>
<th scope="row">Mobil</th>
<td></td>
<td>
<InputText id="mobile" class="form-control" @bind-Value="_companyDto.Mobile"/>
<InputText id="mobile" class="form-control" @bind-Value="_dtoNgCrmCompany.Mobile"/>
</td>
</tr>
<tr>
<th scope="row">Email</th>
<td></td>
<td>
<InputText id="email" class="form-control" @bind-Value="_companyDto.Email"/>
<InputText id="email" class="form-control" @bind-Value="_dtoNgCrmCompany.Email"/>
</td>
</tr>
<tr>
<th scope="row">Attention</th>
<td></td>
<td>
<InputText id="attention" class="form-control" @bind-Value="_companyDto.Attention"/>
<InputText id="attention" class="form-control" @bind-Value="_dtoNgCrmCompany.Attention"/>
</td>
</tr>
</tbody>

View file

@ -43,7 +43,7 @@ namespace Wonky.Client.Pages
[Inject] public HttpInterceptorService Interceptor { get; set; }
[Inject] public VatInfoLookupService VatInfoLookupService { get; set; }
private List<VirkRegInfo> VInfos { get; set; } = new();
private CompanyDto _companyDto = new();
private DtoNgCrmCompany _dtoNgCrmCompany = new();
private VirkRegInfo _virkRegInfo = new();
private EditContext _createCompany;
private bool _formInvalid = true;
@ -51,12 +51,12 @@ namespace Wonky.Client.Pages
protected override async Task OnInitializedAsync()
{
_createCompany = new EditContext(_companyDto);
_createCompany = new EditContext(_dtoNgCrmCompany);
_createCompany.OnFieldChanged += HandleFieldChanged;
var ux = await StorageService.GetItemAsync<UserInfo>("_ux");
_companyDto.SalesRepId = ux.Id;
_companyDto.CountryCode = ux.CountryCode;
var ux = await StorageService.GetItemAsync<UserInfoView>("_ux");
_dtoNgCrmCompany.SalesRepId = ux.Id;
_dtoNgCrmCompany.CountryCode = ux.CountryCode;
Interceptor.RegisterEvent();
Interceptor.RegisterBeforeSendEvent();
}
@ -91,23 +91,23 @@ namespace Wonky.Client.Pages
{
_virkRegInfo = (from x in VInfos where x.VatNumber == vatNumber select x).First();
RegState = _virkRegInfo.States[^1].State == "NORMAL" ? "the-good" : "the-ugly";
_companyDto.Name = _virkRegInfo.Name;
_companyDto.Address1 = _virkRegInfo.CoName;
_companyDto.Address2 = _virkRegInfo.Address;
_companyDto.ZipCode = _virkRegInfo.ZipCode;
_companyDto.City = _virkRegInfo.City;
_companyDto.VatNumber = _virkRegInfo.VatNumber;
_dtoNgCrmCompany.Name = _virkRegInfo.Name;
_dtoNgCrmCompany.Address1 = _virkRegInfo.CoName;
_dtoNgCrmCompany.Address2 = _virkRegInfo.Address;
_dtoNgCrmCompany.ZipCode = _virkRegInfo.ZipCode;
_dtoNgCrmCompany.City = _virkRegInfo.City;
_dtoNgCrmCompany.VatNumber = _virkRegInfo.VatNumber;
}
private async Task Create()
{
var newId = await CompanyRepo.CreateCompany(_companyDto);
ToastService.ShowSuccess($"Godt så! '{_companyDto.Name}' er oprettet i CRM.");
var newId = await CompanyRepo.CreateCompany(_dtoNgCrmCompany);
ToastService.ShowSuccess($"Godt så! '{_dtoNgCrmCompany.Name}' er oprettet i CRM.");
Navigation.NavigateTo($"/company/{newId}");
}
private void HandleFieldChanged(object sender, FieldChangedEventArgs e)
{
if (!VatUtils.ValidateFormat(_companyDto.CountryCode, _companyDto.VatNumber))
if (!VatUtils.ValidateFormat(_dtoNgCrmCompany.CountryCode, _dtoNgCrmCompany.VatNumber))
{
_formInvalid = false;
}
@ -121,7 +121,7 @@ namespace Wonky.Client.Pages
{
_formInvalid = true;
_createCompany.OnFieldChanged -= HandleFieldChanged;
_createCompany = new EditContext(_companyDto);
_createCompany = new EditContext(_dtoNgCrmCompany);
_createCompany.OnFieldChanged += HandleFieldChanged;
_createCompany.OnValidationStateChanged -= ValidationChanged;
}

View file

@ -32,7 +32,7 @@ namespace Wonky.Client.Pages
[Inject] private UserPreferenceService UserPrefService { get; set; }
[Inject] public ICompanyHttpRepository CompanyRepo { get; set; }
[Inject] public HttpInterceptorService Interceptor { get; set; }
public List<CompanyDto>? Companies { get; set; } = new();
public List<DtoNgCrmCompany>? Companies { get; set; } = new();
public MetaData? MetaData { get; set; } = new();
private CompanyPagingParams _paging = new();
private Preferences _preferences { get; set; } = new();
@ -54,21 +54,21 @@ namespace Wonky.Client.Pages
private async Task SelectedPage(int page)
{
Companies = new List<CompanyDto>();
Companies = new List<DtoNgCrmCompany>();
_paging.PageNumber = page;
await GetCompanies();
}
private async Task SetSearchCol(string searchColumn)
{
Companies = new List<CompanyDto>();
Companies = new List<DtoNgCrmCompany>();
_paging.SearchColumn = searchColumn;
_paging.PageNumber = 1;
await GetCompanies();
}
private async Task SetPageSize(string pageSize)
{
Companies = new List<CompanyDto>();
Companies = new List<DtoNgCrmCompany>();
_paging.PageSize = Convert.ToInt32(pageSize);
_paging.PageNumber = 1;
await GetCompanies();
@ -76,7 +76,7 @@ namespace Wonky.Client.Pages
private async Task SetSearchPhrase(string searchTerm)
{
Companies = new List<CompanyDto>();
Companies = new List<DtoNgCrmCompany>();
_paging.PageNumber = 1;
_paging.SearchTerm = searchTerm;
await GetCompanies();
@ -84,14 +84,14 @@ namespace Wonky.Client.Pages
private async Task SetSortCol(string orderBy)
{
Companies = new List<CompanyDto>();
Companies = new List<DtoNgCrmCompany>();
_paging.OrderBy = orderBy;
await GetCompanies();
}
private async Task DeleteCompany(string companyId)
{
Companies = new List<CompanyDto>();
Companies = new List<DtoNgCrmCompany>();
await CompanyRepo.DeleteCompany(companyId);
if (_paging.PageNumber > 1 && Companies.Count == 1)
_paging.PageNumber--;

View file

@ -20,11 +20,11 @@
@attribute [Authorize(Roles = "Adviser")]
@page "/company/{companyId}/update"
@if (_company != null)
@if (DtoNgCrmCompany != null)
{
<div class="card">
<div class="card-header">
<div class="h2">@_company.Account - @_company.Name</div>
<div class="h2">@DtoNgCrmCompany.Account - @DtoNgCrmCompany.Name</div>
</div>
<div class="card-body">
<VatNumberInputComponent OnValidSubmit="GetInfoFromVat"/>
@ -60,65 +60,65 @@
<div class="form-group row mb-2">
<label for="vatNumber" class="col-md-2 col-form-label">CVR/ORG</label>
<div class="col-md-10">
<InputText id="vatNumber" class="form-control" @bind-Value="_company.VatNumber"/>
<ValidationMessage For="@(() => _company.VatNumber)"></ValidationMessage>
<InputText id="vatNumber" class="form-control" @bind-Value="DtoNgCrmCompany.VatNumber"/>
<ValidationMessage For="@(() => DtoNgCrmCompany.VatNumber)"></ValidationMessage>
</div>
</div>
<div class="form-group row mb-2">
<label for="name" class="col-md-2 col-form-label">Firmanavn</label>
<div class="col-md-10">
<InputText id="name" class="form-control" @bind-Value="_company.Name"/>
<ValidationMessage For="@(() => _company.Name)"></ValidationMessage>
<InputText id="name" class="form-control" @bind-Value="DtoNgCrmCompany.Name"/>
<ValidationMessage For="@(() => DtoNgCrmCompany.Name)"></ValidationMessage>
</div>
</div>
<div class="form-group row mb-2">
<label for="address1" class="col-md-2 col-form-label">Conavn</label>
<div class="col-md-10">
<InputText id="address1" class="form-control" @bind-Value="_company.Address1"/>
<InputText id="address1" class="form-control" @bind-Value="DtoNgCrmCompany.Address1"/>
</div>
</div>
<div class="form-group row mb-2">
<label for="address2" class="col-md-2 col-form-label">Adresse</label>
<div class="col-md-10">
<InputText id="address2" class="form-control" @bind-Value="_company.Address2"/>
<InputText id="address2" class="form-control" @bind-Value="DtoNgCrmCompany.Address2"/>
</div>
</div>
<div class="form-group row mb-2">
<label for="zipCode" class="col-md-2 col-form-label">Postnr</label>
<div class="col-md-10">
<InputText id="zipCode" class="form-control" @bind-Value="_company.ZipCode"/>
<ValidationMessage For="@(() => _company.ZipCode)"></ValidationMessage>
<InputText id="zipCode" class="form-control" @bind-Value="DtoNgCrmCompany.ZipCode"/>
<ValidationMessage For="@(() => DtoNgCrmCompany.ZipCode)"></ValidationMessage>
</div>
</div>
<div class="form-group row mb-2">
<label for="city" class="col-md-2 col-form-label">Bynavn</label>
<div class="col-md-10">
<InputText id="city" class="form-control" @bind-Value="_company.City"/>
<ValidationMessage For="@(() => _company.City)"></ValidationMessage>
<InputText id="city" class="form-control" @bind-Value="DtoNgCrmCompany.City"/>
<ValidationMessage For="@(() => DtoNgCrmCompany.City)"></ValidationMessage>
</div>
</div>
<div class="form-group row mb-2">
<label for="phone" class="col-md-2 col-form-label">Telefon</label>
<div class="col-md-10">
<InputText id="phone" class="form-control" @bind-Value="_company.Phone"/>
<InputText id="phone" class="form-control" @bind-Value="DtoNgCrmCompany.Phone"/>
</div>
</div>
<div class="form-group row mb-2">
<label for="mobile" class="col-md-2 col-form-label">Mobil</label>
<div class="col-md-10">
<InputText id="mobile" class="form-control" @bind-Value="_company.Mobile"/>
<InputText id="mobile" class="form-control" @bind-Value="DtoNgCrmCompany.Mobile"/>
</div>
</div>
<div class="form-group row mb-2">
<label for="email" class="col-md-2 col-form-label">Email</label>
<div class="col-md-10">
<InputText id="email" class="form-control" @bind-Value="_company.Email"/>
<InputText id="email" class="form-control" @bind-Value="DtoNgCrmCompany.Email"/>
</div>
</div>
<div class="form-group row mb-2">
<label for="attention" class="col-md-2 col-form-label">Attention</label>
<div class="col-md-10">
<InputText id="attention" class="form-control" @bind-Value="_company.Attention"/>
<InputText id="attention" class="form-control" @bind-Value="DtoNgCrmCompany.Attention"/>
</div>
</div>
<div class="form-group row mb-2">
@ -136,7 +136,7 @@
<div class="form-group row mb-2">
<label for="interval" class="col-form-label col-md-2">Interval (uger)</label>
<div class="col-md-3">
<InputNumber id="interval" class="form-control" @bind-Value="_company.Interval"/>
<InputNumber id="interval" class="form-control" @bind-Value="DtoNgCrmCompany.Interval"/>
</div>
</div>
<div class="row mb-2">
@ -149,7 +149,7 @@
<div class="card-footer">
<div class="row">
<div class="col">
<a class="btn btn-primary" href="/company/@_company.CompanyId">Tilbage</a>
<a class="btn btn-primary" href="/company/@DtoNgCrmCompany.CompanyId">Tilbage</a>
</div>
</div>
</div>

View file

@ -39,7 +39,7 @@ public partial class CompanyUpdate : IDisposable
[Inject] public VatInfoLookupService VatInfoLookupService { get; set; }
[Parameter] public string Account { get; set; } = "";
[Parameter] public string CompanyId { get; set; } = "";
private CompanyDto _company { get; set; }
private DtoNgCrmCompany DtoNgCrmCompany { get; set; }
private EditContext _updateCompany { get; set; }
private List<VirkRegInfo> VInfos { get; set; } = new();
private VirkRegInfo _virkRegInfo { get; set; } = new();
@ -51,41 +51,41 @@ public partial class CompanyUpdate : IDisposable
{
Interceptor.RegisterEvent();
Interceptor.RegisterBeforeSendEvent();
_company = await CompanyRepo.GetCompanyById(CompanyId);
DtoNgCrmCompany = await CompanyRepo.GetCompanyById(CompanyId);
LastVisit = DateTime.Parse(_company.LastVisit);
NextVisit = DateTime.Parse(_company.NextVisit);
_updateCompany = new EditContext(_company);
LastVisit = DateTime.Parse(DtoNgCrmCompany.LastVisit);
NextVisit = DateTime.Parse(DtoNgCrmCompany.NextVisit);
_updateCompany = new EditContext(DtoNgCrmCompany);
if(_company.HasFolded == 1)
if(DtoNgCrmCompany.HasFolded == 1)
{
_vatState = "the-dead";
}
else
{
_vatState = VatUtils.ValidateFormat(_company.CountryCode, _company.VatNumber) ? "the-good" : "the-draw";
_vatState = VatUtils.ValidateFormat(DtoNgCrmCompany.CountryCode, DtoNgCrmCompany.VatNumber) ? "the-good" : "the-draw";
}
}
private async Task Update()
{
if (!string.IsNullOrWhiteSpace(_company.VatNumber) && !VatUtils.ValidateFormat(_company.CountryCode, _company.VatNumber))
if (!string.IsNullOrWhiteSpace(DtoNgCrmCompany.VatNumber) && !VatUtils.ValidateFormat(DtoNgCrmCompany.CountryCode, DtoNgCrmCompany.VatNumber))
{
ToastService.ShowError($"CVR/VAT/ORG nummer er ugyldig.");
StateHasChanged();
return;
}
_company.LastVisit = $"{LastVisit:yyyy-MM-dd}";
_company.NextVisit = $"{NextVisit:yyyy-MM-dd}";
Console.WriteLine(JsonSerializer.Serialize(_company));
await CompanyRepo.UpdateCompany(_company);
DtoNgCrmCompany.LastVisit = $"{LastVisit:yyyy-MM-dd}";
DtoNgCrmCompany.NextVisit = $"{NextVisit:yyyy-MM-dd}";
Console.WriteLine(JsonSerializer.Serialize(DtoNgCrmCompany));
await CompanyRepo.UpdateCompany(DtoNgCrmCompany);
ToastService.ShowSuccess($"Godt så. Firma '{_company!.Name}' er opdateret.");
Navigation.NavigateTo($"/company/{_company.CompanyId}");
ToastService.ShowSuccess($"Godt så. Firma '{DtoNgCrmCompany!.Name}' er opdateret.");
Navigation.NavigateTo($"/company/{DtoNgCrmCompany.CompanyId}");
}
private async Task GetInfoFromVat(string vatNumber)
{
if (string.IsNullOrWhiteSpace(vatNumber) || !VatUtils.ValidateFormat(_company.CountryCode, _company.VatNumber))
if (string.IsNullOrWhiteSpace(vatNumber) || !VatUtils.ValidateFormat(DtoNgCrmCompany.CountryCode, DtoNgCrmCompany.VatNumber))
{
ToastService.ShowError($"CVR er ugyldigt eller mangler");
return;
@ -120,12 +120,12 @@ public partial class CompanyUpdate : IDisposable
private void SelectCompany(string vatNumber)
{
_virkRegInfo = (from x in VInfos where x.VatNumber == vatNumber select x).First();
_company.Name = _virkRegInfo.Name;
_company.Address1 = _virkRegInfo.CoName;
_company.Address2 = _virkRegInfo.Address;
_company.ZipCode = _virkRegInfo.ZipCode;
_company.City = _virkRegInfo.City;
_company.VatNumber = _virkRegInfo.VatNumber;
DtoNgCrmCompany.Name = _virkRegInfo.Name;
DtoNgCrmCompany.Address1 = _virkRegInfo.CoName;
DtoNgCrmCompany.Address2 = _virkRegInfo.Address;
DtoNgCrmCompany.ZipCode = _virkRegInfo.ZipCode;
DtoNgCrmCompany.City = _virkRegInfo.City;
DtoNgCrmCompany.VatNumber = _virkRegInfo.VatNumber;
}
public void Dispose()

View file

@ -21,56 +21,56 @@
@using Wonky.Client.Helpers
@attribute [Authorize(Roles = "Adviser")]
@if (_company != null)
@if (DtoNgCrmCompany != null)
{
<div class="card">
<div class="card-header">
<div class="h2"><img src="gravestone.png" class="img-fluid" style="float:left;width:48px;height:48px;display:@(_hasFolded ? "block" : "none")" alt="tombstone"/> @_company.Name</div>
<div class="h2"><img src="gravestone.png" class="img-fluid" style="float:left;width:48px;height:48px;display:@(_hasFolded ? "block" : "none")" alt="tombstone"/> @DtoNgCrmCompany.Name</div>
</div>
<div class="card-body">
<table class="table table-sm table-striped table-bordered">
<tbody>
<tr>
<th scope="row">Konto</th>
<td colspan="2">@_company.Account</td>
<td colspan="2">@DtoNgCrmCompany.Account</td>
</tr>
<tr>
<th scope="row">Conavn</th>
<td colspan="2">@_company.Address1</td>
<td colspan="2">@DtoNgCrmCompany.Address1</td>
</tr>
<tr>
<th scope="row">Adresse</th>
<td colspan="2">@_company.Address2</td>
<td colspan="2">@DtoNgCrmCompany.Address2</td>
</tr>
<tr>
<th scope="row">Postnummer</th>
<td colspan="2">@_company.ZipCode</td>
<td colspan="2">@DtoNgCrmCompany.ZipCode</td>
</tr>
<tr>
<th scope="row">Bynavn</th>
<td colspan="2">@_company.City</td>
<td colspan="2">@DtoNgCrmCompany.City</td>
</tr>
<tr>
<th scope="row">CVR</th>
<td class="state"><DisplayStateComponent StateClass="@_vatState"></DisplayStateComponent></td>
<td>@_company.VatNumber</td>
<td>@DtoNgCrmCompany.VatNumber</td>
</tr>
<tr>
<th scope="row">Telefon</th>
<td colspan="2">@_company.Phone</td>
<td colspan="2">@DtoNgCrmCompany.Phone</td>
</tr>
<tr>
<th scope="row">Email</th>
<td colspan="2">@_company.Email</td>
<td colspan="2">@DtoNgCrmCompany.Email</td>
</tr>
<tr>
<th scope="row">Sidste besøg</th>
<td colspan="2">@_company.LastVisit</td>
<td colspan="2">@DtoNgCrmCompany.LastVisit</td>
</tr>
<tr>
<th scope="row">Næste besøg</th>
<td class="state"><DisplayStateComponent StateClass="@(_hasFolded ? "the-dead" : Utils.GetVisitState(_company.NextVisit))"></DisplayStateComponent></td>
<td>@_company.NextVisit</td>
<td class="state"><DisplayStateComponent StateClass="@(_hasFolded ? "the-dead" : Utils.GetVisitState(DtoNgCrmCompany.NextVisit))"></DisplayStateComponent></td>
<td>@DtoNgCrmCompany.NextVisit</td>
</tr>
</tbody>
</table>
@ -78,8 +78,8 @@
<div class="card-footer">
<div class="d-flex align-items-end">
<a class="btn btn-primary mx-2" href="/companies">Tilbage</a>
<a class="btn btn-primary mx-2" href="/company/@_company.CompanyId/update">Rediger</a>
<a class="btn btn-primary mx-2" href="/company/@_company.CompanyId/activity">Aktivitet</a>
<a class="btn btn-primary mx-2" href="/company/@DtoNgCrmCompany.CompanyId/update">Rediger</a>
<a class="btn btn-primary mx-2" href="/company/@DtoNgCrmCompany.CompanyId/activity">Aktivitet</a>
</div>
</div>
</div>

View file

@ -35,7 +35,7 @@ public partial class CompanyView : IDisposable
[Inject] public HttpInterceptorService Interceptor { get; set; }
[Inject] public VatInfoLookupService VatInfoLookup { get; set; }
[Parameter] public string CompanyId { get; set; } = "";
private CompanyDto _company { get; set; } = new ();
private DtoNgCrmCompany DtoNgCrmCompany { get; set; } = new ();
private string _vatState { get; set; } = "the-dead";
private bool _hasFolded { get; set; }
@ -43,15 +43,15 @@ public partial class CompanyView : IDisposable
{
Interceptor.RegisterEvent();
Interceptor.RegisterBeforeSendEvent();
_company = await CompanyRepo.GetCompanyById(CompanyId);
DtoNgCrmCompany = await CompanyRepo.GetCompanyById(CompanyId);
if(_company.HasFolded == 1)
if(DtoNgCrmCompany.HasFolded == 1)
{
_hasFolded = true;
}
else
{
_vatState = VatUtils.ValidateFormat(_company.CountryCode, _company.VatNumber) ? "the-good" : "the-draw";
_vatState = VatUtils.ValidateFormat(DtoNgCrmCompany.CountryCode, DtoNgCrmCompany.VatNumber) ? "the-good" : "the-draw";
}
}

View file

@ -19,7 +19,7 @@
@using Microsoft.AspNetCore.Authorization
@attribute [Authorize(Roles = "Adviser")]
@using Wonky.Client.Components
@if (_company != null)
@if (_dtoNgCrmCompany != null)
{
<h2>@_poDraft.Name</h2>
<EditForm EditContext="_createActivity" OnValidSubmit="CreateActivity">
@ -43,9 +43,9 @@
<div class="col-sm-3 col-md-3">
<select id="activityType" class="form-select" @bind-Value="@_poDraft.ActivityType" @bind-Value:event="oninput" @onchange="CheckActivity">
<option value="" selected>--type--</option>
<option value="onSite">Besøg</option>
<option value="phone">Telefon</option>
<option value="canvas">Kanvas</option>
<option value="caOnSite">Besøg</option>
<option value="caPhone">Telefon</option>
<option value="caCanvas">Kanvas</option>
</select>
</div>
<div class="col-sm-3 col-md-3">
@ -254,7 +254,7 @@
<td>@cItem.Item.Sku</td>
<td class="text-end">@cItem.Quantity</td>
<td class="text-end">@cItem.Price</td>
<td class="text-end">@cItem.Total</td>
<td class="text-end">@cItem.LineTotal</td>
<td>
<button class="btn btn-warning" @onclick="@(() => RemoveItem(@cItem))">Slet</button>
</td>
@ -329,7 +329,7 @@
<div class="row mt-2 mb-2">
<div class="col">
<a class="btn btn-primary" href="/company/@_company.CompanyId">Tilbage</a>
<a class="btn btn-primary" href="/company/@_dtoNgCrmCompany.CompanyId">Tilbage</a>
</div>
<div class="col">
<button type="submit" class="btn btn-dark" disabled="@InvalidCanvas">Kanvas</button>

View file

@ -39,12 +39,12 @@ public partial class CrmActivityCreate : IDisposable
[Inject] private UserPreferenceService UserPrefs { get; set; }
[CascadingParameter] DraftStateProvider DraftStateProvider { get; set; }
[Parameter] public string CompanyId { get; set; }
private SalesItemDto _selectedItem { get; set; } = new();
private List<SalesItemDto> SalesItems { get; set; } = new();
private NgSalesItemView _selectedItem { get; set; } = new();
private List<NgSalesItemView> SalesItems { get; set; } = new();
// private MetaData _meta { get; set; } = new();
private Preferences _prefs { get; set; } = new();
private ActivityHead _poDraft { get; set; } = new();
private CompanyDto _company = new();
private DtoNgSalesHead _poDraft { get; set; } = new();
private DtoNgCrmCompany _dtoNgCrmCompany = new();
private CatalogPagingParams _paging = new();
private EditContext _createActivity { get; set; }
private bool _poFormInvalid { get; set; } = true;
@ -56,6 +56,7 @@ public partial class CrmActivityCreate : IDisposable
private bool InvalidActivity { get; set; } = true;
private bool InvalidCanvas { get; set; } = true;
private bool InvalidDate { get; set; } = true;
private UserInfoView Ux { get; set; } = new();
protected override async Task OnInitializedAsync()
{
@ -64,32 +65,31 @@ public partial class CrmActivityCreate : IDisposable
_prefs = await UserPrefs.GetPreferences();
_paging.SearchColumn = _prefs.ItemSearch;
await GetSalesItems();
var ux = await StorageService.GetItemAsync<UserInfo>("_ux");
_company = await CompanyRepo.GetCompanyById(CompanyId);
Ux = await StorageService.GetItemAsync<UserInfoView>("_ux");
_dtoNgCrmCompany = await CompanyRepo.GetCompanyById(CompanyId);
_createActivity = new EditContext(_poDraft);
_createActivity.OnFieldChanged += HandleFieldChanged;
// set up indexdb identification
_poDraft.ActivityId = CompanyId;
_poDraft.CrmCompanyKey = CompanyId;
_poDraft.SalesHeadId = Guid.NewGuid().ToString();
_poDraft.CompanyId = CompanyId;
_poDraft.ActivityDate = string.IsNullOrWhiteSpace(_prefs.WorkDate)
? DateTime.Now
: DateTime.Parse(_prefs.WorkDate);
// permanent identifications
_poDraft.SalesRep = ux.Adviser;
_poDraft.Account = _company.Account;
_poDraft.VatNumber = _company.VatNumber;
_poDraft.EMail = _company.Email;
_poDraft.Phone = _company.Phone;
_poDraft.OurRef = ux.FullName.Split(" ")[0];
_poDraft.SalesRep = Ux.Adviser;
_poDraft.Account = _dtoNgCrmCompany.Account;
_poDraft.VatNumber = _dtoNgCrmCompany.VatNumber;
_poDraft.EMail = _dtoNgCrmCompany.Email;
_poDraft.Phone = _dtoNgCrmCompany.Phone;
_poDraft.Name = _company.Name;
_poDraft.Address = _company.Address1;
_poDraft.Address2 = _company.Address2;
_poDraft.ZipCode = _company.ZipCode;
_poDraft.City = _company.City;
_poDraft.Name = _dtoNgCrmCompany.Name;
_poDraft.Address = _dtoNgCrmCompany.Address1;
_poDraft.Address2 = _dtoNgCrmCompany.Address2;
_poDraft.ZipCode = _dtoNgCrmCompany.ZipCode;
_poDraft.City = _dtoNgCrmCompany.City;
_poDraft.DlvName = "";
_poDraft.DlvAddress1 = "";
@ -111,17 +111,24 @@ public partial class CrmActivityCreate : IDisposable
{
// write work date to preference
await UserPrefs.SetWorkDate(_poDraft.ActivityDate);
var activityType = _poDraft.ActivityType switch
{
"caPhone" => "Tlf. ",
"caOnSite" => "Bsg. ",
_ => ""
};
_poDraft.OurRef = $"{activityType}{Ux.FullName.Split(" ")[0]}";
var ln = 0;
// post to create activity endpoint
foreach (var line in DraftStateProvider.Draft.Items.Select(item => new ActivityLine
foreach (var line in DraftStateProvider.Draft.Items.Select(item => new DtoNgSalesLine
{
Price = item.Price,
Discount = item.Discount,
Qty = item.Quantity,
Sku = item.Item.Sku,
Text = item.Item.Name,
LineAmount = item.Total,
LineAmount = item.LineTotal,
LineNumber = ++ln
}))
{
@ -156,13 +163,13 @@ public partial class CrmActivityCreate : IDisposable
Quantity = quantity;
}
private async Task AddItem(SalesItemDto salesItem)
private async Task AddItem(NgSalesItemView ngSalesItem)
{
ShowItem = false;
// create a new cart item
var item = new DraftItem
{
Item = salesItem,
Item = ngSalesItem,
Quantity = Convert.ToInt32(Quantity),
Price = Convert.ToDecimal(Price)
};
@ -180,14 +187,14 @@ public partial class CrmActivityCreate : IDisposable
}
private async Task SetItemGroup(string groupFilter)
{
SalesItems = new List<SalesItemDto>();
SalesItems = new List<NgSalesItemView>();
_paging.PageNumber = 1;
_paging.SelectGroup = groupFilter;
await GetSalesItems();
}
private async Task SetSearchCol(string columnName)
{
SalesItems = new List<SalesItemDto>();
SalesItems = new List<NgSalesItemView>();
_paging.PageNumber = 1;
_paging.SearchTerm = "";
_paging.SearchColumn = columnName;
@ -195,7 +202,7 @@ public partial class CrmActivityCreate : IDisposable
}
private async Task SetSortCol(string searchTerm)
{
SalesItems = new List<SalesItemDto>();
SalesItems = new List<NgSalesItemView>();
_paging.PageNumber = 1;
_paging.SearchTerm = searchTerm;
await GetSalesItems();
@ -219,7 +226,7 @@ public partial class CrmActivityCreate : IDisposable
{
if (!string.IsNullOrEmpty(_poDraft.VatNumber))
{
if(!VatUtils.ValidateFormat(_company.CountryCode, _poDraft.VatNumber))
if(!VatUtils.ValidateFormat(_dtoNgCrmCompany.CountryCode, _poDraft.VatNumber))
ToastService.ShowWarning("CVR / ORG nummer er ikke et gyldigt registreringsnummer");
}
if (string.IsNullOrEmpty(_poDraft.ActivityType))

View file

@ -28,22 +28,22 @@
}
</div>
}
<EditForm Model="_userAuthenticationDto" OnValidSubmit="ExecuteLogin" class="card card-body bg-light mt-5">
<EditForm Model="_dtoUserAuthentication" OnValidSubmit="ExecuteLogin" class="card card-body bg-light mt-5">
<DataAnnotationsValidator />
<div class="form-group row">
<label for="email" class="col-md-2 col-form-label">Login</label>
<div class="col-md-10">
<InputText type="email" id="email" class="form-control"
@bind-Value="_userAuthenticationDto.Email" autocomplete="username" />
<ValidationMessage For="@(() => _userAuthenticationDto.Email)" />
@bind-Value="_dtoUserAuthentication.Email" autocomplete="username" />
<ValidationMessage For="@(() => _dtoUserAuthentication.Email)" />
</div>
</div>
<div class="form-group row">
<label for="password" class="col-md-2 col-form-label">Kode</label>
<div class="col-md-10">
<InputText type="password" id="password" class="form-control"
@bind-Value="_userAuthenticationDto.Password" autocomplete="current-password" />
<ValidationMessage For="@(() => _userAuthenticationDto.Password)" />
@bind-Value="_dtoUserAuthentication.Password" autocomplete="current-password" />
<ValidationMessage For="@(() => _dtoUserAuthentication.Password)" />
</div>
</div>
<div class="row">

View file

@ -25,7 +25,7 @@ public partial class Login
[Inject] public NavigationManager NavigationManager { get; set; }
[Inject] public IAuthenticationService AuthenticationService { get; set; }
[Parameter] public string ReturnUrl { get; set; } = "";
private UserAuthenticationDto _userAuthenticationDto = new ();
private DtoUserAuthentication _dtoUserAuthentication = new ();
private bool ShowAuthError { get; set; }
private string? Error { get; set; }
private bool execLogin = false;
@ -35,7 +35,7 @@ public partial class Login
ShowAuthError = false;
execLogin = true;
var result = await AuthenticationService.Login(_userAuthenticationDto);
var result = await AuthenticationService.Login(_dtoUserAuthentication);
if (!result.IsSuccess)
{
Error = result.ErrorMessage;

View file

@ -33,7 +33,7 @@ public partial class SalesItemCatalog : IDisposable
[Inject] public ISalesItemHttpRepository SalesItemRepo { get; set; }
[Inject] public HttpInterceptorService Interceptor { get; set; }
[Inject] private UserPreferenceService UserPreferenceService { get; set; }
private List<SalesItemDto> SalesItems { get; set; } = new();
private List<NgSalesItemView> SalesItems { get; set; } = new();
private MetaData? MetaData { get; set; } = new();
private CatalogPagingParams _paging = new();
private Preferences _preferences = new();
@ -52,7 +52,7 @@ public partial class SalesItemCatalog : IDisposable
private async Task SelectedPage(int page)
{
SalesItems = new List<SalesItemDto>();
SalesItems = new List<NgSalesItemView>();
_paging.PageNumber = page;
await GetSalesItems();
}
@ -66,7 +66,7 @@ public partial class SalesItemCatalog : IDisposable
private async Task SetPageSize(string pageSize)
{
SalesItems = new List<SalesItemDto>();
SalesItems = new List<NgSalesItemView>();
_paging.PageSize = Convert.ToInt32(pageSize);
_paging.PageNumber = 1;
await GetSalesItems();
@ -74,21 +74,21 @@ public partial class SalesItemCatalog : IDisposable
private async Task SetItemGroup(string groupFilter)
{
SalesItems = new List<SalesItemDto>();
SalesItems = new List<NgSalesItemView>();
_paging.PageNumber = 1;
_paging.SelectGroup = groupFilter;
await GetSalesItems();
}
private async Task SetSearchCol(string columnName)
{
SalesItems = new List<SalesItemDto>();
SalesItems = new List<NgSalesItemView>();
_paging.PageNumber = 1;
_paging.SearchColumn = columnName;
await GetSalesItems();
}
private async Task SetSearchPhrase(string searchTerm)
{
SalesItems = new List<SalesItemDto>();
SalesItems = new List<NgSalesItemView>();
_paging.PageNumber = 1;
_paging.SearchTerm = searchTerm;
await GetSalesItems();
@ -96,7 +96,7 @@ public partial class SalesItemCatalog : IDisposable
private async Task SetSortCol(string orderBy)
{
SalesItems = new List<SalesItemDto>();
SalesItems = new List<NgSalesItemView>();
_paging.OrderBy = orderBy;
await GetSalesItems();
}

View file

@ -24,7 +24,7 @@ namespace Wonky.Client.Pages;
public partial class SalesItemView : IDisposable
{
private SalesItemDto Item { get; set; } = new ();
private NgSalesItemView Item { get; set; } = new ();
[Inject]
public ISalesItemHttpRepository SalesItemRepo { get; set; }

View file

@ -44,7 +44,7 @@ namespace Wonky.Client.Providers
return _anonymous;
// create an authorized user
var userInfo = await _storage.GetItemAsync<UserInfo>("_ux");
var userInfo = await _storage.GetItemAsync<UserInfoView>("_ux");
if (userInfo == null)
return _anonymous;
@ -79,7 +79,7 @@ namespace Wonky.Client.Providers
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", token);
// create an authorized user
var userInfo = await _storage.GetItemAsync<UserInfo>("_ux");
var userInfo = await _storage.GetItemAsync<UserInfoView>("_ux");
var exp = await _storage.GetItemAsync<string>("_ex");
var roles = ExtractRoles(userInfo);
var claims = new List<Claim>
@ -105,18 +105,18 @@ namespace Wonky.Client.Providers
NotifyAuthenticationStateChanged(authState);
}
private static IEnumerable<string> ExtractRoles(UserInfo userInfo)
private static IEnumerable<string> ExtractRoles(UserInfoView userInfoView)
{
var roles = new List<string>();
if (userInfo.IsAdmin)
if (userInfoView.IsAdmin)
roles.Add("Admin");
if (userInfo.IsAdviser)
if (userInfoView.IsAdviser)
roles.Add("Adviser");
if (userInfo.IsSupervisor)
if (userInfoView.IsSupervisor)
roles.Add("Supervisor");
if(userInfo.IsEDoc)
if(userInfoView.IsEDoc)
roles.Add("EDoc");
if (userInfo.IsEShop)
if (userInfoView.IsEShop)
roles.Add("EShop");
return roles;
}

View file

@ -43,29 +43,29 @@ namespace Wonky.Client.Services
_apiConfig = apiConfig;
}
public async Task<ResponseDto> RegisterUser(UserRegistrationDto userRegistrationDto)
public async Task<ApiResponseView> RegisterUser(DtoNgUserRegistration dtoNgUserRegistration)
{
var response = await _client
.PostAsJsonAsync(_apiConfig.Value.UserRegistration, userRegistrationDto);
.PostAsJsonAsync(_apiConfig.Value.UserRegistration, dtoNgUserRegistration);
if (response.IsSuccessStatusCode)
return new ResponseDto {IsSuccess = true};
return new ApiResponseView {IsSuccess = true};
var content = await response.Content
.ReadAsStringAsync()
;
var result = JsonSerializer.Deserialize<ResponseDto>(content, _options);
return result ?? new ResponseDto();
var result = JsonSerializer.Deserialize<ApiResponseView>(content, _options);
return result ?? new ApiResponseView();
}
public async Task<AuthResponseDto> Login(UserAuthenticationDto userAuth)
public async Task<AuthResponseView> Login(DtoUserAuthentication dtoUserAuth)
{
var credentials = new Dictionary<string, string>
{
["grant_type"] = "password",
["username"] = userAuth.Email,
["password"] = userAuth.Password
["username"] = dtoUserAuth.Email,
["password"] = dtoUserAuth.Password
};
var response = await _client
.PostAsync(_apiConfig.Value.TokenPath, new FormUrlEncodedContent(credentials));
@ -74,10 +74,10 @@ namespace Wonky.Client.Services
// if not success - return error status
if (!response.IsSuccessStatusCode)
return new AuthResponseDto {IsSuccess = false, ErrorMessage = $"Kontroller indtastning"};
return new AuthResponseView {IsSuccess = false, ErrorMessage = $"Kontroller indtastning"};
// process response content
var data = JsonSerializer.Deserialize<AuthResponseDto>(resContent, _options);
var data = JsonSerializer.Deserialize<AuthResponseView>(resContent, _options);
await _localStorage.SetItemAsync("_tx", data.AccessToken);
await _localStorage.SetItemAsync("_rx", data.RefreshToken);
@ -112,7 +112,7 @@ namespace Wonky.Client.Services
if (response.IsSuccessStatusCode)
{
var resContent = await response.Content.ReadAsStringAsync();
var data = JsonSerializer.Deserialize<AuthResponseDto>(resContent, _options);
var data = JsonSerializer.Deserialize<AuthResponseView>(resContent, _options);
// set default request headers using access_token
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", data.AccessToken);
@ -140,14 +140,14 @@ namespace Wonky.Client.Services
_client.DefaultRequestHeaders.Authorization = null;
}
public async Task<UserInfo> UserInfo(bool write = false)
public async Task<UserInfoView> UserInfo(bool write = false)
{
var infoResponse = await _client.GetAsync(_apiConfig.Value.UserInfo);
var infoContent = await infoResponse.Content.ReadAsStringAsync();
var userInfo = JsonSerializer.Deserialize<UserInfo>(infoContent, _options);
var userInfo = JsonSerializer.Deserialize<UserInfoView>(infoContent, _options);
if(write)
await _localStorage.SetItemAsync("_ux", userInfo);
return userInfo ?? new UserInfo();
return userInfo ?? new UserInfoView();
}
}

View file

@ -20,11 +20,11 @@ namespace Wonky.Client.Services
{
public interface IAuthenticationService
{
Task<ResponseDto> RegisterUser(UserRegistrationDto userRegistrationDto);
Task<AuthResponseDto> Login(UserAuthenticationDto userAuth);
Task<ApiResponseView> RegisterUser(DtoNgUserRegistration dtoNgUserRegistration);
Task<AuthResponseView> Login(DtoUserAuthentication dtoUserAuth);
Task Logout();
Task<string> RefreshToken();
Task<UserInfo> UserInfo(bool write = false);
Task<UserInfoView> UserInfo(bool write = false);
}
}

View file

@ -17,7 +17,7 @@ using System.Collections.Generic;
namespace Wonky.Entity.DTO;
public class ResponseDto
public class ApiResponseView
{
public bool IsSuccess { get; set; }
public IEnumerable<string>? Errors { get; set; }

View file

@ -17,9 +17,8 @@ using System.Text.Json.Serialization;
namespace Wonky.Entity.DTO;
public class AuthResponseDto
public class AuthResponseView
{
public bool IsSuccess { get; set; }
public string ErrorMessage { get; set; } = "";
[JsonPropertyName("access_token")] public string? AccessToken { get; set; } = "";
@ -28,12 +27,4 @@ public class AuthResponseDto
[JsonPropertyName("refresh_token")] public string RefreshToken { get; set; } = "";
[JsonPropertyName(".issued")] public string Issued { get; set; } = "";
[JsonPropertyName(".expires")] public string Expires { get; set; } = "";
/*{
"access_token": "",
"token_type": "bearer",
"expires_in": 1209599,
"refresh_token": "",
".issued": "Fri, 14 Jan 2022 07:05:48 GMT",
".expires": "Fri, 28 Jan 2022 07:05:48 GMT"
}*/
}

View file

@ -15,7 +15,7 @@
namespace Wonky.Entity.DTO;
public class CreateCompanyResponse
public class CreateCompanyResponseView
{
}

View file

@ -1,31 +0,0 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Wonky.Entity.DTO;
public class CrmActivityHeadDto
{
// Base account info
public string CompanyId { get; set; } = "";
public string Account { get; set; } = "";
public string VatNumber { get; set; } = "";
public string Name { get; set; } = "";
public string Address { get; set; } = "";
public string Address2 { get; set; } = "";
public string City { get; set; }= "";
public string ZipCode { get; set; } = "";
public string SalesRep { get; set; } = "";
public string Phone { get; set; } = "";
public string EMail { get; set; } = "";
// Form entries
public string ReferenceNumber { get; set; } = "";
public string YourRef { get; set; } = "";
public string OurRef { get; set; } = "";
public string OrderMessage { get; set; } = "";
// From company or form entry
public string DlvName { get; set; } = "";
public string DlvAddress1 { get; set; } = "";
public string DlvAddress2 { get; set; } = "";
public string DlvZipCode { get; set; } = "";
public string DlvCity { get; set; } = "";
}

View file

@ -1,29 +0,0 @@
// Copyright (C) 2022 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the Affero GNU General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// Affero GNU General Public License for more details.
//
// You should have received a copy of the Affero GNU General Public License
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
//
namespace Wonky.Entity.DTO;
public class CrmSalesLines
{
public int ActivityLineId { get; set; }
public int ActivityId { get; set; }
public string Sku { get; set; } = "";
public string Text { get; set; } = "";
public int Qty { get; set; }
public decimal Price { get; set; }
public decimal Discount { get; set; }
public decimal LineAmount { get; set; }
public int LineNumber { get; set; }
}

View file

@ -19,7 +19,7 @@ using System.Text.Json.Serialization;
namespace Wonky.Entity.DTO;
public class CompanyDto
public class DtoNgCrmCompany
{
[Required(ErrorMessage = "Navn skal udfyldes")] [MaxLength(100, ErrorMessage = "Du kan højst bruge 100 tegn")] public string Name { get; set; }
[Required(ErrorMessage = "Postnummer skal udfyldes")] [MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] public string ZipCode { get; set; }

View file

@ -13,16 +13,14 @@
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
//
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Wonky.Entity.DTO;
namespace Wonky.Client.Models
namespace Wonky.Entity.DTO
{
public class ActivityHead
public class DtoNgSalesHead
{
public string ActivityId { get; set; } = "";
public string CrmCompanyKey { get; set; } = "";
public string SalesHeadId { get; set; } = "";
public string CompanyId { get; set; } = "";
public string SalesRep { get; set; } = "";
[MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] public string Account { get; set; } = "";
[MaxLength(100, ErrorMessage = "Du kan højst bruge 100 tegn")] public string Name { get; set; } = "";
@ -50,6 +48,6 @@ namespace Wonky.Client.Models
[MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] public string DlvZipCode { get; set; } = "";
[MaxLength(30, ErrorMessage = "Du kan højst bruge 30 tegn")] public string DlvCity { get; set; } = "";
// Lines
public List<ActivityLine> Lines { get; set; } = new();
public List<DtoNgSalesLine> Lines { get; set; } = new();
}
}

View file

@ -12,9 +12,9 @@
// You should have received a copy of the Affero GNU General Public License
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
//
namespace Wonky.Client.Models;
namespace Wonky.Entity.DTO;
public class ActivityLine
public class DtoNgSalesLine
{
public string Sku { get; set; } = "";
public string Text { get; set; } = "";
@ -23,4 +23,5 @@ public class ActivityLine
public decimal Discount { get; set; }
public decimal LineAmount { get; set; }
public int LineNumber { get; set; }
public bool Sas { get; set; }
}

View file

@ -17,7 +17,7 @@ using System.ComponentModel.DataAnnotations;
namespace Wonky.Entity.DTO;
public class UpdateCompanyDto
public class DtoNgUpdateCompany
{
[MaxLength(100)] public string Name { get; set; } = "";
[MaxLength(30)] public string City { get; set; } = "";

View file

@ -17,17 +17,12 @@ using System.ComponentModel.DataAnnotations;
namespace Wonky.Entity.DTO;
public class UserRegistrationDto
public class DtoNgUserRegistration
{
[Required(ErrorMessage = "Login skal angives")]
public string? Email { get; set; }
[Required(ErrorMessage = "Kode skal angives")]
public string? Password { get; set; }
[Required(ErrorMessage = "Login skal angives")] public string? Email { get; set; }
[Required(ErrorMessage = "Kode skal angives")] public string? Password { get; set; }
[Compare(nameof(Password), ErrorMessage = "Adgangskoder skal være identiske")]
public string? ConfirmPassword { get; set; }
public string FirstName { get; set; } = "";
public string LastName { get; set; } = "";
public string CountryCode { get; set; } = "dk";

View file

@ -17,11 +17,8 @@ using System.ComponentModel.DataAnnotations;
namespace Wonky.Entity.DTO;
public class UserAuthenticationDto
public class DtoUserAuthentication
{
[Required(ErrorMessage = "Email skal angives")]
public string Email { get; set; } = "";
[Required(ErrorMessage = "Password skal angives")]
public string Password { get; set; } = "";
[Required(ErrorMessage = "Email skal angives")] public string Email { get; set; } = "";
[Required(ErrorMessage = "Password skal angives")] public string Password { get; set; } = "";
}

View file

@ -19,12 +19,8 @@ namespace Wonky.Entity.DTO;
public class KrvProductDto
{
[Required]
public string ProductId { get; set; } = "";
[Required]
public string TradingName { get; set; } = "";
[Required]
public string PictureLink { get; set; } = "";
[Required]
public string ProductCategoryEnum { get; set; } = "";
[Required] public string ProductId { get; set; } = "";
[Required] public string TradingName { get; set; } = "";
[Required] public string PictureLink { get; set; } = "";
[Required] public string ProductCategoryEnum { get; set; } = "";
}

View file

@ -19,20 +19,12 @@ namespace Wonky.Entity.DTO;
public class KrvVariantDto
{
[Required]
public string VariantId { get; set; } = "";
[Required]
public string Name { get; set; } = "";
[Required]
public string Sku { get; set; } = "";
[Required]
public string ErpSku { get; set; } = "";
[Required]
public string ErpName { get; set; } = "";
[Required]
public string ShortName { get; set; } = "";
[Required]
public string SdsLink { get; set; } = "";
// [Required]
[Required] public string VariantId { get; set; } = "";
[Required] public string Name { get; set; } = "";
[Required] public string Sku { get; set; } = "";
[Required] public string ErpSku { get; set; } = "";
[Required] public string ErpName { get; set; } = "";
[Required] public string ShortName { get; set; } = "";
[Required] public string SdsLink { get; set; } = "";
public string PictureLink { get; set; } = "";
}

View file

@ -17,7 +17,7 @@ using System.Collections.Generic;
namespace Wonky.Entity.DTO;
public class SalesItemDto
public class NgSalesItemView
{
public string ItemId { get; set; } = "";
public string Name { get; set; } = "";
@ -25,5 +25,5 @@ public class SalesItemDto
public string ShortName { get; set; } = "";
public string ProductGroup { get; set; } = "";
public string PictureLink { get; set; } = "";
public List<SalesRateDto> Rates { get; set; } = new();
public List<NgSalesRateView> Rates { get; set; } = new();
}

View file

@ -14,7 +14,7 @@
//
namespace Wonky.Entity.DTO;
public class SalesRateDto
public class NgSalesRateView
{
public string Quantity { get; set; } = "";
public string Rate { get; set; } = "";

View file

@ -14,7 +14,7 @@
//
namespace Wonky.Entity.DTO;
public class RefreshTokenDto
public class RefreshTokenView
{
public string Token { get; set; } = "";
public string RefreshToken { get; set; } = "";

View file

@ -14,7 +14,7 @@
//
namespace Wonky.Entity.DTO;
public class UploadResponse
public class UploadResponseView
{
public string Message { get; set; } = "";
}

View file

@ -17,7 +17,7 @@ using System.Text.Json.Serialization;
namespace Wonky.Entity.DTO;
public class UserInfo
public class UserInfoView
{
[JsonPropertyName("Id")] public string Id { get; set; } = "";
[JsonPropertyName("adviser")] public string Adviser { get; set; } = "";