diff --git a/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor.cs b/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor.cs index 710ba07d..69872ad0 100644 --- a/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor.cs +++ b/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor.cs @@ -42,7 +42,7 @@ public partial class OfficeCountryCustomerListComponent // ****************************************************** // injects [Inject] public ICountryCustomerHistoryRepository HistoryRepo { get; set; } - [Inject] public ICountryActivityRepository ActivityRepo { get; set; } + [Inject] public ICountryCustomerActivityRepository CustomerActivityRepo { get; set; } // ****************************************************** // overlays @@ -67,7 +67,7 @@ public partial class OfficeCountryCustomerListComponent // call erp to crm sync before requesting invoices var newSyncDate = await HistoryRepo.RequestErpToCrmSync(CountryCode, companyId, SelectedCompany.HistorySync); await Task.Delay(500); - InvoiceList = await HistoryRepo.RequestInvoiceList(CountryCode, companyId); + InvoiceList = await HistoryRepo.GetInvoiceList(CountryCode, companyId); if(!string.IsNullOrWhiteSpace(newSyncDate)) SelectedCompany.HistorySync = newSyncDate; InvoiceListOverlay.Show(); } @@ -77,7 +77,7 @@ public partial class OfficeCountryCustomerListComponent // check for console manipulation if (!Utils.Validate(ValidateType.Id, companyId)) return; SelectedCompany = CompanyList.First(x => x.CompanyId == companyId); - ActivityList = await ActivityRepo.RequestActivityList(companyId); + ActivityList = await CustomerActivityRepo.GetActivityList(companyId); ActivityListOverlay.Show(); } @@ -90,7 +90,7 @@ public partial class OfficeCountryCustomerListComponent var newSyncDate = await HistoryRepo.RequestErpToCrmSync(CountryCode, companyId, SelectedCompany.HistorySync); await Task.Delay(500); if(!string.IsNullOrWhiteSpace(newSyncDate)) SelectedCompany.HistorySync = newSyncDate; - ProductList = await HistoryRepo.RequestInventory(SelectedCompany.CountryCode, SelectedCompany.CompanyId); + ProductList = await HistoryRepo.GetInventory(SelectedCompany.CountryCode, SelectedCompany.CompanyId); ProductListOverlay.Show(); } diff --git a/Wonky.Client/Helpers/Utils.cs b/Wonky.Client/Helpers/Utils.cs index 685ab1eb..b179a7f3 100644 --- a/Wonky.Client/Helpers/Utils.cs +++ b/Wonky.Client/Helpers/Utils.cs @@ -39,7 +39,7 @@ public static class Utils new (){ Name = "Advisor", Assigned = model.Advisor}, new (){ Name = "EDoc", Assigned = model.EDoc}, new (){ Name = "EShop", Assigned = model.EShop}, - new (){ Name = "Managment", Assigned = model.Management}, + new (){ Name = "Management", Assigned = model.Management}, new (){ Name = "Office", Assigned = model.Office}, new (){ Name = "Supervisor", Assigned = model.Supervisor}, new (){ Name = "Warehouse", Assigned = model.Warehouse} diff --git a/Wonky.Client/HttpRepository/AdvisorActivityRepository.cs b/Wonky.Client/HttpRepository/AdvisorActivityRepository.cs index 10405db9..1763857a 100644 --- a/Wonky.Client/HttpRepository/AdvisorActivityRepository.cs +++ b/Wonky.Client/HttpRepository/AdvisorActivityRepository.cs @@ -58,9 +58,11 @@ public class AdvisorActivityRepository : IAdvisorActivityRepository if (!result.IsSuccessStatusCode) return new List(); var content = await result.Content.ReadAsStringAsync(); - return string.IsNullOrWhiteSpace(content) - ? new List() - : JsonSerializer.Deserialize>(content, _options); + if (string.IsNullOrWhiteSpace(content)) + { + return new List(); + } + return JsonSerializer.Deserialize>(content, _options) ?? new List(); } /// @@ -70,11 +72,22 @@ public class AdvisorActivityRepository : IAdvisorActivityRepository /// public async Task UpdateQuoteStatus(ReportItemView activity) { + var resp = new ApiResponseView + { + Code = 404, + IsSuccess = false, + Message = "", + Id = "" + }; var response = await _client.PutAsJsonAsync( $"{_api.CrmActivities}/quote/{activity.ActivityId}", activity, _options); var content = await response.Content.ReadAsStringAsync(); + if (string.IsNullOrWhiteSpace(content)) + { + return resp; + } _logger.LogDebug("UpdateQuote Response Content <= {}", content); - return JsonSerializer.Deserialize(content, _options); + return JsonSerializer.Deserialize(content, _options) ?? resp; } /// diff --git a/Wonky.Client/HttpRepository/CountryActivityRepository.cs b/Wonky.Client/HttpRepository/CountryActivityRepository.cs index 9c896f17..5942cd0b 100644 --- a/Wonky.Client/HttpRepository/CountryActivityRepository.cs +++ b/Wonky.Client/HttpRepository/CountryActivityRepository.cs @@ -23,9 +23,6 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpRepository; -/// -/// Implementing Interface Activity CRM Http repository -/// public class CountryActivityRepository : ICountryActivityRepository { private readonly JsonSerializerOptions? _options = new JsonSerializerOptions @@ -38,6 +35,7 @@ public class CountryActivityRepository : ICountryActivityRepository private readonly HttpClient _client; private readonly ApiConfig _api; + public CountryActivityRepository(HttpClient client, ILogger logger, NavigationManager navigation, IOptions configuration) @@ -48,40 +46,27 @@ public class CountryActivityRepository : ICountryActivityRepository _api = configuration.Value; } - /// - /// Get activity data by id - /// - /// - /// - public async Task RequestActivity(string activityId) + + public async Task GetActivity(string activityId) { var activity = await _client - .GetFromJsonAsync($"{_api.CrmActivities}/{activityId}"); - return activity ?? new ActivityDto(); + .GetFromJsonAsync($"{_api.OfficeActivities}/id/{activityId}"); + + return activity ?? new ReportItemView(); } - /// - /// Get activities for customer Id - /// - /// - /// - public async Task> RequestActivityList(string customerId) + + public async Task> GetActivityList(string companyId) { - var response = await _client.GetAsync($"{_api.CrmActivities}/company/{customerId}"); + var response = await _client.GetAsync($"{_api.OfficeActivities}/company/{companyId}"); + var content = await response.Content.ReadAsStringAsync(); - if (!response.IsSuccessStatusCode) + + if (!response.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content)) + { return new List(); - return string.IsNullOrWhiteSpace(content) - ? new List() - : JsonSerializer.Deserialize>(content, _options); - } - - public async Task CreatePhoneOrder(string customerId, ActivityDto activity) - { - var response = await _client.PostAsJsonAsync($"{_api.OfficeCustomers}/{activity.CountryCode}/id/{customerId}/activities", activity); - var content = await response.Content.ReadAsStringAsync(); - return string.IsNullOrWhiteSpace(content) - ? new ApiResponseView { Code = 0, Id = "", IsSuccess = false, Message = "Ukendt fejl er opstået." } - : JsonSerializer.Deserialize(content, _options); + } + + return JsonSerializer.Deserialize>(content, _options) ?? new List(); } } \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/CountryCustomerActivityRepository.cs b/Wonky.Client/HttpRepository/CountryCustomerActivityRepository.cs new file mode 100644 index 00000000..88745f79 --- /dev/null +++ b/Wonky.Client/HttpRepository/CountryCustomerActivityRepository.cs @@ -0,0 +1,86 @@ +// 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 GNU Affero 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 +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// + +using System.Net.Http.Json; +using System.Text.Json; +using Microsoft.AspNetCore.Components; +using Microsoft.Extensions.Options; +using Wonky.Entity.Configuration; +using Wonky.Entity.DTO; +using Wonky.Entity.Views; + +namespace Wonky.Client.HttpRepository; + +public class CountryCustomerActivityRepository : ICountryCustomerActivityRepository +{ + private readonly JsonSerializerOptions? _options = new JsonSerializerOptions + { + PropertyNameCaseInsensitive = true + }; + + private readonly NavigationManager _navigation; + private readonly ILogger _logger; + private readonly HttpClient _client; + private readonly ApiConfig _api; + + + public CountryCustomerActivityRepository(HttpClient client, + ILogger logger, + NavigationManager navigation, IOptions configuration) + { + _client = client; + _logger = logger; + _navigation = navigation; + _api = configuration.Value; + } + + + public async Task GetActivity(string activityId) + { + var activity = await _client + .GetFromJsonAsync($"{_api.CrmActivities}/{activityId}"); + + return activity ?? new ActivityDto(); + } + + + public async Task> GetActivityList(string customerId) + { + var response = await _client.GetAsync($"{_api.CrmActivities}/company/{customerId}"); + + var content = await response.Content.ReadAsStringAsync(); + + if (!response.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content)) + { + return new List(); + } + + return JsonSerializer.Deserialize>(content, _options) ?? new List(); + } + + + public async Task PostPhoneOrder(string customerId, ActivityDto activity) + { + var respView = new ApiResponseView + { Code = 0, Id = "", IsSuccess = false, Message = "Ukendt fejl er opstået." }; + var response = await _client.PostAsJsonAsync($"{_api.OfficeCustomers}/{activity.CountryCode}/id/{customerId}/activities", activity); + var content = await response.Content.ReadAsStringAsync(); + if (!response.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content)) + { + return respView; + } + return JsonSerializer.Deserialize(content, _options) ?? respView; + } +} \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/CountryCustomerHistoryRepository.cs b/Wonky.Client/HttpRepository/CountryCustomerHistoryRepository.cs index 89891423..3c51ad5c 100644 --- a/Wonky.Client/HttpRepository/CountryCustomerHistoryRepository.cs +++ b/Wonky.Client/HttpRepository/CountryCustomerHistoryRepository.cs @@ -44,109 +44,104 @@ public class CountryCustomerHistoryRepository : ICountryCustomerHistoryRepositor _api = configuration.Value; } - /// - /// Fetch Invoice LIst - /// - /// - /// - /// - public async Task RequestInvoiceList(string countryCode, string companyId) + + public async Task GetInvoiceList(string countryCode, string companyId) { - var response = await _client.GetAsync($"{_api.OfficeCustomers}/{countryCode}/{companyId}/invoices"); - - if (!response.IsSuccessStatusCode) return new InvoiceListView(); + var response = await _client + .GetAsync($"{_api.OfficeCustomers}/{countryCode}/{companyId}/invoices"); var content = await response.Content.ReadAsStringAsync(); - return response.IsSuccessStatusCode - ? JsonSerializer.Deserialize(content, _options) - : new InvoiceListView(); + + if (!response.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content)) + { + return new InvoiceListView(); + } + + return JsonSerializer.Deserialize(content, _options) + ?? new InvoiceListView(); } - /// - /// Fetch given invoice for given customer - /// - /// - /// - /// - /// - public async Task FetchInvoice(string countryCode, string companyId, string invoiceId) + + public async Task GetInvoice(string countryCode, string companyId, string invoiceId) { var response = await _client .GetAsync($"{_api.OfficeCustomers}/{countryCode}/{companyId}/invoices/{invoiceId}"); - if (!response.IsSuccessStatusCode) return new InvoiceView(); + var content = await response.Content.ReadAsStringAsync(); - - return response.IsSuccessStatusCode - ? JsonSerializer.Deserialize(content, _options) - : new InvoiceView(); + + if (!response.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content)) + { + return new InvoiceView(); + } + + return JsonSerializer.Deserialize(content, _options) + ?? new InvoiceView(); } - /// - /// Fetch inventory from given customer - /// - /// - /// - /// - public async Task> RequestInventory(string countryCode, string companyId) + + public async Task> GetInventory(string countryCode, string companyId) { - var response = await _client.GetAsync($"{_api.OfficeCustomers}/{countryCode}/{companyId}/history/inventory"); - if (!response.IsSuccessStatusCode) + var response = await _client + .GetAsync($"{_api.OfficeCustomers}/{countryCode}/{companyId}/history/inventory"); + + var content = await response.Content.ReadAsStringAsync(); + + if (!response.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content)) + { return new List(); - var content = await response.Content.ReadAsStringAsync(); - return string.IsNullOrWhiteSpace(content) - ? new List() - : JsonSerializer.Deserialize>(content, _options); + } + + return JsonSerializer.Deserialize>(content, _options) + ?? new List(); } - /// - /// Fetch History for given customer - /// - /// - /// - /// - public async Task> FetchHistory(string countryCode, string companyId) + + public async Task> GetHistory(string countryCode, string companyId) { - var response = await _client.GetAsync($"{_api.OfficeCustomers}/{countryCode}/{companyId}/history/products"); - - if (!response.IsSuccessStatusCode) return new List(); + var response = await _client + .GetAsync($"{_api.OfficeCustomers}/{countryCode}/{companyId}/history/products"); var content = await response.Content.ReadAsStringAsync(); - return string.IsNullOrWhiteSpace(content) - ? new List() - : JsonSerializer.Deserialize>(content, _options); - } - /// - /// Fetch history for given customer and a given product - /// - /// - /// - /// - /// - public async Task> FetchHistorySku(string countryCode, string companyId, string sku) - { - var response = await _client.GetAsync($"{_api.OfficeCustomers}/{countryCode}/{companyId}/history/products/{sku}"); - if (!response.IsSuccessStatusCode) + if (!response.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content)) + { return new List(); - var content = await response.Content.ReadAsStringAsync(); - return string.IsNullOrWhiteSpace(content) - ? new List() - : JsonSerializer.Deserialize>(content, _options); + } + + return JsonSerializer.Deserialize>(content, _options) + ?? new List(); } - /// - /// RPC call to initiate remote server sync for given customer - /// - /// - /// - /// - /// + + public async Task> GetSkuHistory(string countryCode, string companyId, string sku) + { + var response = await _client + .GetAsync($"{_api.OfficeCustomers}/{countryCode}/{companyId}/history/products/{sku}"); + + var content = await response.Content.ReadAsStringAsync(); + + if (!response.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content)) + { + return new List(); + } + + return JsonSerializer.Deserialize>(content, _options) + ?? new List(); + } + + public async Task RequestErpToCrmSync(string countryCode, string companyId, string syncDate) { - var x = await _client.GetAsync($"{_api.OfficeCustomers}/{countryCode}/{companyId}/{_api.SyncRpcInvoiceExt}/{syncDate}"); - if (!x.IsSuccessStatusCode) + var response = await _client + .GetAsync($"{_api.OfficeCustomers}/{countryCode}/{companyId}/{_api.SyncRpcInvoiceExt}/{syncDate}"); + + var content = await response.Content.ReadAsStringAsync(); + + if (!response.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content)) + { return string.Empty; - var content = await x.Content.ReadAsStringAsync(); + } + return content.Replace("\"", ""); } } \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/OfficeUserInfoRepository.cs b/Wonky.Client/HttpRepository/CountryUserInfoRepository.cs similarity index 92% rename from Wonky.Client/HttpRepository/OfficeUserInfoRepository.cs rename to Wonky.Client/HttpRepository/CountryUserInfoRepository.cs index cf1f08ca..9d85fbcc 100644 --- a/Wonky.Client/HttpRepository/OfficeUserInfoRepository.cs +++ b/Wonky.Client/HttpRepository/CountryUserInfoRepository.cs @@ -22,7 +22,7 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpRepository; -public class OfficeUserInfoRepository : IOfficeUserInfoRepository +public class CountryUserInfoRepository : ICountryUserInfoRepository { private readonly JsonSerializerOptions? _options = new JsonSerializerOptions { @@ -30,11 +30,11 @@ public class OfficeUserInfoRepository : IOfficeUserInfoRepository }; private readonly NavigationManager _navigation; - private ILogger _logger; + private ILogger _logger; private readonly HttpClient _client; private readonly ApiConfig _api; - public OfficeUserInfoRepository(HttpClient client, ILogger logger, + public CountryUserInfoRepository(HttpClient client, ILogger logger, NavigationManager navigation, IOptions configuration) { _client = client; diff --git a/Wonky.Client/HttpRepository/EvaluationRepository.cs b/Wonky.Client/HttpRepository/EvaluationRepository.cs index f4fa8b81..1de5a77b 100644 --- a/Wonky.Client/HttpRepository/EvaluationRepository.cs +++ b/Wonky.Client/HttpRepository/EvaluationRepository.cs @@ -34,7 +34,7 @@ public class EvaluationRepository : IEvaluationRepository public async Task GetManagerByUserId(string userId) { var result = await _client - .GetFromJsonAsync($"{_api.MemberEvaluation}", _options); + .GetFromJsonAsync($"{_api.MemberEvaluation}/id/manager/{userId}", _options); return result ?? new ManagerView(); } @@ -43,13 +43,13 @@ public class EvaluationRepository : IEvaluationRepository public async Task GetMemberByUserId(string userId) { var result = await _client - .GetFromJsonAsync($"{_api.MemberEvaluation}", _options); + .GetFromJsonAsync($"{_api.MemberEvaluation}/id/member/{userId}", _options); return result ?? new MemberView(); } - public async Task> GetByManager(string managerId) + public async Task> GetEvaluationsByManagerId(string managerId) { var result = await _client .GetFromJsonAsync>( @@ -59,7 +59,7 @@ public class EvaluationRepository : IEvaluationRepository } - public async Task> GetByMember(string memberId) + public async Task> GetEvaluationsByMemberId(string memberId) { var result = await _client .GetFromJsonAsync>( diff --git a/Wonky.Client/HttpRepository/ICountryActivityRepository.cs b/Wonky.Client/HttpRepository/ICountryActivityRepository.cs index b5101d28..48580a18 100644 --- a/Wonky.Client/HttpRepository/ICountryActivityRepository.cs +++ b/Wonky.Client/HttpRepository/ICountryActivityRepository.cs @@ -18,24 +18,9 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpRepository; -/// -/// Interface Activity CRM Http repository -/// public interface ICountryActivityRepository { - /// - /// Get activity data by id - /// - /// - /// - Task RequestActivity(string activityId); - - /// - /// Get activities for customer Id - /// - /// - /// - Task> RequestActivityList(string customerId); + Task GetActivity(string activityId); - Task CreatePhoneOrder(string customerId, ActivityDto activity); + Task> GetActivityList(string companyId); } \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/IOfficeCatalogRepository.cs b/Wonky.Client/HttpRepository/ICountryCatalogRepository.cs similarity index 100% rename from Wonky.Client/HttpRepository/IOfficeCatalogRepository.cs rename to Wonky.Client/HttpRepository/ICountryCatalogRepository.cs diff --git a/Wonky.Client/HttpRepository/ICountryCustomerActivityRepository.cs b/Wonky.Client/HttpRepository/ICountryCustomerActivityRepository.cs new file mode 100644 index 00000000..c85c9320 --- /dev/null +++ b/Wonky.Client/HttpRepository/ICountryCustomerActivityRepository.cs @@ -0,0 +1,28 @@ +// 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 GNU Affero 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 +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// + +using Wonky.Entity.DTO; +using Wonky.Entity.Views; + +namespace Wonky.Client.HttpRepository; + +public interface ICountryCustomerActivityRepository +{ + Task GetActivity(string activityId); + + Task> GetActivityList(string customerId); + + Task PostPhoneOrder(string customerId, ActivityDto activity); +} \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/ICountryCustomerHistoryRepository.cs b/Wonky.Client/HttpRepository/ICountryCustomerHistoryRepository.cs new file mode 100644 index 00000000..564a8e0a --- /dev/null +++ b/Wonky.Client/HttpRepository/ICountryCustomerHistoryRepository.cs @@ -0,0 +1,33 @@ +// 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 GNU Affero 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 +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// + +using Wonky.Entity.Views; + +namespace Wonky.Client.HttpRepository; + +public interface ICountryCustomerHistoryRepository +{ + Task GetInvoiceList(string countryCode, string companyId); + + Task GetInvoice(string countryCode, string companyId, string invoiceId); + + Task> GetInventory(string countryCode, string companyId); + + Task> GetHistory(string countryCode, string companyId); + + Task> GetSkuHistory(string countryCode, string companyId, string sku); + + Task RequestErpToCrmSync(string countryCode, string companyId, string syncDate); +} \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/IOfficeCustomerRepository.cs b/Wonky.Client/HttpRepository/ICountryCustomerRepository.cs similarity index 100% rename from Wonky.Client/HttpRepository/IOfficeCustomerRepository.cs rename to Wonky.Client/HttpRepository/ICountryCustomerRepository.cs diff --git a/Wonky.Client/HttpRepository/IOfficeReportRepository.cs b/Wonky.Client/HttpRepository/ICountryReportRepository.cs similarity index 100% rename from Wonky.Client/HttpRepository/IOfficeReportRepository.cs rename to Wonky.Client/HttpRepository/ICountryReportRepository.cs diff --git a/Wonky.Client/HttpRepository/IOfficeUserInfoRepository.cs b/Wonky.Client/HttpRepository/ICountryUserInfoRepository.cs similarity index 97% rename from Wonky.Client/HttpRepository/IOfficeUserInfoRepository.cs rename to Wonky.Client/HttpRepository/ICountryUserInfoRepository.cs index 3cebd1ba..4d5ed643 100644 --- a/Wonky.Client/HttpRepository/IOfficeUserInfoRepository.cs +++ b/Wonky.Client/HttpRepository/ICountryUserInfoRepository.cs @@ -21,7 +21,7 @@ namespace Wonky.Client.HttpRepository; /// /// Interface for User handling over http /// -public interface IOfficeUserInfoRepository +public interface ICountryUserInfoRepository { /// /// Get Users diff --git a/Wonky.Client/HttpRepository/IEvaluationRepository.cs b/Wonky.Client/HttpRepository/IEvaluationRepository.cs index acc93398..9868f57b 100644 --- a/Wonky.Client/HttpRepository/IEvaluationRepository.cs +++ b/Wonky.Client/HttpRepository/IEvaluationRepository.cs @@ -7,8 +7,8 @@ public interface IEvaluationRepository { Task GetManagerByUserId(string userId); Task GetMemberByUserId(string userId); - Task> GetByManager(string managerId); - Task> GetByMember(string memberId); + Task> GetEvaluationsByManagerId(string managerId); + Task> GetEvaluationsByMemberId(string memberId); Task GetById(string evaluationId); Task CreateEvaluation(EvaluationEditView evaluationEditView); Task UpdateEvaluation(string evaluationId, EvaluationEditView evaluationEditView); diff --git a/Wonky.Client/HttpRepository/IOfficeCustomerHistoryRepository.cs b/Wonky.Client/HttpRepository/IOfficeCustomerHistoryRepository.cs deleted file mode 100644 index 01e016f5..00000000 --- a/Wonky.Client/HttpRepository/IOfficeCustomerHistoryRepository.cs +++ /dev/null @@ -1,69 +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 GNU Affero 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 -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// - -using Wonky.Entity.Views; - -namespace Wonky.Client.HttpRepository; - -/// -/// Interface Customer History CRM Http repository -/// -public interface ICountryCustomerHistoryRepository -{ - /// - /// Fetch Invoice LIst - /// - /// - /// - Task RequestInvoiceList(string countryCode, string companyId); - - /// - /// Fetch given invoice for given customer - /// - /// - /// - /// - Task FetchInvoice(string countryCode, string companyId, string invoiceId); - - /// - /// Fetch inventory from given customer - /// - /// - /// - Task> RequestInventory(string countryCode, string companyId); - - /// - /// Fetch History for given customer - /// - /// - /// - Task> FetchHistory(string countryCode, string companyId); - - /// - /// Fetch history for given customer and a given product - /// - /// - /// - /// - Task> FetchHistorySku(string countryCode, string companyId, string sku); - - /// - /// RPC call to initiate remote server sync for given customer - /// - /// - /// - /// - Task RequestErpToCrmSync(string countryCode, string companyId, string syncDate); -} \ No newline at end of file diff --git a/Wonky.Client/OverlayOffice/OfficeCustomerInventoryReorderOverlay.razor.cs b/Wonky.Client/OverlayOffice/OfficeCustomerInventoryReorderOverlay.razor.cs index 43768e75..ac88d156 100644 --- a/Wonky.Client/OverlayOffice/OfficeCustomerInventoryReorderOverlay.razor.cs +++ b/Wonky.Client/OverlayOffice/OfficeCustomerInventoryReorderOverlay.razor.cs @@ -42,7 +42,7 @@ public partial class OfficeCustomerInventoryReorderOverlay if (string.IsNullOrWhiteSpace(SalesItem.Sku)) return; - History = await HistoryRepo.FetchHistorySku(Company.CountryCode, Company.CompanyId, SalesItem.Sku); + History = await HistoryRepo.GetSkuHistory(Company.CountryCode, Company.CompanyId, SalesItem.Sku); // if (!History.Any()) // await Task.Delay(500); SelectedItem.Item = SalesItem; diff --git a/Wonky.Client/OverlayOffice/OfficeCustomerInvoiceViewOverlay.razor.cs b/Wonky.Client/OverlayOffice/OfficeCustomerInvoiceViewOverlay.razor.cs index 4698cda3..cd6e92c6 100644 --- a/Wonky.Client/OverlayOffice/OfficeCustomerInvoiceViewOverlay.razor.cs +++ b/Wonky.Client/OverlayOffice/OfficeCustomerInvoiceViewOverlay.razor.cs @@ -41,7 +41,7 @@ public partial class OfficeCustomerInvoiceViewOverlay : IDisposable if (!string.IsNullOrWhiteSpace(InvoiceId)) { - Invoice = await HistoryRepo.FetchInvoice( CountryCode, CompanyId, InvoiceId); + Invoice = await HistoryRepo.GetInvoice( CountryCode, CompanyId, InvoiceId); } } diff --git a/Wonky.Client/OverlayOffice/OfficeOrderInventoryReorderOverlay.razor.cs b/Wonky.Client/OverlayOffice/OfficeOrderInventoryReorderOverlay.razor.cs index 2c0b9c98..119cba3c 100644 --- a/Wonky.Client/OverlayOffice/OfficeOrderInventoryReorderOverlay.razor.cs +++ b/Wonky.Client/OverlayOffice/OfficeOrderInventoryReorderOverlay.razor.cs @@ -42,7 +42,7 @@ public partial class OfficeOrderInventoryReorderOverlay if (string.IsNullOrWhiteSpace(SalesItem.Sku)) return; - ProductHistory = await HistoryRepo.FetchHistorySku(Company.CountryCode, Company.CompanyId, SalesItem.Sku); + ProductHistory = await HistoryRepo.GetSkuHistory(Company.CountryCode, Company.CompanyId, SalesItem.Sku); if (!ProductHistory.Any()) await Task.Delay(250); SelectedItem.Item = SalesItem; diff --git a/Wonky.Client/Pages/ManagerEvaluationListPage.razor b/Wonky.Client/Pages/ManagerEvaluationListPage.razor index 3b684cea..19d0ecc6 100644 --- a/Wonky.Client/Pages/ManagerEvaluationListPage.razor +++ b/Wonky.Client/Pages/ManagerEvaluationListPage.razor @@ -16,7 +16,7 @@ @using Microsoft.AspNetCore.Authorization @attribute [Authorize(Roles = "Management,Supervisor")] -@page "/management/members/{UserId}/evaluations" +@page "/supervisor/members/{UserId}/evaluations" Evalueringer @@ -26,7 +26,7 @@
- Opret Evaluering + Opret Evaluering @*
diff --git a/Wonky.Client/Pages/ManagerEvaluationListPage.razor.cs b/Wonky.Client/Pages/ManagerEvaluationListPage.razor.cs index 81d2fa94..6006799d 100644 --- a/Wonky.Client/Pages/ManagerEvaluationListPage.razor.cs +++ b/Wonky.Client/Pages/ManagerEvaluationListPage.razor.cs @@ -38,27 +38,23 @@ public partial class ManagerEvaluationListPage : IDisposable private List Evaluations { get; set; } = new(); private MemberView Member { get; set; } = new(); private bool _working = true; - - protected override async Task OnParametersSetAsync() - { - Interceptor.RegisterEvent(); - Interceptor.RegisterBeforeSendEvent(); - - Member = await EvaluationRepo.GetMemberByUserId(UserId); - while (string.IsNullOrWhiteSpace(Member.MemberId)) - { - await Task.Delay(250); - } - - Logger.LogDebug("Member => {}",JsonSerializer.Serialize(Member)); - } - + + protected override async Task OnInitializedAsync() { - Evaluations = await EvaluationRepo.GetByMember(Member.MemberId); + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); - Logger.LogDebug("{}",JsonSerializer.Serialize(Evaluations)); + Logger.LogDebug("UserId => {}", UserId); + + Member = await EvaluationRepo.GetMemberByUserId(UserId); + + Logger.LogDebug("Member => {}",JsonSerializer.Serialize(Member)); + + Evaluations = await EvaluationRepo.GetEvaluationsByMemberId(Member.MemberId); + + Logger.LogDebug("Evaluations => {}",JsonSerializer.Serialize(Evaluations)); _working = false; diff --git a/Wonky.Client/Pages/ManagerEvaluationNewPage.razor b/Wonky.Client/Pages/ManagerEvaluationNewPage.razor index 5f1fbd00..81052d3d 100644 --- a/Wonky.Client/Pages/ManagerEvaluationNewPage.razor +++ b/Wonky.Client/Pages/ManagerEvaluationNewPage.razor @@ -17,7 +17,7 @@ @attribute [Authorize(Roles = "Management,Supervisor")] -@page "/management/members/{UserId}/evaluations/new" +@page "/supervisor/members/{UserId}/evaluations/new" Ny evaluering diff --git a/Wonky.Client/Pages/ManagerEvaluationNewPage.razor.cs b/Wonky.Client/Pages/ManagerEvaluationNewPage.razor.cs index 0e14b788..0f5adcc9 100644 --- a/Wonky.Client/Pages/ManagerEvaluationNewPage.razor.cs +++ b/Wonky.Client/Pages/ManagerEvaluationNewPage.razor.cs @@ -13,6 +13,7 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // +using System.Text.Json; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Forms; using Wonky.Client.HttpInterceptors; @@ -30,6 +31,8 @@ public partial class ManagerEvaluationNewPage : IDisposable [Inject] public IEvaluationRepository EvaluationRepo { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public IUserInfoService UserService { get; set; } + [Inject] public ILogger Logger { get; set; } + // ############################################################ [Parameter] public string UserId { get; set; } = ""; @@ -47,10 +50,16 @@ public partial class ManagerEvaluationNewPage : IDisposable Interceptor.RegisterBeforeSendEvent(); Member = await EvaluationRepo.GetMemberByUserId(UserId); + + Logger.LogDebug("Member => {}", JsonSerializer.Serialize(Member)); + var managerId = await UserService.GetUserId(); + Logger.LogDebug("ManagerId => {}", managerId); + Manager = await EvaluationRepo.GetManagerByUserId(managerId); + Logger.LogDebug("Manager => {}", JsonSerializer.Serialize(Manager)); } diff --git a/Wonky.Client/Pages/ManagerEvaluationViewEditPage.razor b/Wonky.Client/Pages/ManagerEvaluationViewEditPage.razor index d7e79398..c5f562f3 100644 --- a/Wonky.Client/Pages/ManagerEvaluationViewEditPage.razor +++ b/Wonky.Client/Pages/ManagerEvaluationViewEditPage.razor @@ -17,7 +17,7 @@ @attribute [Authorize(Roles = "Management,Supervisor")] -@page "/management/members/{UserId}/evaluations/{EvaluationId}" +@page "/supervisor/members/{UserId}/evaluations/{EvaluationId}"
diff --git a/Wonky.Client/Pages/ManagerMemberActivityListViewPage.razor b/Wonky.Client/Pages/ManagerMemberActivityListViewPage.razor new file mode 100644 index 00000000..b333f149 --- /dev/null +++ b/Wonky.Client/Pages/ManagerMemberActivityListViewPage.razor @@ -0,0 +1,48 @@ +@* 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 GNU Affero 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 +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +*@ + +@using Wonky.Client.Components +@using Microsoft.AspNetCore.Authorization +@attribute [Authorize(Roles = "Management,Supervisor")] + +@page "/supervisor/members/{UserId}/activities/{ReportDate}" + +
+ @if (!string.IsNullOrWhiteSpace(Report.ReportData.DayTypeEnum)) + { + @Report.ReportData.Name +
+
+

@Report.ReportData.Name

+
+
+
+
+ +
+
+ +
+
+ + + } + else + { +
+
Ingen rapport data
+
+ } +
diff --git a/Wonky.Client/Pages/ManagerMemberActivityListViewPage.razor.cs b/Wonky.Client/Pages/ManagerMemberActivityListViewPage.razor.cs new file mode 100644 index 00000000..a0f6ca41 --- /dev/null +++ b/Wonky.Client/Pages/ManagerMemberActivityListViewPage.razor.cs @@ -0,0 +1,150 @@ +// 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 GNU Affero 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 +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// 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.Toast.Services; +using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; +using Wonky.Client.Helpers; +using Wonky.Client.HttpInterceptors; +using Wonky.Client.HttpRepository; +using Wonky.Client.Local.Services; +using Wonky.Client.Models; +using Wonky.Entity.DTO; +using Wonky.Entity.Views; +#pragma warning disable CS8618 + +namespace Wonky.Client.Pages; + +public partial class ManagerMemberActivityListViewPage : IDisposable +{ + // ############################################################# + [Inject] public HttpInterceptorService Interceptor { get; set; } + [Inject] public ICountryReportRepository ReportRepo { get; set; } + [Inject] public NavigationManager Navigator { get; set; } + [Inject] public ILogger Logger { get; set; } + [Inject] public ILocalStorageService Storage { get; set; } + [Inject] public UserPreferenceService PreferenceService { get; set; } + [Inject] public IToastService Toaster { get; set; } + [Inject] public IOrderProcessRepository ProcessRepo { get; set; } + // [Inject] public EventCallback OnShowDocument { get; set; } + + + // ############################################################# + [Parameter] public string UserId { get; set; } = ""; + [Parameter] public string ReportDate { get; set; } = ""; + + + // ############################################################# + private IJSObjectReference JsModule { get; set; } + private ReportView Report { get; set; } = new(); + private List Activities { get; set; } = new(); + private bool Working { get; set; } = true; + private UserPreference Profile { get; set; } = new(); + private string _returnUrl = ""; + + + protected override async Task OnParametersSetAsync() + { + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); + + PreferenceService.OnChange += ProfileServiceOnOnChange; + + await PreferenceService.SetWorkDate(DateTime.Parse(ReportDate)); + + await FetchUserReport(ReportDate); + } + + /// + /// Event handler to show the document by Id + /// + /// + private void ShowDocument(string documentId) + { + // shoe order/activity document + // the supervisor version + Navigator.NavigateTo($"/supervisor/members/{UserId}/activities/{ReportDate}/visits/{documentId}"); + } + + + /// + /// Work date component event handler + /// + /// + private async Task FetchUserReport(string workDate) + { + // remove busy signal if report is empty + if (string.IsNullOrWhiteSpace(Report.ReportData.ReportDate)) + { + Working = false; + } + + ReportDate = workDate; + + // ensure the browser address bar contains the correct link + Navigator.NavigateTo($"/supervisor/members/{UserId}/activities/{workDate}", false, true); + + // return if we are already at it + if (Working) + { + return; + } + + // reset variables + Report = new ReportView(); + Activities = new List(); + + // set busy signal + Working = true; + + Logger.LogDebug("UserId => {}", UserId); + // fetch report + Report = await ReportRepo.GetCountryReport(UserId, workDate); + Logger.LogDebug("Report => {}", JsonSerializer.Serialize(Report, new JsonSerializerOptions(JsonSerializerDefaults.Web))); + + // extract activities + Activities = Report.ReportItems.Where(x => x.Lines.Any()).ToList(); + + // store locally + if (!string.IsNullOrWhiteSpace(Report.ReportData.ReportDate)) + { + await Storage.SetItemAsync($"{UserId}-{workDate}", Report); + } + + // remove busy signal + Working = false; + } + + + private void ProfileServiceOnOnChange(UserPreference userPreference) + { + Logger.LogDebug("OfficeReportViewPage => ProfileServiceOnOnChange"); + Profile = userPreference; + Logger.LogDebug("OfficeReportViewPage => ProfileServiceOnOnChange => Prefs.WorkDate <= {}", Profile.WorkDate); + ReportDate = Profile.WorkDate; + + StateHasChanged(); + } + + + public void Dispose() + { + Interceptor.DisposeEvent(); + PreferenceService.OnChange -= ProfileServiceOnOnChange; + } +} diff --git a/Wonky.Client/Pages/ManagerMemberActivityViewPage.razor b/Wonky.Client/Pages/ManagerMemberActivityViewPage.razor index b558d325..a40da505 100644 --- a/Wonky.Client/Pages/ManagerMemberActivityViewPage.razor +++ b/Wonky.Client/Pages/ManagerMemberActivityViewPage.razor @@ -13,36 +13,145 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] *@ -@using Wonky.Client.Components + @using Microsoft.AspNetCore.Authorization +@using Wonky.Client.Components @attribute [Authorize(Roles = "Management,Supervisor")] -@page "/management/members/{UserId}/activities/{ReportDate}" +@page "/supervisor/members/{UserId}/activities/{ReportDate}/visits/{DocumentId}" -
- @if (!string.IsNullOrWhiteSpace(Report.ReportData.DayTypeEnum)) +@ReportItem.ESalesNumber - @ReportItem.Company.Name + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

@ReportItem.Company.Name

+ @if (ReportItem.Express) + { +

HASTER

+ } + @if (ReportItem.VisitTypeEnum.ToLower() == "phone" || ReportItem.OurRef.Contains("T:")) + { +
TELEFONORDRE
+ } + @if (ReportItem.StatusTypeEnum is "Quote") + { +
TILBUD
+ } +
+
Dato@ReportItem.OrderDateKonto@ReportItem.Company.Account
Telefon@ReportItem.Company.PhoneKøber@ReportItem.YourRef
CVR/VAT@ReportItem.Company.VatNumberRekvisition@ReportItem.ReferenceNumber
Navn@ReportItem.Company.NameLev.Navn@ReportItem.DlvName
Adresse@ReportItem.Company.Address1Lev.Adresse@ReportItem.DlvAddress1
Adresse@ReportItem.Company.Address2Lev.Adresse@ReportItem.DlvAddress2
Postnr By@ReportItem.Company.ZipCode @ReportItem.Company.CityLev.Postnr By@ReportItem.DlvZipCity
Email@ReportItem.Company.Email
+ + + + + + + + + + + + + @foreach (var line in ReportItem.Lines) { - @Report.ReportData.Name -
-
-

@Report.ReportData.Name

-
-
-
-
- -
-
- -
-
- - + + + + + + + + } - else + + + + + + @if (ReportItem.Express) { -
-
Ingen rapport data
-
+ + } + +
AntalVarnrBeskrivelsePrisR%Beløb
@line.Quantity@line.Sku@line.Description@($"{line.Price:N2}")@($"{line.Discount:N2}")@($"{line.LineSum:N2}")
Ordresum@ReportItem.OrderAmount
+
HASTER
+
+
+
+
+
+ Noter +
+
+
+
+
+ Kontor +
+ @ReportItem.OfficeNote +
+
+
+ Kundekort +
+ @ReportItem.CrmNote +
+ +@if (Working) +{ + +} diff --git a/Wonky.Client/Pages/ManagerMemberActivityViewPage.razor.cs b/Wonky.Client/Pages/ManagerMemberActivityViewPage.razor.cs index 9cd3083d..01f8de10 100644 --- a/Wonky.Client/Pages/ManagerMemberActivityViewPage.razor.cs +++ b/Wonky.Client/Pages/ManagerMemberActivityViewPage.razor.cs @@ -14,16 +14,14 @@ // +using System.Text; using System.Text.Json; using Blazored.LocalStorage; using Blazored.Toast.Services; using Microsoft.AspNetCore.Components; -using Microsoft.JSInterop; -using Wonky.Client.Helpers; using Wonky.Client.HttpInterceptors; using Wonky.Client.HttpRepository; using Wonky.Client.Local.Services; -using Wonky.Client.Models; using Wonky.Entity.DTO; using Wonky.Entity.Views; #pragma warning disable CS8618 @@ -34,117 +32,45 @@ public partial class ManagerMemberActivityViewPage : IDisposable { // ############################################################# [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public ICountryReportRepository ReportRepo { get; set; } - [Inject] public NavigationManager Navigator { get; set; } - [Inject] public ILogger Logger { get; set; } + [Inject] public ICountryActivityRepository ActivityRepo { get; set; } + [Inject] public ISystemSendMailService MailService { get; set; } [Inject] public ILocalStorageService Storage { get; set; } - [Inject] public UserPreferenceService PreferenceService { get; set; } - [Inject] public IToastService Toaster { get; set; } - [Inject] public IOrderProcessRepository ProcessRepo { get; set; } - // [Inject] public EventCallback OnShowDocument { get; set; } - + [Inject] public ICountryUserInfoRepository UserRepo { get; set; } + [Inject] public ILogger Logger { get; set; } + [Inject] public IToastService Toast { get; set; } + [Inject] public IUserInfoService UserInfoService { get; set; } + // ############################################################# [Parameter] public string UserId { get; set; } = ""; + [Parameter] public string DocumentId { get; set; } = ""; [Parameter] public string ReportDate { get; set; } = ""; - - - // ############################################################# - private IJSObjectReference JsModule { get; set; } - private ReportView Report { get; set; } = new(); - private List Activities { get; set; } = new(); - private bool Working { get; set; } = true; - private UserPreference Profile { get; set; } = new(); - private string _returnUrl = ""; - protected override async Task OnParametersSetAsync() + // ############################################################# + private ReportItemView ReportItem { get; set; } = new(); + private bool IsNotified { get; set; } + private bool Working { get; set; } = true; + private readonly JsonSerializerOptions _options = new JsonSerializerOptions + { + PropertyNameCaseInsensitive = true + }; + + + + protected override async Task OnInitializedAsync() { Interceptor.RegisterEvent(); Interceptor.RegisterBeforeSendEvent(); - - PreferenceService.OnChange += ProfileServiceOnOnChange; - - await PreferenceService.SetWorkDate(DateTime.Parse(ReportDate)); - - await FetchUserReport(ReportDate); - } - - /// - /// Event handler to show the document by Id - /// - /// - private void ShowDocument(string documentId) - { - // shoe order/activity document - // the supervisor version - Navigator.NavigateTo($"/management/members/{UserId}/activities/{ReportDate}/visits/{documentId}"); - } - - - /// - /// Work date component event handler - /// - /// - private async Task FetchUserReport(string workDate) - { - // remove busy signal if report is empty - if (string.IsNullOrWhiteSpace(Report.ReportData.ReportDate)) - { - Working = false; - } - - ReportDate = workDate; - - // ensure the browser address bar contains the correct link - Navigator.NavigateTo($"/management/members/{UserId}/activities/{workDate}", false, true); - - // return if we are already at it - if (Working) - { - return; - } - - // reset variables - Report = new ReportView(); - Activities = new List(); - - // set busy signal - Working = true; - - Logger.LogDebug("UserId => {}", UserId); - // fetch report - Report = await ReportRepo.GetCountryReport(UserId, workDate); - Logger.LogDebug("Report => {}", JsonSerializer.Serialize(Report, new JsonSerializerOptions(JsonSerializerDefaults.Web))); - - // extract activities - Activities = Report.ReportItems.Where(x => x.Lines.Any()).ToList(); - - // store locally - if (!string.IsNullOrWhiteSpace(Report.ReportData.ReportDate)) - { - await Storage.SetItemAsync($"{UserId}-{workDate}", Report); - } - - // remove busy signal + // fetch order from backend + ReportItem = await ActivityRepo.GetActivity(DocumentId); + Logger.LogDebug("ReportItem => \n {}", JsonSerializer.Serialize(ReportItem, _options)); Working = false; } - - private void ProfileServiceOnOnChange(UserPreference userPreference) - { - Logger.LogDebug("OfficeReportViewPage => ProfileServiceOnOnChange"); - Profile = userPreference; - Logger.LogDebug("OfficeReportViewPage => ProfileServiceOnOnChange => Prefs.WorkDate <= {}", Profile.WorkDate); - ReportDate = Profile.WorkDate; - - StateHasChanged(); - } - public void Dispose() { Interceptor.DisposeEvent(); - PreferenceService.OnChange -= ProfileServiceOnOnChange; } } diff --git a/Wonky.Client/Pages/ManagerMemberVisitViewPage.razor.css b/Wonky.Client/Pages/ManagerMemberActivityViewPage.razor.css similarity index 100% rename from Wonky.Client/Pages/ManagerMemberVisitViewPage.razor.css rename to Wonky.Client/Pages/ManagerMemberActivityViewPage.razor.css diff --git a/Wonky.Client/Pages/ManagerMemberViewPage.razor b/Wonky.Client/Pages/ManagerMemberBaseViewPage.razor similarity index 97% rename from Wonky.Client/Pages/ManagerMemberViewPage.razor rename to Wonky.Client/Pages/ManagerMemberBaseViewPage.razor index 80447d2f..27b2f0b0 100644 --- a/Wonky.Client/Pages/ManagerMemberViewPage.razor +++ b/Wonky.Client/Pages/ManagerMemberBaseViewPage.razor @@ -17,7 +17,7 @@ @using Wonky.Client.Components @attribute [Authorize(Roles = "Management,Supervisor")] -@page "/management/members/{UserId}" +@page "/supervisor/members/{UserId}" Rapport Arkiv @InfoAdvisor.FirstName @InfoAdvisor.LastName
diff --git a/Wonky.Client/Pages/ManagerMemberViewPage.razor.cs b/Wonky.Client/Pages/ManagerMemberBaseViewPage.razor.cs similarity index 90% rename from Wonky.Client/Pages/ManagerMemberViewPage.razor.cs rename to Wonky.Client/Pages/ManagerMemberBaseViewPage.razor.cs index 48a3db25..592f9438 100644 --- a/Wonky.Client/Pages/ManagerMemberViewPage.razor.cs +++ b/Wonky.Client/Pages/ManagerMemberBaseViewPage.razor.cs @@ -7,14 +7,14 @@ using Wonky.Entity.Views; namespace Wonky.Client.Pages; -public partial class ManagerMemberViewPage : IDisposable +public partial class ManagerMemberBaseViewPage : IDisposable { // ############################################################# [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public IOfficeUserInfoRepository UserRepo { get; set; } + [Inject] public ICountryUserInfoRepository UserRepo { get; set; } [Inject] public ICountryReportRepository ReportRepo { get; set; } [Inject] public NavigationManager Navigator { get; set; } - [Inject] public ILogger Logger { get; set; } + [Inject] public ILogger Logger { get; set; } // ############################################################# diff --git a/Wonky.Client/Pages/ManagerMemberListPage.razor b/Wonky.Client/Pages/ManagerMemberListPage.razor index 5b992834..628af735 100644 --- a/Wonky.Client/Pages/ManagerMemberListPage.razor +++ b/Wonky.Client/Pages/ManagerMemberListPage.razor @@ -16,7 +16,7 @@ @using Microsoft.AspNetCore.Authorization @attribute [Authorize(Roles = "Supervisor")] -@page "/management" +@page "/supervisor" Supervisor @@ -68,8 +68,8 @@
diff --git a/Wonky.Client/Pages/ManagerMemberListPage.razor.cs b/Wonky.Client/Pages/ManagerMemberListPage.razor.cs index 14b881c7..ba006c79 100644 --- a/Wonky.Client/Pages/ManagerMemberListPage.razor.cs +++ b/Wonky.Client/Pages/ManagerMemberListPage.razor.cs @@ -26,7 +26,7 @@ public partial class ManagerMemberListPage { // ############################################################# [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public IOfficeUserInfoRepository UserRepo { get; set; } + [Inject] public ICountryUserInfoRepository UserRepo { get; set; } // ############################################################# private List Users { get; set; } = new(); diff --git a/Wonky.Client/Pages/ManagerMemberVisitViewPage.razor b/Wonky.Client/Pages/ManagerMemberVisitViewPage.razor deleted file mode 100644 index 5c7fc544..00000000 --- a/Wonky.Client/Pages/ManagerMemberVisitViewPage.razor +++ /dev/null @@ -1,157 +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 GNU Affero 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 -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -*@ - - -@using Microsoft.AspNetCore.Authorization -@using Wonky.Client.Components -@attribute [Authorize(Roles = "Management,Supervisor")] - -@page "/management/members/{UserId}/activities/{ReportDate}/visits/{DocumentId}" - -@ReportItem.ESalesNumber - @ReportItem.Company.Name - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-

@ReportItem.Company.Name

- @if (ReportItem.Express) - { -

HASTER

- } - @if (ReportItem.VisitTypeEnum.ToLower() == "phone" || ReportItem.OurRef.Contains("T:")) - { -
TELEFONORDRE
- } - @if (ReportItem.StatusTypeEnum is "Quote") - { -
TILBUD
- } -
-
Dato@ReportItem.OrderDateKonto@ReportItem.Company.Account
Telefon@ReportItem.Company.PhoneKøber@ReportItem.YourRef
CVR/VAT@ReportItem.Company.VatNumberRekvisition@ReportItem.ReferenceNumber
Navn@ReportItem.Company.NameLev.Navn@ReportItem.DlvName
Adresse@ReportItem.Company.Address1Lev.Adresse@ReportItem.DlvAddress1
Adresse@ReportItem.Company.Address2Lev.Adresse@ReportItem.DlvAddress2
Postnr By@ReportItem.Company.ZipCode @ReportItem.Company.CityLev.Postnr By@ReportItem.DlvZipCity
Email@ReportItem.Company.Email
- - - - - - - - - - - - - @foreach (var line in ReportItem.Lines) - { - - - - - - - - - } - - - - - - @if (ReportItem.Express) - { - - - } - -
AntalVarnrBeskrivelsePrisR%Beløb
@line.Quantity@line.Sku@line.Description@($"{line.Price:N2}")@($"{line.Discount:N2}")@($"{line.LineSum:N2}")
Ordresum@ReportItem.OrderAmount
-
HASTER
-
-
-
-
-
- Noter -
-
-
-
-
- Kontor -
- @ReportItem.OfficeNote -
-
-
- Kundekort -
- @ReportItem.CrmNote -
-
- -@if (Working) -{ - -} diff --git a/Wonky.Client/Pages/ManagerMemberVisitViewPage.razor.cs b/Wonky.Client/Pages/ManagerMemberVisitViewPage.razor.cs deleted file mode 100644 index fb1963ba..00000000 --- a/Wonky.Client/Pages/ManagerMemberVisitViewPage.razor.cs +++ /dev/null @@ -1,75 +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 GNU Affero 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 -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// - - -using System.Text; -using System.Text.Json; -using Blazored.LocalStorage; -using Blazored.Toast.Services; -using Microsoft.AspNetCore.Components; -using Wonky.Client.HttpInterceptors; -using Wonky.Client.HttpRepository; -using Wonky.Client.Local.Services; -using Wonky.Entity.DTO; -using Wonky.Entity.Views; -#pragma warning disable CS8618 - -namespace Wonky.Client.Pages; - -public partial class ManagerMemberVisitViewPage : IDisposable -{ - // ############################################################# - [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public IAdvisorActivityRepository AdvisorActivityRepo { get; set; } - [Inject] public ISystemSendMailService MailService { get; set; } - [Inject] public ILocalStorageService Storage { get; set; } - [Inject] public IOfficeUserInfoRepository UserRepo { get; set; } - [Inject] public ILogger Logger { get; set; } - [Inject] public IToastService Toast { get; set; } - [Inject] public IUserInfoService UserInfoService { get; set; } - - - // ############################################################# - [Parameter] public string UserId { get; set; } = ""; - [Parameter] public string DocumentId { get; set; } = ""; - [Parameter] public string ReportDate { get; set; } = ""; - - - // ############################################################# - private ReportItemView ReportItem { get; set; } = new(); - private bool IsNotified { get; set; } - private bool Working { get; set; } = true; - private readonly JsonSerializerOptions _options = new JsonSerializerOptions - { - PropertyNameCaseInsensitive = true - }; - - - protected override async Task OnInitializedAsync() - { - Interceptor.RegisterEvent(); - Interceptor.RegisterBeforeSendEvent(); - // fetch order from backend - ReportItem = await AdvisorActivityRepo.GetReportItem(DocumentId); - Logger.LogDebug("ReportItem => \n {}", JsonSerializer.Serialize(ReportItem, _options)); - Working = false; - } - - - public void Dispose() - { - Interceptor.DisposeEvent(); - } -} diff --git a/Wonky.Client/Pages/OfficeAdvisorCustomerPagedListPage.razor.cs b/Wonky.Client/Pages/OfficeAdvisorCustomerPagedListPage.razor.cs index 08e08c6f..17cdf796 100644 --- a/Wonky.Client/Pages/OfficeAdvisorCustomerPagedListPage.razor.cs +++ b/Wonky.Client/Pages/OfficeAdvisorCustomerPagedListPage.razor.cs @@ -31,7 +31,7 @@ public partial class OfficeAdvisorCustomerPagedListPage : IDisposable [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public ICountryCustomerRepository CustomerRepo { get; set; } [Inject] public UserPreferenceService UserPreferenceService { get; set; } - [Inject] public IOfficeUserInfoRepository UserRepo { get; set; } + [Inject] public ICountryUserInfoRepository UserRepo { get; set; } // ############################################################# [Parameter] public string UserId { get; set; } = ""; diff --git a/Wonky.Client/Pages/OfficeAdvisorListPage.razor.cs b/Wonky.Client/Pages/OfficeAdvisorListPage.razor.cs index 1cecfd56..4e86c5a8 100644 --- a/Wonky.Client/Pages/OfficeAdvisorListPage.razor.cs +++ b/Wonky.Client/Pages/OfficeAdvisorListPage.razor.cs @@ -28,7 +28,7 @@ public partial class OfficeAdvisorListPage :IDisposable { // ############################################################# [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public IOfficeUserInfoRepository UserRepo { get; set; } + [Inject] public ICountryUserInfoRepository UserRepo { get; set; } // ############################################################# [Parameter] public string CountryCode { get; set; } = ""; diff --git a/Wonky.Client/Pages/OfficeAdvisorReportListPage.razor.cs b/Wonky.Client/Pages/OfficeAdvisorReportListPage.razor.cs index 7f597f34..c562958e 100644 --- a/Wonky.Client/Pages/OfficeAdvisorReportListPage.razor.cs +++ b/Wonky.Client/Pages/OfficeAdvisorReportListPage.razor.cs @@ -28,7 +28,7 @@ public partial class OfficeAdvisorReportListPage : IDisposable // ############################################################# [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public ICountryReportRepository ReportRepo { get; set; } - [Inject] public IOfficeUserInfoRepository UserRepo { get; set; } + [Inject] public ICountryUserInfoRepository UserRepo { get; set; } [Inject] public NavigationManager Navigator { get; set; } // ############################################################# diff --git a/Wonky.Client/Pages/OfficeOrderCreatePage.razor.cs b/Wonky.Client/Pages/OfficeOrderCreatePage.razor.cs index 16fbd244..69018798 100644 --- a/Wonky.Client/Pages/OfficeOrderCreatePage.razor.cs +++ b/Wonky.Client/Pages/OfficeOrderCreatePage.razor.cs @@ -43,8 +43,8 @@ public partial class OfficeOrderCreatePage : IDisposable [Inject] public ICountryCatalogRepository Catalog { get; set; } [Inject] public ICountryCustomerRepository CustomerRepo { get; set; } [Inject] public ICountryCustomerHistoryRepository HistoryRepo { get; set; } - [Inject] public ICountryActivityRepository ActivityRepo { get; set; } - [Inject] public IOfficeUserInfoRepository UserRepo { get; set; } + [Inject] public ICountryCustomerActivityRepository CustomerActivityRepo { get; set; } + [Inject] public ICountryUserInfoRepository UserRepo { get; set; } [Inject] public NavigationManager Navigator { get; set; } [Inject] public IUserInfoService UserInfoService { get; set; } @@ -114,13 +114,13 @@ public partial class OfficeOrderCreatePage : IDisposable Logger.LogDebug("OfficeOrderCreate => RequestErpToCrmSync <= {}", Company.HistorySync); } // fetch invoices - CompanyInvoices = await HistoryRepo.RequestInvoiceList(CountryCode, CompanyId); + CompanyInvoices = await HistoryRepo.GetInvoiceList(CountryCode, CompanyId); Logger.LogDebug("OfficeOrderCreate => Invoices => {}", JsonSerializer.Serialize(CompanyInvoices)); // fetch activities - CompanyActivities = await ActivityRepo.RequestActivityList(CompanyId); + CompanyActivities = await CustomerActivityRepo.GetActivityList(CompanyId); Logger.LogDebug("OfficeOrderCreate => Activities => {}", JsonSerializer.Serialize(CompanyActivities)); // fetch inventory - CompanyInventory = await HistoryRepo.RequestInventory(CountryCode, CompanyId); + CompanyInventory = await HistoryRepo.GetInventory(CountryCode, CompanyId); CompanyInventory = CompanyInventory.OrderBy(x => x.Description).ToList(); Logger.LogDebug("OfficeOrderCreate => Inventory => {}", JsonSerializer.Serialize(CompanyInventory)); // get sales rep info @@ -310,7 +310,7 @@ public partial class OfficeOrderCreatePage : IDisposable // debug logging Logger.LogDebug("CrmNewActivityPage => \n {}", JsonSerializer.Serialize(Activity)); // post to api - var result = await ActivityRepo.CreatePhoneOrder(Company.CompanyId, Activity); + var result = await CustomerActivityRepo.PostPhoneOrder(Company.CompanyId, Activity); // debug logging Logger.LogDebug("ApiResponseView => \n {}", JsonSerializer.Serialize(result)); // show result message diff --git a/Wonky.Client/Pages/OfficeOrderViewPage.razor.cs b/Wonky.Client/Pages/OfficeOrderViewPage.razor.cs index 2f6a3505..83765895 100644 --- a/Wonky.Client/Pages/OfficeOrderViewPage.razor.cs +++ b/Wonky.Client/Pages/OfficeOrderViewPage.razor.cs @@ -35,7 +35,7 @@ public partial class OfficeOrderViewPage : IDisposable [Inject] public IAdvisorActivityRepository AdvisorActivityRepo { get; set; } [Inject] public ISystemSendMailService MailService { get; set; } [Inject] public ILocalStorageService Storage { get; set; } - [Inject] public IOfficeUserInfoRepository UserRepo { get; set; } + [Inject] public ICountryUserInfoRepository UserRepo { get; set; } [Inject] public ILogger Logger { get; set; } [Inject] public IToastService Toast { get; set; } [Inject] public IUserInfoService UserInfoService { get; set; } diff --git a/Wonky.Client/Program.cs b/Wonky.Client/Program.cs index c6bba798..74543f6c 100644 --- a/Wonky.Client/Program.cs +++ b/Wonky.Client/Program.cs @@ -66,15 +66,16 @@ builder.Services.AddScoped(); builder.Services.AddScoped(); // administrative repositories builder.Services.AddScoped(); -builder.Services.AddScoped(); +builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); -builder.Services.AddScoped(); +builder.Services.AddScoped(); builder.Services.AddScoped(); +builder.Services.AddScoped(); // warehouse repository builder.Services.AddScoped(); // mail service diff --git a/Wonky.Client/Shared/NavMenu.razor b/Wonky.Client/Shared/NavMenu.razor index 101efeac..fe96e5c9 100644 --- a/Wonky.Client/Shared/NavMenu.razor +++ b/Wonky.Client/Shared/NavMenu.razor @@ -119,8 +119,8 @@ diff --git a/Wonky.Client/wwwroot/appsettings.json b/Wonky.Client/wwwroot/appsettings.json index a86fca93..67b533a1 100644 --- a/Wonky.Client/wwwroot/appsettings.json +++ b/Wonky.Client/wwwroot/appsettings.json @@ -29,6 +29,7 @@ "crmTasks": "api/v2/crm/advisors/tasks", "crmWorkplaceExt": "workplaces", "officeBase": "api/v2/office", + "officeActivities": "api/v2/office/activities", "officeAdvisors": "api/v2/office/users/advisors", "officeCustomers": "api/v2/office/customers", "officeReports": "api/v2/office/reports", diff --git a/Wonky.Entity/Configuration/ApiConfig.cs b/Wonky.Entity/Configuration/ApiConfig.cs index 2cadefdc..775c96d8 100644 --- a/Wonky.Entity/Configuration/ApiConfig.cs +++ b/Wonky.Entity/Configuration/ApiConfig.cs @@ -68,6 +68,11 @@ public class ApiConfig ///
public string OfficeBase { get; set; } = ""; + /// + /// Office activity url + /// + public string OfficeActivities { get; set; } = ""; + /// /// Application uri for administration of sales representatives ///