built v0.2.37

This commit is contained in:
Frede Hundewadt 2022-05-16 10:34:27 +02:00
parent 327aecaffe
commit 9c5c698ecf
10 changed files with 47 additions and 32 deletions

View file

@ -17,7 +17,7 @@
<span class="version">@Name</span> <span class="version">@Version</span>@if(IsBeta){<span class="version">-beta</span>} <span class="version">@Name</span> <span class="version">@Version</span>@if(IsBeta){<span class="version">-beta</span>}
@code @code
{ {
private const string Version = "0.2.36"; private const string Version = "0.2.37";
private const string Name = "wwo"; private const string Name = "wwo";
private const bool IsBeta = true; private const bool IsBeta = true;
} }

View file

@ -37,12 +37,12 @@ public class ActivityHttpRepository : IActivityHttpRepository
}; };
private readonly NavigationManager _navigation; private readonly NavigationManager _navigation;
private ILogger<SalesItemHttpRepository> _logger; private ILogger<ActivityHttpRepository> _logger;
private readonly HttpClient _client; private readonly HttpClient _client;
private readonly ApiConfig _apiConfig; private readonly ApiConfig _apiConfig;
public ActivityHttpRepository(HttpClient client, public ActivityHttpRepository(HttpClient client,
ILogger<SalesItemHttpRepository> logger, ILogger<ActivityHttpRepository> logger,
NavigationManager navigation, IOptions<ApiConfig> configuration) NavigationManager navigation, IOptions<ApiConfig> configuration)
{ {
_client = client; _client = client;
@ -77,6 +77,7 @@ public class ActivityHttpRepository : IActivityHttpRepository
public async Task<ActivityResponseView> CreateActivity(DtoNgActivity model) public async Task<ActivityResponseView> CreateActivity(DtoNgActivity model)
{ {
Console.WriteLine(JsonSerializer.Serialize(model));
var response = await _client.PostAsJsonAsync($"{_apiConfig.ActivityEndpoint}", model).ConfigureAwait(true); var response = await _client.PostAsJsonAsync($"{_apiConfig.ActivityEndpoint}", model).ConfigureAwait(true);
var content = await response.Content.ReadAsStringAsync(); var content = await response.Content.ReadAsStringAsync();
var result = JsonSerializer.Deserialize<ActivityResponseView>(content); var result = JsonSerializer.Deserialize<ActivityResponseView>(content);

View file

@ -87,7 +87,9 @@ public partial class CompanyUpdate : IDisposable
} }
DtoNgCompany.LastVisit = $"{LastVisit:yyyy-MM-dd}"; DtoNgCompany.LastVisit = $"{LastVisit:yyyy-MM-dd}";
DtoNgCompany.NextVisit = $"{NextVisit:yyyy-MM-dd}"; DtoNgCompany.NextVisit = $"{NextVisit:yyyy-MM-dd}";
Console.WriteLine(JsonSerializer.Serialize(DtoNgCompany)); Console.WriteLine(JsonSerializer.Serialize(DtoNgCompany));
await CompanyRepo.UpdateCompany(DtoNgCompany); await CompanyRepo.UpdateCompany(DtoNgCompany);
ToastService.ShowSuccess($"Godt så. Firma '{DtoNgCompany!.Name}' er opdateret."); ToastService.ShowSuccess($"Godt så. Firma '{DtoNgCompany!.Name}' er opdateret.");

View file

@ -85,7 +85,7 @@
<div class="row mb-1"> <div class="row mb-1">
<label for="activityDate" class="col-md-2 col-form-label">Dato</label> <label for="activityDate" class="col-md-2 col-form-label">Dato</label>
<div class="col-md-4"> <div class="col-md-4">
<InputDate id="activityDate" class="form-control" @bind-Value="@(_poDraft.ActivityDate)"/> <InputDate id="activityDate" class="form-control" @bind-Value="@(_draftDate)"/>
</div> </div>
<label for="checkDate" class="col-md-2 form-check-label">Bekræft dato?</label> <label for="checkDate" class="col-md-2 form-check-label">Bekræft dato?</label>
<div class="col-md-4"> <div class="col-md-4">

View file

@ -13,6 +13,7 @@
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
// //
using System.Text.Json;
using Blazored.LocalStorage; using Blazored.LocalStorage;
using Blazored.Toast.Services; using Blazored.Toast.Services;
using Wonky.Client.Helpers; using Wonky.Client.Helpers;
@ -62,6 +63,7 @@ public partial class CrmActivityCreate : IDisposable
private bool InvalidDate { get; set; } = true; private bool InvalidDate { get; set; } = true;
private UserInfoView Ux { get; set; } = new(); private UserInfoView Ux { get; set; } = new();
private VatUtils _vatUtils { get; set; } private VatUtils _vatUtils { get; set; }
private DateTime _draftDate { get; set; }
protected override void OnParametersSet() protected override void OnParametersSet()
{ {
@ -70,9 +72,10 @@ public partial class CrmActivityCreate : IDisposable
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
_vatUtils = new VatUtils();
Interceptor.RegisterEvent(); Interceptor.RegisterEvent();
Interceptor.RegisterBeforeSendEvent(); Interceptor.RegisterBeforeSendEvent();
_vatUtils = new VatUtils();
_prefs = await UserPrefs.GetPreferences(); _prefs = await UserPrefs.GetPreferences();
_paging.SearchColumn = _prefs.ItemSearch; _paging.SearchColumn = _prefs.ItemSearch;
_paging.PageSize = Convert.ToInt32(_prefs.PageSize); _paging.PageSize = Convert.ToInt32(_prefs.PageSize);
@ -83,12 +86,13 @@ public partial class CrmActivityCreate : IDisposable
DraftContext = new EditContext(_poDraft); DraftContext = new EditContext(_poDraft);
DraftContext.OnFieldChanged += HandleFieldChanged; DraftContext.OnFieldChanged += HandleFieldChanged;
// set up indexdb identification // set up identification
_poDraft.SalesHeadId = Guid.NewGuid().ToString(); _poDraft.SalesHeadId = "";
_poDraft.CompanyId = CompanyId; _poDraft.CompanyId = CompanyId;
_poDraft.ActivityDate = string.IsNullOrWhiteSpace(_prefs.WorkDate) _draftDate = string.IsNullOrWhiteSpace(_prefs.WorkDate)
? DateTime.Now ? DateTime.Now
: DateTime.Parse(_prefs.WorkDate); : DateTime.Parse(_prefs.WorkDate);
_poDraft.ActivityDate = $"{_draftDate:yyyy-MM-dd}";
// permanent identifications // permanent identifications
_poDraft.SalesRep = Ux.Adviser; _poDraft.SalesRep = Ux.Adviser;
@ -114,19 +118,22 @@ public partial class CrmActivityCreate : IDisposable
{ {
HideButtons = true; HideButtons = true;
// write work date to preference // write work date to preference
await UserPrefs.SetWorkDate(_poDraft.ActivityDate); await UserPrefs.SetWorkDate(_draftDate);
var activityType = _poDraft.ActivityTypeEnum switch var activityType = _poDraft.ActivityTypeEnum switch
{ {
"phone" => "Tlf. ", "phone" => "Tlf",
"onSite" => "Bsg. ", "onSite" => "Bsg",
_ => "" _ => ""
}; };
_poDraft.OurRef = $"{activityType}{Ux.FullName.Split(" ")[0]}"; _poDraft.OurRef = $"{Ux.FullName.Split(" ")[0]} {activityType}";
_poDraft.ActivityDate = $"{_draftDate:yyyy-MM-dd}";
var ln = 0; var ln = 0;
// post to create activity endpoint // post to create activity endpoint
foreach (var line in DraftStateProvider.Draft.Items.Select(item => new DtoNgActivityLine var lines = new List<DtoNgActivityLine>();
foreach (var item in DraftStateProvider.Draft.Items)
{ {
var line = new DtoNgActivityLine{
Price = item.Price, Price = item.Price,
Discount = item.Discount, Discount = item.Discount,
Qty = item.Quantity, Qty = item.Quantity,
@ -135,13 +142,16 @@ public partial class CrmActivityCreate : IDisposable
LineAmount = item.LineTotal, LineAmount = item.LineTotal,
LineNumber = ++ln, LineNumber = ++ln,
Sas = item.Sas Sas = item.Sas
})) };
{ lines.Add(line);
_poDraft.Lines.Add(line);
} }
//await StorageService.SetItemAsync(CompanyId, _poDraft); _poDraft.Lines = lines;
await ActivityRepo.CreateActivity(_poDraft);
ToastService.ShowSuccess($"Godt så! Aktivitet oprettet for {_poDraft.Name}."); await StorageService.SetItemAsync(CompanyId, _poDraft);
var result = await ActivityRepo.CreateActivity(_poDraft).ConfigureAwait(true);
Console.WriteLine(JsonSerializer.Serialize(result));
ToastService.ShowSuccess($"{result.Message}.");
NavigationManager.NavigateTo($"/companies"); NavigationManager.NavigateTo($"/companies");
} }
@ -158,6 +168,7 @@ public partial class CrmActivityCreate : IDisposable
private void CheckDate() private void CheckDate()
{ {
_poDraft.ActivityDate = $"{_draftDate:yyyy-MM-dd}";
InvalidDate = _poDraft.CheckDate; InvalidDate = _poDraft.CheckDate;
Console.WriteLine($"InvalidDate => {InvalidDate}"); Console.WriteLine($"InvalidDate => {InvalidDate}");
} }

View file

@ -23,8 +23,8 @@ using Blazored.Toast;
using Wonky.Client; using Wonky.Client;
using Wonky.Client.HttpInterceptors; using Wonky.Client.HttpInterceptors;
using Wonky.Client.HttpRepository; using Wonky.Client.HttpRepository;
using Wonky.Client.Providers;
using Wonky.Client.Services; using Wonky.Client.Services;
using Wonky.Client.Shared;
using Wonky.Entity.Configuration; using Wonky.Entity.Configuration;
var builder = WebAssemblyHostBuilder.CreateDefault(args); var builder = WebAssemblyHostBuilder.CreateDefault(args);

View file

@ -19,7 +19,7 @@ using System.Text.Json;
using Blazored.LocalStorage; using Blazored.LocalStorage;
using Microsoft.AspNetCore.Components.Authorization; using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Wonky.Client.Providers; using Wonky.Client.Shared;
using Wonky.Entity.Configuration; using Wonky.Entity.Configuration;
using Wonky.Entity.DTO; using Wonky.Entity.DTO;

View file

@ -19,7 +19,7 @@ using Blazored.LocalStorage;
using Microsoft.AspNetCore.Components.Authorization; using Microsoft.AspNetCore.Components.Authorization;
using Wonky.Entity.DTO; using Wonky.Entity.DTO;
namespace Wonky.Client.Providers namespace Wonky.Client.Shared
{ {
public class AuthStateProvider : AuthenticationStateProvider public class AuthStateProvider : AuthenticationStateProvider
{ {

View file

@ -33,6 +33,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Providers" />
<Folder Include="wwwroot\scripts" /> <Folder Include="wwwroot\scripts" />
</ItemGroup> </ItemGroup>

View file

@ -36,7 +36,7 @@ namespace Wonky.Entity.DTO
[Required(ErrorMessage = "Vælg aktivitetstype")] public string ActivityTypeEnum { get; set; } = ""; [Required(ErrorMessage = "Vælg aktivitetstype")] public string ActivityTypeEnum { get; set; } = "";
[Required(ErrorMessage = "Vælg status for besøg ")] public string ActivityStatusEnum { get; set; } = ""; [Required(ErrorMessage = "Vælg status for besøg ")] public string ActivityStatusEnum { get; set; } = "";
public bool CheckDate { get; set; } public bool CheckDate { get; set; }
[Required] public DateTime ActivityDate { get; set; } [Required] public string ActivityDate { get; set; } = "";
[MaxLength(50, ErrorMessage = "Du kan højst bruge 50 tegn")] public string Demo { get; set; } = ""; [MaxLength(50, ErrorMessage = "Du kan højst bruge 50 tegn")] public string Demo { get; set; } = "";
[MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] public string OurRef { get; set; } = ""; [MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] public string OurRef { get; set; } = "";
[MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] public string ReferenceNumber { get; set; } = ""; [MaxLength(20, ErrorMessage = "Du kan højst bruge 20 tegn")] public string ReferenceNumber { get; set; } = "";