diff --git a/Wonky.Client/Components/CustomerProductTableComponent.razor.cs b/Wonky.Client/Components/CustomerProductTableComponent.razor.cs index 136a5094..b1ec58d4 100644 --- a/Wonky.Client/Components/CustomerProductTableComponent.razor.cs +++ b/Wonky.Client/Components/CustomerProductTableComponent.razor.cs @@ -30,7 +30,7 @@ public partial class CustomerProductTableComponent [CascadingParameter] public DraftStateProvider DraftStateProvider { get; set; } = new(); [Parameter] public List ProductList { get; set; } = new(); [Parameter] public string CompanyId { get; set; } = ""; - [Inject] public ICatalogHttpRepository Catalog { get; set; } + [Inject] public ICatalogCrmHttpRepository CatalogCrm { get; set; } [Inject] public ILocalStorageService Storage { get; set; } // private variables private SalesItemView SalesItem { get; set; } = new(); @@ -89,7 +89,7 @@ public partial class CustomerProductTableComponent private async Task CallShowReorderModal(string sku) { // fetch item from http repo - SalesItem = await Catalog.GetSalesItemSku(sku); + SalesItem = await CatalogCrm.GetSalesItemSku(sku); ReorderModal.Show(); } diff --git a/Wonky.Client/Components/LandingComponentAdmin.razor.cs b/Wonky.Client/Components/LandingComponentAdmin.razor.cs index a342cae0..bfa137f2 100644 --- a/Wonky.Client/Components/LandingComponentAdmin.razor.cs +++ b/Wonky.Client/Components/LandingComponentAdmin.razor.cs @@ -36,7 +36,7 @@ public partial class LandingComponentAdmin : IDisposable [Inject] public ILogger Logger { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public IToastService Toaster { get; set; } - [Inject] public ICrmTaskItemHttpRepository CrmTaskItemRepo { get; set; } + [Inject] public ITaskItemCrmHttpRepository TaskRepo { get; set; } [Inject] public NavigationManager Navigator { get; set; } private readonly JsonSerializerOptions _options = new JsonSerializerOptions diff --git a/Wonky.Client/Components/LandingComponentAdvisor.razor.cs b/Wonky.Client/Components/LandingComponentAdvisor.razor.cs index c471c4fd..c2351ea9 100644 --- a/Wonky.Client/Components/LandingComponentAdvisor.razor.cs +++ b/Wonky.Client/Components/LandingComponentAdvisor.razor.cs @@ -36,7 +36,7 @@ public partial class LandingComponentAdvisor : IDisposable [Inject] public ILogger Logger { get; set; } [Inject] public HttpInterceptorService Inteceptor { get; set; } [Inject] public IToastService Toaster { get; set; } - [Inject] public ICrmTaskItemHttpRepository TaskItemRepo { get; set; } + [Inject] public ITaskItemCrmHttpRepository TaskRepo { get; set; } [Inject] public NavigationManager Navigator { get; set; } private readonly JsonSerializerOptions JsonOptions = new JsonSerializerOptions @@ -63,7 +63,7 @@ public partial class LandingComponentAdvisor : IDisposable private async Task GetAllTasks() { - TaskItems = await TaskItemRepo.GetTaskList(); + TaskItems = await TaskRepo.GetTaskList(); } private async Task OnCompleteTask(string taskItemId) @@ -77,14 +77,14 @@ public partial class LandingComponentAdvisor : IDisposable { SelectedDate = DateTime.Parse(workDate); TaskItems = new List(); - TaskItems = await TaskItemRepo.GetTaskList($"{SelectedDate:yyyy-MM-dd}"); + TaskItems = await TaskRepo.GetTaskList($"{SelectedDate:yyyy-MM-dd}"); } private async Task OnTaskCompleted(string taskItemId) { var item = TaskItems.Find(x => x.TaskItemId == taskItemId); item.IsCompleted = true; - await TaskItemRepo.UpdateTaskItem(taskItemId, item); + await TaskRepo.UpdateTaskItem(taskItemId, item); TaskItems.Remove(item); Toaster.ShowInfo("Opgaven er markeret som udført."); } @@ -93,7 +93,7 @@ public partial class LandingComponentAdvisor : IDisposable { var item = TaskItems.First(x => x.TaskItemId == taskItemId); TaskItems.Remove(item); - await TaskItemRepo.DeleteTaskItem(taskItemId); + await TaskRepo.DeleteTaskItem(taskItemId); Toaster.ShowInfo("Opgaven er slettet."); } diff --git a/Wonky.Client/Features/PagingLink.cs b/Wonky.Client/Features/PagingLink.cs index a4d6c97a..240cb2d5 100644 --- a/Wonky.Client/Features/PagingLink.cs +++ b/Wonky.Client/Features/PagingLink.cs @@ -14,14 +14,34 @@ // namespace Wonky.Client.Features; - +/// +/// PagingLink class +/// public class PagingLink { + /// + /// Text + /// public string Text { get; set; } + /// + /// Page + /// public int Page { get; set; } + /// + /// Enabled + /// public bool Enabled { get; set; } + /// + /// Active + /// public bool Active { get; set; } + /// + /// The paging link + /// + /// + /// + /// public PagingLink(int page, bool enabled, string text) { Page = page; diff --git a/Wonky.Client/Features/PagingResponse.cs b/Wonky.Client/Features/PagingResponse.cs index 5cde91c4..da8245c8 100644 --- a/Wonky.Client/Features/PagingResponse.cs +++ b/Wonky.Client/Features/PagingResponse.cs @@ -18,8 +18,18 @@ using Wonky.Entity.Requests; namespace Wonky.Client.Features; +/// +/// PagingResponse T class +/// +/// public class PagingResponse where T : class { + /// + /// Items + /// public List? Items { get; set; } + /// + /// Meta DAta + /// public MetaData? MetaData { get; set; } } \ No newline at end of file diff --git a/Wonky.Client/Helpers/InputDateTime.cs b/Wonky.Client/Helpers/InputDateTime.cs index 8bf8a65c..5ae2983f 100644 --- a/Wonky.Client/Helpers/InputDateTime.cs +++ b/Wonky.Client/Helpers/InputDateTime.cs @@ -21,73 +21,99 @@ using Microsoft.AspNetCore.Components.Rendering; namespace Wonky.Client.Helpers; +/// +/// InputDateTime Component +/// +/// public class InputDateTime : InputDate { private const string DateFormat = "yyyy-MM-ddTHH:mm"; - /// - protected override void BuildRenderTree ( RenderTreeBuilder builder ) + /// + /// BuildTender + /// + /// + protected override void BuildRenderTree(RenderTreeBuilder builder) { - builder.OpenElement( 0, "input" ); - builder.AddMultipleAttributes( 1, AdditionalAttributes ); - builder.AddAttribute( 2, "type", "datetime-local" ); - builder.AddAttribute( 3, "class", CssClass ); - builder.AddAttribute( 4, "value", BindConverter.FormatValue( CurrentValueAsString ) ); - builder.AddAttribute( 5, "onchange", EventCallback.Factory.CreateBinder( this, __value => CurrentValueAsString = __value, CurrentValueAsString ) ); + builder.OpenElement(0, "input"); + builder.AddMultipleAttributes(1, AdditionalAttributes); + builder.AddAttribute(2, "type", "datetime-local"); + builder.AddAttribute(3, "class", CssClass); + builder.AddAttribute(4, "value", BindConverter.FormatValue(CurrentValueAsString)); + builder.AddAttribute(5, "onchange", + EventCallback.Factory.CreateBinder(this, __value => CurrentValueAsString = __value, + CurrentValueAsString)); builder.CloseElement(); } - /// - protected override string FormatValueAsString ( TValue value ) + /// + /// Format value as string + /// + /// + /// + protected override string FormatValueAsString(TValue value) { - switch ( value ) + return value switch { - case DateTime dateTimeValue: - return BindConverter.FormatValue( dateTimeValue, DateFormat, CultureInfo.InvariantCulture ); - case DateTimeOffset dateTimeOffsetValue: - return BindConverter.FormatValue( dateTimeOffsetValue, DateFormat, CultureInfo.InvariantCulture ); - default: - return string.Empty; // Handles null for Nullable, etc. - } + DateTime dateTimeValue => + BindConverter.FormatValue(dateTimeValue, DateFormat, CultureInfo.InvariantCulture), + DateTimeOffset dateTimeOffsetValue => BindConverter.FormatValue(dateTimeOffsetValue, DateFormat, + CultureInfo.InvariantCulture), + _ => string.Empty + }; } - /// - protected override bool TryParseValueFromString ( string value, out TValue result, out string validationErrorMessage ) + /// + /// TryParseValueFromString + /// + /// + /// + /// + /// + /// + protected override bool TryParseValueFromString(string value, out TValue result, out string validationErrorMessage) { // Unwrap nullable types. We don't have to deal with receiving empty values for nullable // types here, because the underlying InputBase already covers that. - var targetType = Nullable.GetUnderlyingType( typeof( TValue ) ) ?? typeof( TValue ); + var targetType = Nullable.GetUnderlyingType(typeof(TValue)) ?? typeof(TValue); bool success; - if ( targetType == typeof( DateTime ) ) + if (targetType == typeof(DateTime)) { - success = TryParseDateTime( value, out result ); + success = TryParseDateTime(value, out result); } - else if ( targetType == typeof( DateTimeOffset ) ) + else if (targetType == typeof(DateTimeOffset)) { - success = TryParseDateTimeOffset( value, out result ); + success = TryParseDateTimeOffset(value, out result); } else { - throw new InvalidOperationException( $"The type '{targetType}' is not a supported date type." ); + throw new InvalidOperationException($"The type '{targetType}' is not a supported date type."); } - if ( success ) + if (success) { validationErrorMessage = null; return true; } else { - validationErrorMessage = string.Format( ParsingErrorMessage, FieldIdentifier.FieldName ); + validationErrorMessage = string.Format(ParsingErrorMessage, FieldIdentifier.FieldName); return false; } } - static bool TryParseDateTime ( string value, out TValue result ) + /// + /// TrypParseDateTime + /// + /// + /// + /// + private static bool TryParseDateTime(string value, out TValue result) { - var success = BindConverter.TryConvertToDateTime( value, CultureInfo.InvariantCulture, DateFormat, out var parsedValue ); - if ( success ) + var success = + BindConverter.TryConvertToDateTime(value, CultureInfo.InvariantCulture, DateFormat, out var parsedValue); + if (success) { result = (TValue)(object)parsedValue; return true; @@ -99,10 +125,18 @@ public class InputDateTime : InputDate } } - static bool TryParseDateTimeOffset ( string value, out TValue result ) + /// + /// TryParseDateTimeOffset + /// + /// + /// + /// + private static bool TryParseDateTimeOffset(string value, out TValue result) { - var success = BindConverter.TryConvertToDateTimeOffset( value, CultureInfo.InvariantCulture, DateFormat, out var parsedValue ); - if ( success ) + var success = + BindConverter.TryConvertToDateTimeOffset(value, CultureInfo.InvariantCulture, DateFormat, + out var parsedValue); + if (success) { result = (TValue)(object)parsedValue; return true; diff --git a/Wonky.Client/Helpers/Squid.cs b/Wonky.Client/Helpers/Squid.cs index aa4a2c56..2283ec17 100644 --- a/Wonky.Client/Helpers/Squid.cs +++ b/Wonky.Client/Helpers/Squid.cs @@ -28,36 +28,79 @@ using System.Diagnostics; namespace Wonky.Client.Helpers { + /// + /// Squid is guid string shortened and url safe + /// [DebuggerDisplay("{" + nameof(Value) + "}")] public readonly struct Squid : IEquatable - { + { + /// + /// Return Empty value + /// + // ReSharper disable once MemberCanBePrivate.Global public static readonly Squid Empty = new(Guid.Empty); + + /// + /// Decode Squid to Guid + /// + /// public Squid(string value) { Value = value; Guid = DecodeSquid(value); } + + /// + /// Generate Squid from Guid object + /// + /// public Squid(Guid obj) { Value = EncodeGuid(obj); Guid = obj; } -#pragma warning disable CA1720 // Identifier contains type name + + /// + /// Guid + /// + // ReSharper disable once MemberCanBePrivate.Global public Guid Guid { get; } -#pragma warning restore CA1720 // Identifier contains type name + public string Value { get; } + + /// + /// ToString() function + /// + /// public override string ToString() { return Value; } - public override bool Equals(object obj) + + /// + /// Equality + /// + /// + /// + public override bool Equals(object? obj) { return obj is Squid other && Equals(other); } + + /// + /// EQuality + /// + /// + /// public bool Equals(Squid obj) { return Guid.Equals(obj.Guid) && Value == obj.Value; } + + /// + /// Get hashcode + /// + /// public override int GetHashCode() { unchecked @@ -65,15 +108,33 @@ namespace Wonky.Client.Helpers return (Guid.GetHashCode() * 397) ^ (Value != null ? Value.GetHashCode() : 0); } } + + /// + /// Create Squid from new Guid + /// + /// public static Squid NewGuid() { - return new(Guid.NewGuid()); + return new Squid(Guid.NewGuid()); } + + /// + /// Encode string + /// + /// + /// public static string EncodeString(string value) { var guid = new Guid(value); return EncodeGuid(guid); } + + /// + /// Encode Guid + /// + /// + /// + // ReSharper disable once MemberCanBePrivate.Global public static string EncodeGuid(Guid obj) { var encoded = Convert.ToBase64String(obj.ToByteArray()); @@ -82,25 +143,52 @@ namespace Wonky.Client.Helpers .Replace("+", "-"); return encoded.Substring(0, 22); } + + /// + /// Decode Squid + /// + /// + /// + // ReSharper disable once MemberCanBePrivate.Global public static Guid DecodeSquid(string value) { - if (value == null) return Empty; + if (!value.Any()) return Empty; value = value .Replace("_", "/") .Replace("-", "+"); var blob = Convert.FromBase64String(value + "=="); return new Guid(blob); } + + /// + /// Guid From Squid + /// + /// + /// public static Guid FromSquid(Squid obj) { return obj.Guid; } + + /// + /// Squid From String + /// + /// + /// public static Squid FromString(string value) { if (string.IsNullOrEmpty(value)) return Empty; return TryParse(value, out Squid obj) ? obj : Empty; } + + /// + /// TryDecode + /// + /// + /// + /// + // ReSharper disable once MemberCanBePrivate.Global public static bool TryDecode(string value, out Guid obj) { try @@ -109,15 +197,21 @@ namespace Wonky.Client.Helpers obj = DecodeSquid(value); return true; } -#pragma warning disable CA1031 // Do not catch general exception types catch (Exception) -#pragma warning restore CA1031 // Do not catch general exception types { // Return empty Guid obj = Guid.Empty; return false; } } + + /// + /// TryParse + /// + /// + /// + /// + // ReSharper disable once MemberCanBePrivate.Global public static bool TryParse(string value, out Squid obj) { // Parse as Squid string. @@ -126,15 +220,24 @@ namespace Wonky.Client.Helpers obj = oGuid; return true; } + // Parse as Guid string. if (Guid.TryParse(value, out oGuid)) { obj = oGuid; return true; } + obj = Empty; return false; } + + /// + /// TryParse + /// + /// + /// + /// public static bool TryParse(string value, out Guid obj) { // Try a Squid string. @@ -146,38 +249,98 @@ namespace Wonky.Client.Helpers obj = Guid.Empty; return false; } + + /// + /// Operator + /// + /// + /// + /// public static bool operator ==(Squid x, Squid y) { return x.Guid == y.Guid; } + + /// + /// Operator + /// + /// + /// + /// public static bool operator ==(Squid x, Guid y) { return x.Guid == y; } + + /// + /// Operator + /// + /// + /// + /// public static bool operator ==(Guid x, Squid y) { return y == x; // NB: order of arguments } + + /// + /// Operator + /// + /// + /// + /// public static bool operator !=(Squid x, Squid y) { return !(x == y); } + + /// + /// Operator + /// + /// + /// + /// public static bool operator !=(Squid x, Guid y) { return !(x == y); } + + /// + /// Operator + /// + /// + /// + /// public static bool operator !=(Guid x, Squid y) { return !(x == y); } + + /// + /// Operator + /// + /// + /// public static implicit operator string(Squid oSquid) { return oSquid.Value; } + + /// + /// Operator + /// + /// + /// public static implicit operator Guid(Squid oSquid) { return oSquid.Guid; } + + /// + /// Operator + /// + /// + /// public static implicit operator Squid(string value) { if (string.IsNullOrEmpty(value)) @@ -185,6 +348,12 @@ namespace Wonky.Client.Helpers return TryParse(value, out Squid oSquid) ? oSquid : Empty; } + + /// + /// Operator + /// + /// + /// public static implicit operator Squid(Guid oGuid) { return oGuid == Guid.Empty ? Empty : new Squid(oGuid); diff --git a/Wonky.Client/Helpers/StringExtensions.cs b/Wonky.Client/Helpers/StringExtensions.cs index e9168eda..51a5c3a4 100644 --- a/Wonky.Client/Helpers/StringExtensions.cs +++ b/Wonky.Client/Helpers/StringExtensions.cs @@ -17,7 +17,13 @@ namespace Wonky.Client.Helpers; public static class StringExtensions { - public static string Left(this string value, int maxLength) + /// + /// Left Pad a string with spaces until maxlength + /// + /// + /// + /// + public static string PadLeft(this string value, int maxLength) { if (string.IsNullOrEmpty(value)) return value; maxLength = Math.Abs(maxLength); diff --git a/Wonky.Client/Helpers/Utils.cs b/Wonky.Client/Helpers/Utils.cs index 75c75119..82da8565 100644 --- a/Wonky.Client/Helpers/Utils.cs +++ b/Wonky.Client/Helpers/Utils.cs @@ -21,60 +21,95 @@ namespace Wonky.Client.Helpers; public static class Utils { + /// + /// Helper to parse querystring + /// + /// + /// public static Dictionary ParseQuery(string query) { if (string.IsNullOrWhiteSpace(query) || query.Contains("://")) return new Dictionary(); - + // remove the question mark + query = query.Replace("?", ""); + // split into pairs var elements = query.Split("&"); - + // return elements as list return elements.Select( - data - => data.Split("=")) + data + => data.Split("=")) .ToDictionary(element => element[0], element => element[1]); } - + + /// + /// Validate email format + /// + /// + /// public static bool IsValidEmail(string email) { var trimmedEmail = email.Trim(); - if (trimmedEmail.EndsWith(".")) { + if (trimmedEmail.EndsWith(".")) + { return false; // suggested by @TK-421 } - try { + + try + { var addr = new MailAddress(email); return addr.Address == trimmedEmail; } - catch { + catch + { return false; } } - + + /// + /// return enum as the string value + /// + /// + /// public static string EnumToString(Enum value) { return value.ToString(); } - + + /// + /// Generate unique hashcode from time + /// + /// public static int GetHashFromNow() { return DateTime.Now.ToFileTimeUtc().GetHashCode(); } + /// + /// Get visit state as colored icon + /// + /// + /// public static string GetVisitState(string dtNextVisit) { if (dtNextVisit is "0001-01-01" or "1970-01-01") return "the-draw"; if (!DateTime.TryParse(dtNextVisit, out _)) return "the-draw"; - + var dtNow = DateTime.Now; var dtNext = DateTime.Parse(dtNextVisit); if (dtNow > dtNext) return "the-ugly"; - + return dtNow > dtNext.AddDays(-14) ? "the-bad" : "the-good"; } - + + /// + /// Translate process status to icon + /// + /// + /// public static string GetProcessStatus(string processStatus) { return processStatus.ToLower() switch @@ -86,5 +121,5 @@ public static class Utils "shipped" => "the-dead", _ => "question-square" }; - } + } } \ No newline at end of file diff --git a/Wonky.Client/Helpers/VatUtils.cs b/Wonky.Client/Helpers/VatUtils.cs index 83f77e9b..c2e05e51 100644 --- a/Wonky.Client/Helpers/VatUtils.cs +++ b/Wonky.Client/Helpers/VatUtils.cs @@ -21,14 +21,19 @@ public class VatUtils { // https://ec.europa.eu/taxation_customs/vies/faqvies.do#item_11 // https://ec.europa.eu/taxation_customs/vies/ - + /// + /// Entrypoint for validating vat number + /// + /// + /// + /// public static bool ValidateFormat(string countryCode, string vatNumber) { if (string.IsNullOrWhiteSpace(vatNumber) || string.IsNullOrWhiteSpace(countryCode) || !IsDigitsOnly(vatNumber)) return false; - + var sanitisedVat = SanitizeVatNumber(vatNumber); - + return countryCode.ToUpperInvariant() switch { "DK" => ValidateFormatDk(sanitisedVat), @@ -38,10 +43,21 @@ public class VatUtils }; } + /// + /// Validate string is only numbers + /// + /// + /// private static bool IsDigitsOnly(string check) { return check.All(c => c is >= '0' and <= '9'); } + + /// + /// Validate Danish Vat number format + /// + /// + /// private static bool ValidateFormatDk(string vatNumber) { // https://wiki.scn.sap.com/wiki/display/CRM/Denmark @@ -57,6 +73,11 @@ public class VatUtils return ValidateMod11(vatNumber); } + /// + /// Validate Norwegian Vat number format + /// + /// + /// private static bool ValidateFormatNo(string vatNumber) { // https://wiki.scn.sap.com/wiki/display/CRM/Norway @@ -69,6 +90,11 @@ public class VatUtils return long.Parse(vatNumber) != 0 && ValidateMod11(vatNumber); } + /// + /// Validate Swedish Vat number format + /// + /// + /// private static bool ValidateFormatSe(string vatNumber) { // https://wiki.scn.sap.com/wiki/display/CRM/Sweden @@ -81,7 +107,7 @@ public class VatUtils var vatToCheck = vatNumber; if (vatToCheck.Length < 10 || long.Parse(vatToCheck) == 0) return false; - + var r = new[] { 0, 2, 4, 6, 8 } .Sum(m => (int)char.GetNumericValue(vatToCheck[m]) / 5 + (int)char.GetNumericValue(vatToCheck[m]) * 2 % 10); @@ -89,11 +115,17 @@ public class VatUtils var c10 = (10 - (r + c1) % 10) % 10; if (vatToCheck.Length == 10) { - return $"{vatToCheck[..9]}{c10}" == vatNumber; + return $"{vatToCheck[..9]}{c10}" == vatNumber; } + return $"{vatToCheck[..9]}{c10}01" == vatNumber; } - + + /// + /// Modulus11 validator + /// + /// + /// private static bool ValidateMod11(string number) { if (long.Parse(number) == 0) @@ -108,14 +140,18 @@ public class VatUtils return sum % 11 == 0; } + /// + /// Sanitize Vat number to it's raw numbers + /// + /// + /// private static string SanitizeVatNumber(string vatNumber) { - return vatNumber.ToUpperInvariant() - .Replace(" ", "") + return vatNumber.Replace(" ", "") .Replace("-", "") .Replace("DK", "") .Replace("NO", "") - .Replace("SE","") + .Replace("SE", "") .Replace("MVA", ""); } } \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/ICrmActivityHttpRepository.cs b/Wonky.Client/HttpInterfaces/IActivityCrmHttpRepository.cs similarity index 95% rename from Wonky.Client/HttpInterfaces/ICrmActivityHttpRepository.cs rename to Wonky.Client/HttpInterfaces/IActivityCrmHttpRepository.cs index dbab34d8..4dcd1fc4 100644 --- a/Wonky.Client/HttpInterfaces/ICrmActivityHttpRepository.cs +++ b/Wonky.Client/HttpInterfaces/IActivityCrmHttpRepository.cs @@ -18,7 +18,10 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpInterfaces; -public interface ICrmActivityHttpRepository +/// +/// Interface Activity CRM Http repository +/// +public interface IActivityCrmHttpRepository { /// /// Get a list of open quotes @@ -33,13 +36,6 @@ public interface ICrmActivityHttpRepository /// Task UpdateQuoteStatus(ReportItemView activity); - /// - /// Get activities by date - /// - /// - /// - Task GetActivities(string activityDate); - /// /// Create new activity /// @@ -47,12 +43,26 @@ public interface ICrmActivityHttpRepository /// Task CreateActivity(ActivityDto model); + /// + /// Get activities by date + /// + /// + /// + Task GetActivities(string activityDate); + /// /// Get activity data by id /// /// /// Task GetActivity(string activityId); + + /// + /// Get activities for customer Id + /// + /// + /// + Task> GetCustomerActivities(string customerId); /// /// Get activity by id formatted for report @@ -61,20 +71,13 @@ public interface ICrmActivityHttpRepository /// Task GetReportItem(string activityId); - /// - /// Get activities for customer Id - /// - /// - /// - Task> GetCustomerActivities(string customerId); - /// /// Set backend process state to express /// /// /// ApiResponseView Task GetExpressState(string activityId); - + /// /// Update office note for activity /// diff --git a/Wonky.Client/HttpInterfaces/ICatalogHttpRepository.cs b/Wonky.Client/HttpInterfaces/ICatalogHttpRepository.cs index 3b07d212..68770aa9 100644 --- a/Wonky.Client/HttpInterfaces/ICatalogHttpRepository.cs +++ b/Wonky.Client/HttpInterfaces/ICatalogHttpRepository.cs @@ -19,7 +19,10 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpInterfaces; -public interface ICatalogHttpRepository +/// +/// Interface Catalog Http repository +/// +public interface ICatalogCrmHttpRepository { /// /// Get a paged sales item list @@ -28,6 +31,14 @@ public interface ICatalogHttpRepository /// Task> GetSalesItemsPaged(CatalogPagingParams pagingParameters); + /// + /// Get a paged sales item list for country + /// + /// + /// + /// + Task> GetSalesItemsPaged(CatalogPagingParams pagingParameters, string countryCode); + /// /// Get sales item by id /// @@ -43,7 +54,7 @@ public interface ICatalogHttpRepository Task GetSalesItemSku(string sku); /// - /// Overload Get sales item by id and country code + /// Overload Get sales item by sku and country code /// /// /// @@ -57,5 +68,16 @@ public interface ICatalogHttpRepository /// Task GetSalesVariantId(string variantId); + /// + /// Complete catalog for print + /// + /// Task> GetPriceList(); + + /// + /// Complete catalog for print country + /// + /// + /// + Task> GetPriceList(string countryCode); } \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/IContactCrmHttpRepository.cs b/Wonky.Client/HttpInterfaces/IContactCrmHttpRepository.cs new file mode 100644 index 00000000..633723fa --- /dev/null +++ b/Wonky.Client/HttpInterfaces/IContactCrmHttpRepository.cs @@ -0,0 +1,47 @@ +using Wonky.Entity.DTO; + +namespace Wonky.Client.HttpInterfaces; + +/// +/// Interface for Contacts CRM Http repository +/// +/// +public interface IContactCrmHttpRepository +{ + /// + /// Create Contact + /// + /// + /// + Task CreateContact(ContactDto model); + + /// + /// Get Contact + /// + /// + /// + /// + Task GetContact(string companyId, string contactId); + + /// + /// Get Contacts + /// + /// + /// + Task> GetContacts(string companyId); + + /// + /// Delete Contact + /// + /// + /// + /// + Task DeleteContact(string companyId, string contactId); + + /// + /// Update Contact + /// + /// + /// + Task UpdateContact(ContactDto model); +} \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/ICrmContactHttpRepository.cs b/Wonky.Client/HttpInterfaces/ICrmContactHttpRepository.cs deleted file mode 100644 index 685b999f..00000000 --- a/Wonky.Client/HttpInterfaces/ICrmContactHttpRepository.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Wonky.Entity.DTO; - -namespace Wonky.Client.HttpInterfaces; - -public interface ICrmContactHttpRepository -{ - Task CreateContact(ContactDto model); - Task GetContact(string companyId, string contactId); - Task> GetContacts(string companyId); - Task DeleteContact(string companyId, string contactId); - Task UpdateContact(ContactDto model); -} \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/ICrmReportHttpRepository.cs b/Wonky.Client/HttpInterfaces/ICrmReportHttpRepository.cs deleted file mode 100644 index d6211053..00000000 --- a/Wonky.Client/HttpInterfaces/ICrmReportHttpRepository.cs +++ /dev/null @@ -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 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.HttpInterfaces; - -public interface ICrmReportHttpRepository -{ - Task ReportExist(string workDate); - Task> GetReports(); - Task GetReport(string workDate); - Task InitializeReportData(string workDate); - Task PostReport(string workDate, ReportDto reportDto); -} \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/ICrmTaskItemHttpRepository.cs b/Wonky.Client/HttpInterfaces/ICrmTaskItemHttpRepository.cs deleted file mode 100644 index 3a15fb3c..00000000 --- a/Wonky.Client/HttpInterfaces/ICrmTaskItemHttpRepository.cs +++ /dev/null @@ -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 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; - -namespace Wonky.Client.HttpInterfaces; - -public interface ICrmTaskItemHttpRepository -{ - Task?> GetTaskList(); - Task?> GetTaskList(string workDate); - Task GetTaskItem(string taskItemId); - Task CreateTaskItem(TaskItemDto taskItem); - Task UpdateTaskItem(string taskItemId, TaskItemDto taskItem); - Task DeleteTaskItem(string taskItemId); -} \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/ICrmCompanyHttpRepository.cs b/Wonky.Client/HttpInterfaces/ICustomerCrmHttpRepository.cs similarity index 81% rename from Wonky.Client/HttpInterfaces/ICrmCompanyHttpRepository.cs rename to Wonky.Client/HttpInterfaces/ICustomerCrmHttpRepository.cs index 4c90faab..e5bd56b7 100644 --- a/Wonky.Client/HttpInterfaces/ICrmCompanyHttpRepository.cs +++ b/Wonky.Client/HttpInterfaces/ICustomerCrmHttpRepository.cs @@ -19,48 +19,57 @@ using Wonky.Entity.Requests; namespace Wonky.Client.HttpInterfaces; -public interface ICrmCompanyHttpRepository +/// +/// Interface Customer CRM Http repository +/// +public interface ICustomerCrmHttpRepository { /// - /// Get a list of CRM entities + /// Get a list of CRM customers (SalesRep) /// /// /// A paged response defined by pagingParameters - Task> GetCompanies(CompanyPagingParams pagingParameters); + Task> GetCompanies(CustomerPaging pagingParameters); + /// - /// Get CRM entity by Id + /// Get CRM customer by Id (SalesRep) /// /// /// A CRM Company entity Task GetCompanyById(string companyId); + /// - /// Create new CRM entity + /// Create Customer (SalesRep) /// /// /// The Id of the entity Task CreateCompany(CompanyDto model); + /// - /// Delete the CRM entity + /// Delete the CRM customer (SalesRep) /// /// /// true/false to define success Task DeleteCompany(string companyId); + /// - /// Update CRM entity properties + /// Update CRM customer properties (SalesRep) /// /// /// /// A CRM Company entity Task UpdateCrmData(string companyId, CompanyDto model); + /// - /// Update ERP entity properties + /// Update ERP customer properties (SalesRep) /// /// /// /// A CRM Company entity Task UpdateErpData(string companyId, CompanyDto model); + /// - /// Update Entity Vat Number + /// Update customer Vat Number (SalesRep) /// /// /// diff --git a/Wonky.Client/HttpInterfaces/ICustomerHistoryCrmHttpRepository.cs b/Wonky.Client/HttpInterfaces/ICustomerHistoryCrmHttpRepository.cs new file mode 100644 index 00000000..360812d2 --- /dev/null +++ b/Wonky.Client/HttpInterfaces/ICustomerHistoryCrmHttpRepository.cs @@ -0,0 +1,70 @@ +// 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.HttpInterfaces; + +/// +/// Interface Customer History CRM Http repository +/// +public interface ICustomerHistoryCrmHttpRepository +{ + /// + /// Fetch Invoice LIst + /// + /// + /// + Task FetchInvoiceList(string companyId); + + /// + /// Fetch given invoice for given customer + /// + /// + /// + /// + Task FetchInvoice(string companyId, string invoiceId); + + /// + /// Fetch inventory from given customer + /// + /// + /// + Task> FetchInventory(string companyId); + + /// + /// Fetch History for given customer + /// + /// + /// + Task> FetchHistory(string companyId); + + /// + /// Fetch history for given customer and a given product + /// + /// + /// + /// + Task> FetchHistory(string companyId, string sku); + + /// + /// RPC call to initiate remote server sync for given customer + /// + /// + /// + /// + Task ErpInvoiceToCrmRpc(string companyId, string syncDate); +} \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/ICustomerOfficeHttpRepository.cs b/Wonky.Client/HttpInterfaces/ICustomerOfficeHttpRepository.cs new file mode 100644 index 00000000..c5cffab2 --- /dev/null +++ b/Wonky.Client/HttpInterfaces/ICustomerOfficeHttpRepository.cs @@ -0,0 +1,57 @@ +// 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.Features; +using Wonky.Entity.DTO; +using Wonky.Entity.Requests; + +namespace Wonky.Client.HttpInterfaces; + +/// +/// Interface for Customer Office Http repository +/// +public interface ICustomerOfficeHttpRepository +{ + /// + /// Get customers paged for given country + /// + /// + /// + /// + Task> GetCompaniesPaged(CustomerPaging pagingParameters, string countryCode); + + /// + /// Get customers paged for given sales rep + /// + /// + /// + /// + Task> GetCompaniesPagedSalesRep(string salesRepId, CustomerPaging pagingParameters); + + /// + /// Get customer by Id + /// + /// + /// + Task GetByCustomerId(string companyId); + + /// + /// Update Company data + /// + /// + /// + /// + Task UpdateCompany(string companyId, CompanyDto model); +} \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/IOfficeCustomerHttpRepository.cs b/Wonky.Client/HttpInterfaces/IOfficeCustomerHttpRepository.cs deleted file mode 100644 index 746c2308..00000000 --- a/Wonky.Client/HttpInterfaces/IOfficeCustomerHttpRepository.cs +++ /dev/null @@ -1,27 +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.Client.Features; -using Wonky.Entity.DTO; -using Wonky.Entity.Requests; - -namespace Wonky.Client.HttpInterfaces; - -public interface IOfficeCustomerHttpRepository -{ - Task> GetCompaniesPaged(CompanyPagingParams pagingParameters); - Task> GetCompaniesPagedSalesRep(string salesRepId, CompanyPagingParams pagingParameters); - Task GetByCustomerId(string companyId); -} \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/IReportHttpRepository.cs b/Wonky.Client/HttpInterfaces/IReportHttpRepository.cs new file mode 100644 index 00000000..f6cfa923 --- /dev/null +++ b/Wonky.Client/HttpInterfaces/IReportHttpRepository.cs @@ -0,0 +1,75 @@ +// 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.HttpInterfaces; + +/// +/// Interface Report Http repository +/// +public interface IReportHttpRepository +{ + /// + /// Report Exist for given data (SalesRep) + /// + /// + /// + Task ReportExist(string workDate); + + /// + /// Get Reports for (SalesRep) + /// + /// + Task> GetReports(); + + /// + /// Get Report for given date (SalesRep) + /// + /// + /// + Task GetReport(string workDate); + + /// + /// Initialize Report for given data (SalesRep) + /// + /// + /// + Task InitializeReportData(string workDate); + + /// + /// Create Report for given data - using reportData + /// + /// + /// + /// + Task CreateReport(string workDate, ReportDto reportDto); + + /// + /// Get Reports for given userId (Office) + /// + /// + /// + Task> GetCountryReports(string userId); + + /// + /// Get Report for given userId and workDate (Office) + /// + /// + /// + /// + Task GetCountryReport(string userId, string workDate); +} \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/ICrmHistoryHttpRepository.cs b/Wonky.Client/HttpInterfaces/IReportOfficeHttpRepository.cs similarity index 56% rename from Wonky.Client/HttpInterfaces/ICrmHistoryHttpRepository.cs rename to Wonky.Client/HttpInterfaces/IReportOfficeHttpRepository.cs index fc83c7c7..a70d909e 100644 --- a/Wonky.Client/HttpInterfaces/ICrmHistoryHttpRepository.cs +++ b/Wonky.Client/HttpInterfaces/IReportOfficeHttpRepository.cs @@ -18,12 +18,24 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpInterfaces; -public interface ICrmHistoryHttpRepository +/// +/// Interface for Report http repository +/// +/// Possibly duplicated in IReportHttpRepository +public interface IReportOfficeHttpRepository { - Task FetchInvoiceList(string companyId); - Task FetchInvoice(string companyId, string invoiceId); - Task> FetchInventory(string companyId); - Task> FetchHistory(string companyId); - Task> FetchHistory(string companyId, string sku); - Task ErpInvoiceToCrmRpc(string companyId, string syncDate); + /// + /// Get reports for given userId + /// + /// + /// + Task> GetReports(string userId); + + /// + /// Get report for given userId and workDate + /// + /// + /// + /// + Task GetReport(string userId, string workDate); } \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/ISendMailService.cs b/Wonky.Client/HttpInterfaces/ISendMailService.cs index 14d5d163..719f150a 100644 --- a/Wonky.Client/HttpInterfaces/ISendMailService.cs +++ b/Wonky.Client/HttpInterfaces/ISendMailService.cs @@ -3,7 +3,16 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpInterfaces; +/// +/// Interface for sending emai +/// public interface ISendMailService { + /// + /// Send Mail + /// + /// + /// + /// Task SendMail(string messageType, EmailMessage message); } \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/ITaskItemCrmHttpRepository.cs b/Wonky.Client/HttpInterfaces/ITaskItemCrmHttpRepository.cs new file mode 100644 index 00000000..d881f124 --- /dev/null +++ b/Wonky.Client/HttpInterfaces/ITaskItemCrmHttpRepository.cs @@ -0,0 +1,66 @@ +// 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; + +namespace Wonky.Client.HttpInterfaces; + +/// +/// Interface for handling CRM Tasks http repository +/// +public interface ITaskItemCrmHttpRepository +{ + /// + /// Get Task List (SalesRep) + /// + /// + Task> GetTaskList(); + + /// + /// Get Task List for given workDate (SalesRep) + /// + /// + /// + Task> GetTaskList(string workDate); + + /// + /// Get Task Item by id (SalesRep) + /// + /// + /// + Task GetTaskItem(string taskItemId); + + /// + /// Create task using taskItem (SalesRep) + /// + /// + /// + Task CreateTaskItem(TaskItemDto taskItem); + + /// + /// Delete Task Item (SalesRep + /// + /// + /// + Task UpdateTaskItem(string taskItemId, TaskItemDto taskItem); + + /// + /// Delete Task Item (SalesRep + /// + /// + /// + Task DeleteTaskItem(string taskItemId); +} \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/IUserHttpRepository.cs b/Wonky.Client/HttpInterfaces/IUserHttpRepository.cs index 08f17f94..fcb5223d 100644 --- a/Wonky.Client/HttpInterfaces/IUserHttpRepository.cs +++ b/Wonky.Client/HttpInterfaces/IUserHttpRepository.cs @@ -18,13 +18,59 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpInterfaces; +/// +/// Interface for User handling over http +/// public interface IUserHttpRepository { + /// + /// Get Advisors (Office) + /// + /// Task> GetAdvisors(); + + /// + /// Get Advisor Info for given userId + /// + /// + /// Task GetAdvisorInfo(string userId); + + /// + /// Update Advisor using userId and updated data + /// + /// + /// + /// Task UpdateAdvisor(string userId, UserUpdateDto model); + + /// + /// Get Administrative Users + /// + /// Task> GetAdminUsers(); + + /// + /// Get Admin Info for giver userId + /// + /// + /// Task GetAdminUserInfo(string userId); + + /// + /// Update Admin user using userId and updated data + /// + /// + /// + /// Task UpdateAdminUser(string userId, UserUpdateDto model); + + /// + /// Set new user password + /// + /// + /// + /// + /// Task ResetUserPassword(string userId, string newPasswd, string confirmPasswd); } \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/IWarehouseHttpRepository.cs b/Wonky.Client/HttpInterfaces/IWarehouseHttpRepository.cs index afa8842b..d03b9255 100644 --- a/Wonky.Client/HttpInterfaces/IWarehouseHttpRepository.cs +++ b/Wonky.Client/HttpInterfaces/IWarehouseHttpRepository.cs @@ -17,9 +17,37 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpInterfaces; +/// +/// Interface for processing orders in warehouse +/// public interface IWarehouseHttpRepository { + /// + /// Get warehouse order list by date + /// + /// + /// + Task> GetWarehouseOrderListByDate(string date); + + /// + /// Get orders by status + /// + /// + /// + /// Task> GetWarehouseOrderListByStatus(string status, string express = ""); + + /// + /// Get order with orderId + /// + /// + /// Task GetWarehouseOrder(string orderId); + + /// + /// Update Order status setting new process status + /// + /// + /// Task UpdateWarehouseOrderStatus(WarehouseProcess process); } \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/ICrmWorkplaceHttpRepository.cs b/Wonky.Client/HttpInterfaces/IWorkplaceCrmHttpRepository.cs similarity index 51% rename from Wonky.Client/HttpInterfaces/ICrmWorkplaceHttpRepository.cs rename to Wonky.Client/HttpInterfaces/IWorkplaceCrmHttpRepository.cs index 740c3a01..21de0e06 100644 --- a/Wonky.Client/HttpInterfaces/ICrmWorkplaceHttpRepository.cs +++ b/Wonky.Client/HttpInterfaces/IWorkplaceCrmHttpRepository.cs @@ -18,11 +18,47 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpInterfaces; -public interface ICrmWorkplaceHttpRepository +/// +/// Interface for handling Customer Workplaces (chemical document service) +/// +public interface IWorkplaceCrmHttpRepository { + /// + /// Get Workplaces for given customer id + /// + /// + /// Task> GetWorkplaces(string companyId); + + /// + /// Get specific workplace using customer id and workplace id + /// + /// + /// + /// Task GetWorkplace(string companyId, string workplaceId); + + /// + /// Create new workplace given the customer id and workplace data + /// + /// + /// + /// Task CreateWorkplace(string companyId, WorkplaceDto workplace); + + /// + /// Update workplace given the customer id and updated data + /// + /// + /// + /// Task UpdateWorkplace(string companyId, WorkplaceDto workplace); + + /// + /// Delete workplace given customer id and workplace id + /// + /// + /// + /// Task DeleteWorkplace(string companyId, string workplaceId); } \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/CrmActivityHttpRepository.cs b/Wonky.Client/HttpRepository/ActivityCrmHttpRepository.cs similarity index 92% rename from Wonky.Client/HttpRepository/CrmActivityHttpRepository.cs rename to Wonky.Client/HttpRepository/ActivityCrmHttpRepository.cs index 2e1d877b..4e167378 100644 --- a/Wonky.Client/HttpRepository/CrmActivityHttpRepository.cs +++ b/Wonky.Client/HttpRepository/ActivityCrmHttpRepository.cs @@ -25,7 +25,10 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpRepository; -public class CrmActivityHttpRepository : ICrmActivityHttpRepository +/// +/// Implementing Interface Activity CRM Http repository +/// +public class ActivityCrmHttpRepository : IActivityCrmHttpRepository { private readonly JsonSerializerOptions? _options = new JsonSerializerOptions { @@ -33,12 +36,12 @@ public class CrmActivityHttpRepository : ICrmActivityHttpRepository }; private readonly NavigationManager _navigation; - private ILogger _logger; + private ILogger _logger; private readonly HttpClient _client; private readonly ApiConfig _api; - public CrmActivityHttpRepository(HttpClient client, - ILogger logger, + public ActivityCrmHttpRepository(HttpClient client, + ILogger logger, NavigationManager navigation, IOptions configuration) { _client = client; @@ -48,9 +51,9 @@ public class CrmActivityHttpRepository : ICrmActivityHttpRepository } /// - /// Get a list of quotes + /// Get a list of open quotes /// - /// List of activities with Quote status + /// List of Activities with ActivityStatus == Quote public async Task> GetQuotes() { return await _client.GetFromJsonAsync>($"{_api.CrmActivities}/quotes", _options); @@ -63,7 +66,7 @@ public class CrmActivityHttpRepository : ICrmActivityHttpRepository /// public async Task UpdateQuoteStatus(ReportItemView activity) { - var response = await _client.PutAsJsonAsync( + var response = await _client.PutAsJsonAsync( $"{_api.CrmActivities}/quote/{activity.ActivityId}", activity, _options); var content = await response.Content.ReadAsStringAsync(); _logger.LogDebug("UpdateQuote Response Content <= {}", content); diff --git a/Wonky.Client/HttpRepository/CatalogHttpRepository.cs b/Wonky.Client/HttpRepository/CatalogHttpRepository.cs index 3ad86041..5c476c28 100644 --- a/Wonky.Client/HttpRepository/CatalogHttpRepository.cs +++ b/Wonky.Client/HttpRepository/CatalogHttpRepository.cs @@ -31,7 +31,7 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpRepository; -public class CatalogHttpRepository : ICatalogHttpRepository +public class CatalogCrmHttpRepository : ICatalogCrmHttpRepository { private readonly JsonSerializerOptions _options = new JsonSerializerOptions { @@ -39,12 +39,12 @@ public class CatalogHttpRepository : ICatalogHttpRepository }; private readonly NavigationManager _navigation; - private ILogger _logger; + private ILogger _logger; private readonly HttpClient _client; private readonly ApiConfig _apiConfig; - public CatalogHttpRepository(HttpClient client, - ILogger logger, + public CatalogCrmHttpRepository(HttpClient client, + ILogger logger, NavigationManager navigation, IOptions configuration) { _client = client; @@ -91,6 +91,45 @@ public class CatalogHttpRepository : ICatalogHttpRepository return pagingResponse; } + /// + /// Get a paged sales item list for country + /// + /// + /// + /// + public async Task> GetSalesItemsPaged(CatalogPagingParams pagingParameters, string countryCode) + { + var queryString = new Dictionary + { + ["pageNumber"] = pagingParameters.PageNumber.ToString(), + ["pageSize"] = pagingParameters.PageSize.ToString(), + ["orderBy"] = pagingParameters.OrderBy, + ["searchColumn"] = pagingParameters.SearchColumn, + ["searchTerm"] = pagingParameters.SearchTerm, + ["selectGroup"] = pagingParameters.SelectGroup == "0" ? "" : pagingParameters.SelectGroup, + }; + var response = await _client + .GetAsync(QueryHelpers.AddQueryString($"{_apiConfig.Catalog}/{countryCode}/page", queryString)); + + if (!response.IsSuccessStatusCode) + { + return new PagingResponse + { + Items = new List(), + MetaData = new MetaData() + }; + } + var content = await response.Content.ReadAsStringAsync(); + + var pagingResponse = new PagingResponse + { + Items = JsonSerializer.Deserialize>(content, _options), + MetaData = JsonSerializer.Deserialize( + response.Headers.GetValues("X-Pagination").First(), _options) + }; + return pagingResponse; + } + /// /// Get sales item by id /// @@ -115,7 +154,7 @@ public class CatalogHttpRepository : ICatalogHttpRepository } /// - /// Overload Get sales item by id and country code + /// Overload Get sales item by sku and country code /// /// /// @@ -137,9 +176,24 @@ public class CatalogHttpRepository : ICatalogHttpRepository .GetFromJsonAsync($"{_apiConfig.Catalog}/variant/{variantId}"); return salesItem ?? new SalesItemView(); } - + + /// + /// Complete catalog for print + /// + /// public async Task> GetPriceList() { return await _client.GetFromJsonAsync>($"{_apiConfig.Catalog}", _options); } + + /// + /// Complete catalog for print country + /// + /// + /// + public async Task> GetPriceList(string countryCode) + { + return await _client.GetFromJsonAsync>($"{_apiConfig.Catalog}/{countryCode}", _options); + } + } \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/CrmContactHttpRepository.cs b/Wonky.Client/HttpRepository/ContactCrmHttpRepository.cs similarity index 71% rename from Wonky.Client/HttpRepository/CrmContactHttpRepository.cs rename to Wonky.Client/HttpRepository/ContactCrmHttpRepository.cs index 83e93730..285c6c1c 100644 --- a/Wonky.Client/HttpRepository/CrmContactHttpRepository.cs +++ b/Wonky.Client/HttpRepository/ContactCrmHttpRepository.cs @@ -8,7 +8,7 @@ using Wonky.Entity.DTO; namespace Wonky.Client.HttpRepository; -public class CrmContactHttpRepository : ICrmContactHttpRepository +public class ContactCrmHttpRepository : IContactCrmHttpRepository { private readonly JsonSerializerOptions _options = new () { @@ -16,12 +16,12 @@ public class CrmContactHttpRepository : ICrmContactHttpRepository }; private readonly NavigationManager _navigation; - private ILogger _logger; + private ILogger _logger; private readonly HttpClient _client; private readonly ApiConfig _conf; - public CrmContactHttpRepository(HttpClient client, - ILogger logger, + public ContactCrmHttpRepository(HttpClient client, + ILogger logger, NavigationManager navigation, IOptions apiConfig) { @@ -32,9 +32,10 @@ public class CrmContactHttpRepository : ICrmContactHttpRepository } /// - /// Create contact + /// Create Contact /// /// + /// public async Task CreateContact(ContactDto model) { var response = await _client.PostAsJsonAsync( @@ -42,13 +43,23 @@ public class CrmContactHttpRepository : ICrmContactHttpRepository return await response.Content.ReadAsStringAsync(); } - + /// + /// Get Contact + /// + /// + /// + /// public async Task GetContact(string companyId, string contactId) { return await _client.GetFromJsonAsync( $"{_conf.CrmCustomers}/{companyId}/contacts/{contactId}"); } + /// + /// Get Contacts + /// + /// + /// public async Task> GetContacts(string companyId) { var response = await _client.GetAsync( @@ -58,13 +69,23 @@ public class CrmContactHttpRepository : ICrmContactHttpRepository ? new List() : JsonSerializer.Deserialize>(content, _options); } - + /// + /// Delete Contact + /// + /// + /// + /// public async Task DeleteContact(string companyId, string contactId) { await _client.DeleteAsync( $"{_conf.CrmCustomers}/{companyId}/contacts/{contactId}"); } + /// + /// Update Contact + /// + /// + /// public async Task UpdateContact(ContactDto model) { await _client.PutAsJsonAsync( diff --git a/Wonky.Client/HttpRepository/CrmCompanyHttpRepository.cs b/Wonky.Client/HttpRepository/CustomerCrmHttpRepository.cs similarity index 85% rename from Wonky.Client/HttpRepository/CrmCompanyHttpRepository.cs rename to Wonky.Client/HttpRepository/CustomerCrmHttpRepository.cs index 73054895..9161989c 100644 --- a/Wonky.Client/HttpRepository/CrmCompanyHttpRepository.cs +++ b/Wonky.Client/HttpRepository/CustomerCrmHttpRepository.cs @@ -34,7 +34,7 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpRepository; -public class CrmCompanyHttpRepository : ICrmCompanyHttpRepository +public class CustomerCrmCrmHttpRepository : ICustomerCrmHttpRepository { private readonly JsonSerializerOptions _options = new () { @@ -42,12 +42,12 @@ public class CrmCompanyHttpRepository : ICrmCompanyHttpRepository }; private readonly NavigationManager _navigation; - private ILogger _logger; + private ILogger _logger; private readonly HttpClient _client; private readonly ApiConfig _conf; - public CrmCompanyHttpRepository(HttpClient client, - ILogger logger, + public CustomerCrmCrmHttpRepository(HttpClient client, + ILogger logger, NavigationManager navigation, IOptions apiConfig) { @@ -58,11 +58,11 @@ public class CrmCompanyHttpRepository : ICrmCompanyHttpRepository } /// - /// Get from crm endpoint + /// Get a list of CRM customers (SalesRep) /// /// - /// Paged response - public async Task> GetCompanies(CompanyPagingParams pagingParameters) + /// A paged response defined by pagingParameters + public async Task> GetCompanies(CustomerPaging pagingParameters) { var queryString = new Dictionary { @@ -93,17 +93,21 @@ public class CrmCompanyHttpRepository : ICrmCompanyHttpRepository }; return pagingResponse; } - + /// + /// Get CRM customer by Id (SalesRep) + /// + /// + /// A CRM Company entity public async Task GetCompanyById(string companyId) { return await _client.GetFromJsonAsync($"{_conf.CrmCustomers}/{companyId}", _options); } /// - /// Create company from model + /// Create Customer (SalesRep) /// /// - /// company id + /// The Id of the entity public async Task CreateCompany(CompanyDto model) { var response = await _client.PostAsJsonAsync($"{_conf.CrmCustomers}", model, _options); @@ -113,10 +117,10 @@ public class CrmCompanyHttpRepository : ICrmCompanyHttpRepository } /// - /// Delete company + /// Delete the CRM customer (SalesRep) /// /// - /// + /// true/false to define success public async Task DeleteCompany(string companyId) { var response = await _client.DeleteAsync($"{_conf.CrmCustomers}/{companyId}"); @@ -124,11 +128,11 @@ public class CrmCompanyHttpRepository : ICrmCompanyHttpRepository } /// - /// Update Company CRM properties + /// Update CRM customer properties (SalesRep) /// /// /// - /// + /// A CRM Company entity public async Task UpdateCrmData(string companyId, CompanyDto model) { var updateModel = new UpdateCrmDto @@ -146,11 +150,11 @@ public class CrmCompanyHttpRepository : ICrmCompanyHttpRepository } /// - /// Update Company ERP properties + /// Update ERP customer properties (SalesRep) /// /// /// - /// + /// A CRM Company entity public async Task UpdateErpData(string companyId, CompanyDto model) { var updateModel = new UpdateErpDto @@ -172,11 +176,11 @@ public class CrmCompanyHttpRepository : ICrmCompanyHttpRepository } /// - /// Update company VAT number + /// Update customer Vat Number (SalesRep) /// /// /// - /// + /// A CRM Company entity public async Task UpdateCompanyVat(string companyId, string vatNumber) { var model = new Dictionary diff --git a/Wonky.Client/HttpRepository/CrmHistoryHttpRepository.cs b/Wonky.Client/HttpRepository/CustomerHistoryCrmHttpRepository.cs similarity index 87% rename from Wonky.Client/HttpRepository/CrmHistoryHttpRepository.cs rename to Wonky.Client/HttpRepository/CustomerHistoryCrmHttpRepository.cs index 2d33cbde..25fa1eaa 100644 --- a/Wonky.Client/HttpRepository/CrmHistoryHttpRepository.cs +++ b/Wonky.Client/HttpRepository/CustomerHistoryCrmHttpRepository.cs @@ -25,7 +25,7 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpRepository; -public class CrmHistoryHttpRepository : ICrmHistoryHttpRepository +public class CustomerHistoryCrmHttpRepository : ICustomerHistoryCrmHttpRepository { private readonly JsonSerializerOptions _options = new JsonSerializerOptions { @@ -33,12 +33,12 @@ public class CrmHistoryHttpRepository : ICrmHistoryHttpRepository }; private readonly NavigationManager _navigation; - private ILogger _logger; + private ILogger _logger; private readonly HttpClient _client; private readonly ApiConfig _api; - public CrmHistoryHttpRepository( - HttpClient client, ILogger logger, + public CustomerHistoryCrmHttpRepository( + HttpClient client, ILogger logger, NavigationManager navigation, IOptions configuration) { _client = client; @@ -48,7 +48,7 @@ public class CrmHistoryHttpRepository : ICrmHistoryHttpRepository } /// - /// fetch a list of invoices for CompanyId + /// Fetch Invoice LIst /// /// /// @@ -62,7 +62,7 @@ public class CrmHistoryHttpRepository : ICrmHistoryHttpRepository } /// - /// Fetch invoice from archiveHeadId + /// Fetch given invoice for given customer /// /// /// @@ -74,10 +74,10 @@ public class CrmHistoryHttpRepository : ICrmHistoryHttpRepository } /// - /// fetch inventory - summarized list of products + /// Fetch inventory from given customer /// /// - /// List of products + /// public async Task> FetchInventory(string companyId) { var response = await _client.GetAsync($"{_api.CrmCustomers}/{companyId}/{_api.CrmInventoryExt}"); @@ -90,10 +90,10 @@ public class CrmHistoryHttpRepository : ICrmHistoryHttpRepository } /// - /// Fetch history for all products + /// Fetch History for given customer /// /// - /// List of products + /// public async Task> FetchHistory(string companyId) { var response = await _client.GetAsync($"{_api.CrmCustomers}/{companyId}/{_api.CrmProductExt}"); @@ -106,11 +106,11 @@ public class CrmHistoryHttpRepository : ICrmHistoryHttpRepository } /// - /// Fetch history for single product + /// Fetch history for given customer and a given product /// /// /// - /// list of products + /// public async Task> FetchHistory(string companyId, string sku) { var response = await _client.GetAsync($"{_api.CrmCustomers}/{companyId}/{_api.CrmProductExt}/{sku}"); @@ -123,11 +123,11 @@ public class CrmHistoryHttpRepository : ICrmHistoryHttpRepository } /// - /// execute a remote procedure designed to update crm database from erp system based on a date string + /// RPC call to initiate remote server sync for given customer /// /// /// - /// date string + /// public async Task ErpInvoiceToCrmRpc(string companyId, string syncDate) { var x = await _client.GetAsync($"{_api.CrmCustomers}/{companyId}/{_api.CrmRpcSyncExt}/{syncDate}"); diff --git a/Wonky.Client/HttpRepository/OfficeCustomerHttpRepository.cs b/Wonky.Client/HttpRepository/CustomerOfficeHttpRepository.cs similarity index 77% rename from Wonky.Client/HttpRepository/OfficeCustomerHttpRepository.cs rename to Wonky.Client/HttpRepository/CustomerOfficeHttpRepository.cs index 61beb540..f2787c0a 100644 --- a/Wonky.Client/HttpRepository/OfficeCustomerHttpRepository.cs +++ b/Wonky.Client/HttpRepository/CustomerOfficeHttpRepository.cs @@ -34,66 +34,36 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpRepository; -public class OfficeCustomerHttpRepository : IOfficeCustomerHttpRepository +public class CustomerOfficeHttpRepository : ICustomerOfficeHttpRepository { private readonly JsonSerializerOptions _options = new () { PropertyNameCaseInsensitive = true }; - private readonly NavigationManager _navigation; - private ILogger _logger; + private readonly NavigationManager _navigator; + private ILogger _logger; private readonly HttpClient _client; private readonly ApiConfig _api; - public OfficeCustomerHttpRepository(HttpClient client, - ILogger logger, - NavigationManager navigation, + public CustomerOfficeHttpRepository(HttpClient client, + ILogger logger, + NavigationManager navigator, IOptions apiConfig) { _client = client; _logger = logger; - _navigation = navigation; + _navigator = navigator; _api = apiConfig.Value; } - - /// - /// Get paged list of customer entities by sales rep id - /// - /// - /// - /// - public async Task> GetCompaniesPagedSalesRep(string salesRepId, CompanyPagingParams pagingParameters) - { - var queryString = new Dictionary - { - ["pageNumber"] = pagingParameters.PageNumber.ToString(), - ["pageSize"] = pagingParameters.PageSize.ToString(), - ["searchTerm"] = pagingParameters.SearchTerm, - ["searchColumn"] = pagingParameters.SearchColumn, - ["orderBy"] = pagingParameters.OrderBy, - ["isHidden"] = pagingParameters.IsHidden.ToString(), - ["hasFolded"] = pagingParameters.HasFolded.ToString(), - ["countryCode"] = pagingParameters.CountryCode - }; - - var response = await _client.GetAsync(QueryHelpers.AddQueryString($"{_api.OfficeCustomers}/salesRep/{salesRepId}/", queryString)); - var content = await response.Content.ReadAsStringAsync(); - var pagingResponse = new PagingResponse - { - Items = JsonSerializer.Deserialize>(content, _options), - MetaData = JsonSerializer.Deserialize(response.Headers.GetValues("X-Pagination").First(), _options) - }; - return pagingResponse; - } - /// - /// Get paged list of customer companies by country code + /// Get customers paged for given sales rep /// /// + /// /// - public async Task> GetCompaniesPaged(CompanyPagingParams pagingParameters) + public async Task> GetCompaniesPaged(CustomerPaging pagingParameters, string countryCode) { var queryString = new Dictionary { @@ -118,6 +88,36 @@ public class OfficeCustomerHttpRepository : IOfficeCustomerHttpRepository return pagingResponse; } + /// + /// Get customers paged for given sales rep + /// + /// + /// + /// + public async Task> GetCompaniesPagedSalesRep(string salesRepId, CustomerPaging pagingParameters) + { + var queryString = new Dictionary + { + ["pageNumber"] = pagingParameters.PageNumber.ToString(), + ["pageSize"] = pagingParameters.PageSize.ToString(), + ["searchTerm"] = pagingParameters.SearchTerm, + ["searchColumn"] = pagingParameters.SearchColumn, + ["orderBy"] = pagingParameters.OrderBy, + ["isHidden"] = pagingParameters.IsHidden.ToString(), + ["hasFolded"] = pagingParameters.HasFolded.ToString(), + ["countryCode"] = pagingParameters.CountryCode + }; + + var response = await _client.GetAsync(QueryHelpers.AddQueryString($"{_api.OfficeCustomers}/salesRep/{salesRepId}/", queryString)); + var content = await response.Content.ReadAsStringAsync(); + var pagingResponse = new PagingResponse + { + Items = JsonSerializer.Deserialize>(content, _options), + MetaData = JsonSerializer.Deserialize(response.Headers.GetValues("X-Pagination").First(), _options) + }; + return pagingResponse; + + } /// /// Get customer entity by id /// @@ -128,22 +128,9 @@ public class OfficeCustomerHttpRepository : IOfficeCustomerHttpRepository var company = await _client.GetFromJsonAsync($"{_api.OfficeCustomers}/id/{companyId}"); return company ?? new CompanyDto(); } - + /// - /// Create company from model - /// - /// - /// company id - public async Task CreateCompany(CompanyDto model) - { - var response = await _client.PostAsJsonAsync($"{_api.OfficeCustomers}", model); - var content = await response.Content.ReadAsStringAsync(); - var result = JsonSerializer.Deserialize(content, _options); - return result.CompanyId; - } - - /// - /// Update company card + /// Update Company data /// /// /// @@ -156,14 +143,4 @@ public class OfficeCustomerHttpRepository : IOfficeCustomerHttpRepository return response.IsSuccessStatusCode; } - /// - /// Delete company - /// - /// - /// - public async Task DeleteCompany(string companyId) - { - var response = await _client.DeleteAsync($"{_api.OfficeCustomers}/{companyId}"); - return response.IsSuccessStatusCode; - } } \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/OfficeReportHttpRepository.cs b/Wonky.Client/HttpRepository/OfficeReportHttpRepository.cs deleted file mode 100644 index 42319199..00000000 --- a/Wonky.Client/HttpRepository/OfficeReportHttpRepository.cs +++ /dev/null @@ -1,59 +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.Net.Http.Json; -using System.Text.Json; -using Microsoft.AspNetCore.Components; -using Microsoft.Extensions.Options; -using Wonky.Client.HttpInterfaces; -using Wonky.Entity.Configuration; -using Wonky.Entity.DTO; -using Wonky.Entity.Views; - -namespace Wonky.Client.HttpRepository; - -public class OfficeReportHttpRepository : IOfficeReportHttpRepository -{ - private readonly JsonSerializerOptions _options = new JsonSerializerOptions - { - PropertyNameCaseInsensitive = true - }; - - private readonly NavigationManager _navigation; - private ILogger _logger; - private readonly HttpClient _client; - private readonly ApiConfig _apiConfig; - - public OfficeReportHttpRepository(HttpClient client, - ILogger logger, - NavigationManager navigation, IOptions configuration) - { - _client = client; - _logger = logger; - _navigation = navigation; - _apiConfig = configuration.Value; - } - - public async Task> GetReports(string userId) - { - return await _client.GetFromJsonAsync>($"{_apiConfig.OfficeReports}/{userId}"); - } - - public async Task GetReport(string userId, string workDate) - { - return await _client.GetFromJsonAsync($"{_apiConfig.OfficeReports}/{userId}/{workDate}"); - - } -} \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/CrmReportHttpRepository.cs b/Wonky.Client/HttpRepository/ReportHttpRepository.cs similarity index 59% rename from Wonky.Client/HttpRepository/CrmReportHttpRepository.cs rename to Wonky.Client/HttpRepository/ReportHttpRepository.cs index 71074793..c9f4f551 100644 --- a/Wonky.Client/HttpRepository/CrmReportHttpRepository.cs +++ b/Wonky.Client/HttpRepository/ReportHttpRepository.cs @@ -25,7 +25,7 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpRepository; -public class CrmReportHttpRepository :ICrmReportHttpRepository +public class ReportHttpRepository : IReportHttpRepository { private readonly JsonSerializerOptions _options = new JsonSerializerOptions { @@ -33,12 +33,12 @@ public class CrmReportHttpRepository :ICrmReportHttpRepository }; private readonly NavigationManager _navigation; - private ILogger _logger; + private ILogger _logger; private readonly HttpClient _client; private readonly ApiConfig _apiConfig; - public CrmReportHttpRepository(HttpClient client, - ILogger logger, + public ReportHttpRepository(HttpClient client, + ILogger logger, NavigationManager navigation, IOptions configuration) { _client = client; @@ -47,22 +47,42 @@ public class CrmReportHttpRepository :ICrmReportHttpRepository _apiConfig = configuration.Value; } - public async Task> GetReports() - { - return await _client.GetFromJsonAsync>($"{_apiConfig.CrmReports}"); - } + /// + /// Report Exist for given data (SalesRep) + /// + /// + /// public async Task ReportExist(string workDate) { var result = await _client.GetFromJsonAsync( $"{_apiConfig.CrmReports}/exist/{workDate}"); return result.ReportClosed; } - + + /// + /// Get Reports for (SalesRep) + /// + /// + public async Task> GetReports() + { + return await _client.GetFromJsonAsync>($"{_apiConfig.CrmReports}"); + } + + /// + /// Get Report for given date (SalesRep) + /// + /// + /// public async Task GetReport(string workDate) { return await _client.GetFromJsonAsync($"{_apiConfig.CrmReports}/{workDate}"); - } + + /// + /// Initialize Report for given data (SalesRep) + /// + /// + /// public async Task InitializeReportData(string workDate) { var initData = await _client @@ -70,13 +90,19 @@ public class CrmReportHttpRepository :ICrmReportHttpRepository return initData ?? new ReportInitDto(); } - public async Task PostReport(string workDate, ReportDto reportDto) + /// + /// Create Report for given data - using reportData + /// + /// + /// + /// + public async Task CreateReport(string workDate, ReportDto reportDto) { var response = await _client .PostAsJsonAsync($"{_apiConfig.CrmReports}/{workDate}", reportDto, _options); - + var jsonDate = await response.Content.ReadAsStringAsync(); - var result = JsonSerializer.Deserialize(jsonDate); + var result = JsonSerializer.Deserialize(jsonDate); return new ApiResponseView { Code = result.Code, @@ -85,4 +111,25 @@ public class CrmReportHttpRepository :ICrmReportHttpRepository IsSuccess = result.IsSuccess }; } + + /// + /// Get Reports for given userId (Office) + /// + /// + /// + public async Task> GetCountryReports(string userId) + { + return await _client.GetFromJsonAsync>($"{_apiConfig.OfficeReports}/{userId}"); + } + + /// + /// Get Report for given userId and workDate (Office) + /// + /// + /// + /// + public async Task GetCountryReport(string userId, string workDate) + { + return await _client.GetFromJsonAsync($"{_apiConfig.OfficeReports}/{userId}/{workDate}"); + } } \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/SendMailService.cs b/Wonky.Client/HttpRepository/SendMailService.cs index 3281b434..2a6e4177 100644 --- a/Wonky.Client/HttpRepository/SendMailService.cs +++ b/Wonky.Client/HttpRepository/SendMailService.cs @@ -16,13 +16,13 @@ public class SendMailService : ISendMailService { PropertyNameCaseInsensitive = true }; - + private readonly NavigationManager _navigation; private ILogger _logger; private readonly HttpClient _client; private readonly ApiConfig _api; - public SendMailService(HttpClient client, ILogger logger, + public SendMailService(HttpClient client, ILogger logger, NavigationManager navigation, IOptions configuration) { _client = client; @@ -30,14 +30,20 @@ public class SendMailService : ISendMailService _navigation = navigation; _api = configuration.Value; } - + + /// + /// Send Mail + /// + /// + /// + /// public async Task SendMail(string messageType, EmailMessage message) { var response = await _client.PostAsJsonAsync($"{_api.ServicesMail}/{messageType}", message, _options); if (!response.IsSuccessStatusCode) return new ApiResponseView { - Code = (int) response.StatusCode, + Code = (int)response.StatusCode, Message = $"{response.ReasonPhrase}: {await response.Content.ReadAsStringAsync()}", IsSuccess = false, Id = "" diff --git a/Wonky.Client/HttpRepository/CrmTaskItemHttpRepository.cs b/Wonky.Client/HttpRepository/TaskItemCrmHttpRepository.cs similarity index 71% rename from Wonky.Client/HttpRepository/CrmTaskItemHttpRepository.cs rename to Wonky.Client/HttpRepository/TaskItemCrmHttpRepository.cs index c2c01e8b..655eb177 100644 --- a/Wonky.Client/HttpRepository/CrmTaskItemHttpRepository.cs +++ b/Wonky.Client/HttpRepository/TaskItemCrmHttpRepository.cs @@ -26,21 +26,21 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpRepository; -public class CrmTaskItemHttpRepository : ICrmTaskItemHttpRepository +public class TaskItemCrmHttpRepository : ITaskItemCrmHttpRepository { private readonly JsonSerializerOptions _options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true, PropertyNamingPolicy = JsonNamingPolicy.CamelCase }; - + private readonly NavigationManager _navigation; - private ILogger _logger; + private ILogger _logger; private readonly HttpClient _client; private readonly ApiConfig _apiConfig; - public CrmTaskItemHttpRepository(HttpClient client, - ILogger logger, + public TaskItemCrmHttpRepository(HttpClient client, + ILogger logger, NavigationManager navigation, IOptions configuration) { _client = client; @@ -49,32 +49,60 @@ public class CrmTaskItemHttpRepository : ICrmTaskItemHttpRepository _apiConfig = configuration.Value; } - + /// + /// Get Task List (SalesRep) + /// + /// public async Task?> GetTaskList() { return await _client.GetFromJsonAsync>($"{_apiConfig.CrmTasks}", _options); } + /// + /// Get Task List for given workDate (SalesRep) + /// + /// + /// public async Task?> GetTaskList(string workDate) { return await _client.GetFromJsonAsync>($"{_apiConfig.CrmTasks}/date/{workDate}", _options); } + /// + /// Get Task Item by id (SalesRep) + /// + /// + /// public async Task GetTaskItem(string taskItemId) { return await _client.GetFromJsonAsync($"{_apiConfig.CrmTasks}/{taskItemId}", _options); } - + + /// + /// Create task using taskItem (SalesRep) + /// + /// + /// public async Task CreateTaskItem(TaskItemDto taskItem) { await _client.PostAsJsonAsync($"{_apiConfig.CrmTasks}", taskItem, _options); } - + + /// + /// Delete Task Item (SalesRep + /// + /// + /// public async Task UpdateTaskItem(string taskItemId, TaskItemDto taskItem) { await _client.PutAsJsonAsync($"{_apiConfig.CrmTasks}/{taskItemId}", taskItem, _options); } - + + /// + /// Delete Task Item (SalesRep + /// + /// + /// public async Task DeleteTaskItem(string taskItemId) { await _client.DeleteAsync($"{_apiConfig.CrmTasks}/{taskItemId}"); diff --git a/Wonky.Client/HttpRepository/UserHttpRepository.cs b/Wonky.Client/HttpRepository/UserHttpRepository.cs index ab00e9dc..8597ba03 100644 --- a/Wonky.Client/HttpRepository/UserHttpRepository.cs +++ b/Wonky.Client/HttpRepository/UserHttpRepository.cs @@ -31,13 +31,13 @@ public class UserHttpRepository : IUserHttpRepository { PropertyNameCaseInsensitive = true }; - + private readonly NavigationManager _navigation; private ILogger _logger; private readonly HttpClient _client; private readonly ApiConfig _api; - public UserHttpRepository(HttpClient client, ILogger logger, + public UserHttpRepository(HttpClient client, ILogger logger, NavigationManager navigation, IOptions configuration) { _client = client; @@ -45,40 +45,78 @@ public class UserHttpRepository : IUserHttpRepository _navigation = navigation; _api = configuration.Value; } - + + /// + /// Get Advisors (Office) + /// + /// public async Task> GetAdvisors() { return await _client.GetFromJsonAsync>(_api.OfficeAdvisors); } - + + /// + /// Get Advisor Info for given userId + /// + /// + /// public async Task GetAdvisorInfo(string userId) { return await _client.GetFromJsonAsync($"{_api.OfficeAdvisors}/{userId}"); } + /// + /// Update Advisor using userId and updated data + /// + /// + /// + /// public async Task UpdateAdvisor(string userId, UserUpdateDto model) { await _client.PutAsJsonAsync($"{_api.OfficeAdvisors}/{userId}", model, _options); } + /// + /// Get Administrative Users + /// + /// public async Task> GetAdminUsers() { return await _client.GetFromJsonAsync>(_api.OfficeUsers); } + /// + /// Get Admin Info for giver userId + /// + /// + /// public async Task GetAdminUserInfo(string userId) { return await _client.GetFromJsonAsync($"{_api.OfficeUsers}/{userId}"); } - + + /// + /// Update Admin user using userId and updated data + /// + /// + /// + /// public async Task UpdateAdminUser(string userId, UserUpdateDto model) { await _client.PutAsJsonAsync($"{_api.OfficeUsers}/{userId}", model, _options); } + /// + /// Set new user password + /// + /// + /// + /// + /// public async Task ResetUserPassword(string userId, string newPasswd, string confirmPasswd) { - var passwd = new Dictionary {{"newPassword", newPasswd}, {"confirmPassword", confirmPasswd}}; + var passwd = new Dictionary + { { "newPassword", newPasswd }, { "confirmPassword", confirmPasswd } }; await _client.PostAsJsonAsync($"{_api.OfficeUserPasswd}/{userId}", passwd, _options); } } \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/WarehouseHttpRepository.cs b/Wonky.Client/HttpRepository/WarehouseHttpRepository.cs index ec429f4e..b0af0c0d 100644 --- a/Wonky.Client/HttpRepository/WarehouseHttpRepository.cs +++ b/Wonky.Client/HttpRepository/WarehouseHttpRepository.cs @@ -29,7 +29,7 @@ public class WarehouseHttpRepository : IWarehouseHttpRepository { PropertyNameCaseInsensitive = true }; - + private readonly NavigationManager _navigation; private ILogger _logger; private readonly HttpClient _client; @@ -37,7 +37,7 @@ public class WarehouseHttpRepository : IWarehouseHttpRepository public WarehouseHttpRepository(HttpClient client, ILogger logger, - NavigationManager navigation, + NavigationManager navigation, IOptions configuration) { _client = client; @@ -46,20 +46,43 @@ public class WarehouseHttpRepository : IWarehouseHttpRepository _api = configuration.Value; } + /// + /// Get warehouse order list by date + /// + /// + /// public async Task> GetWarehouseOrderListByDate(string date) { return await _client.GetFromJsonAsync>($"{_api.Warehouse}?date={date}", _options); } - + + /// + /// Get orders by status + /// + /// + /// + /// public async Task> GetWarehouseOrderListByStatus(string status, string express = "") { - return await _client.GetFromJsonAsync>($"{_api.Warehouse}?status={status}&express={express}", _options); + return await _client.GetFromJsonAsync>( + $"{_api.Warehouse}?status={status}&express={express}", _options); } + /// + /// Get order with orderId + /// + /// + /// public async Task GetWarehouseOrder(string orderId) { return await _client.GetFromJsonAsync($"{_api.Warehouse}/{orderId}", _options); } + + /// + /// Update Order status setting new process status + /// + /// + /// public async Task UpdateWarehouseOrderStatus(WarehouseProcess process) { _logger.LogDebug("process => {}", JsonSerializer.Serialize(process, _options)); diff --git a/Wonky.Client/HttpRepository/CrmWorkplaceHttpRepository.cs b/Wonky.Client/HttpRepository/WorkplaceCrmHttpRepository.cs similarity index 68% rename from Wonky.Client/HttpRepository/CrmWorkplaceHttpRepository.cs rename to Wonky.Client/HttpRepository/WorkplaceCrmHttpRepository.cs index ea91b497..06d42e08 100644 --- a/Wonky.Client/HttpRepository/CrmWorkplaceHttpRepository.cs +++ b/Wonky.Client/HttpRepository/WorkplaceCrmHttpRepository.cs @@ -24,21 +24,21 @@ using Wonky.Entity.Views; namespace Wonky.Client.HttpRepository; -public class CrmWorkplaceHttpRepository : ICrmWorkplaceHttpRepository +public class WorkplaceCrmHttpRepository : IWorkplaceCrmHttpRepository { private readonly JsonSerializerOptions? _options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; - + private readonly NavigationManager _navigation; - private ILogger _logger; + private ILogger _logger; private readonly HttpClient _client; private readonly ApiConfig _api; - public CrmWorkplaceHttpRepository(HttpClient client, - ILogger logger, - NavigationManager navigation, + public WorkplaceCrmHttpRepository(HttpClient client, + ILogger logger, + NavigationManager navigation, IOptions configuration) { _client = client; @@ -46,7 +46,12 @@ public class CrmWorkplaceHttpRepository : ICrmWorkplaceHttpRepository _navigation = navigation; _api = configuration.Value; } - + + /// + /// Get Workplaces for given customer id + /// + /// + /// public async Task> GetWorkplaces(string companyId) { var result = await _client.GetFromJsonAsync>( @@ -54,6 +59,12 @@ public class CrmWorkplaceHttpRepository : ICrmWorkplaceHttpRepository return result ?? new List(); } + /// + /// Get specific workplace using customer id and workplace id + /// + /// + /// + /// public async Task GetWorkplace(string companyId, string workplaceId) { var result = await _client.GetFromJsonAsync( @@ -61,18 +72,36 @@ public class CrmWorkplaceHttpRepository : ICrmWorkplaceHttpRepository return result ?? new WorkplaceDto(); } + /// + /// Create new workplace given the customer id and workplace data + /// + /// + /// + /// public async Task CreateWorkplace(string companyId, WorkplaceDto workplace) { await _client.PostAsJsonAsync( $"{_api.CrmCustomers}/{companyId}/{_api.CrmWorkplaceExt}", workplace, _options); } + /// + /// Update workplace given the customer id and updated data + /// + /// + /// + /// public async Task UpdateWorkplace(string companyId, WorkplaceDto workplace) { await _client.PutAsJsonAsync( $"{_api.CrmCustomers}/{companyId}/{_api.CrmWorkplaceExt}/{workplace.WorkplaceId}", workplace, _options); } + /// + /// Delete workplace given customer id and workplace id + /// + /// + /// + /// public async Task DeleteWorkplace(string companyId, string workplaceId) { await _client.DeleteAsync( diff --git a/Wonky.Client/Pages/ActivityCreateCrmPage.razor.cs b/Wonky.Client/Pages/ActivityCreateCrmPage.razor.cs index 75cb6ed2..4b280514 100644 --- a/Wonky.Client/Pages/ActivityCreateCrmPage.razor.cs +++ b/Wonky.Client/Pages/ActivityCreateCrmPage.razor.cs @@ -43,11 +43,11 @@ public partial class ActivityCreateCrmPage : IDisposable [Inject] public IToastService Toast { get; set; } [Inject] public NavigationManager Navigator { get; set; } [Inject] public ILocalStorageService Storage { get; set; } - [Inject] public ICatalogHttpRepository Catalog { get; set; } - [Inject] public ICrmCompanyHttpRepository CompanyRepo { get; set; } - [Inject] public ICrmActivityHttpRepository ActivityRepo { get; set; } - [Inject] public ICrmReportHttpRepository ReportRepo { get; set; } - [Inject] public ICrmHistoryHttpRepository HistoryRepo { get; set; } + [Inject] public ICatalogCrmHttpRepository CatalogCrm { get; set; } + [Inject] public ICustomerCrmHttpRepository CompanyRepo { get; set; } + [Inject] public IActivityCrmHttpRepository ActivityRepo { get; set; } + [Inject] public IReportHttpRepository ReportRepo { get; set; } + [Inject] public ICustomerHistoryCrmHttpRepository HistoryRepo { get; set; } // variables private readonly JsonSerializerOptions? _options = new() {PropertyNameCaseInsensitive = true}; private SalesItemView SelectedItem { get; set; } = new(); @@ -258,7 +258,7 @@ public partial class ActivityCreateCrmPage : IDisposable // get selected item if (string.IsNullOrWhiteSpace(sku.ItemId)) return; - SelectedItem = await Catalog.GetSalesItemId(sku.ItemId); + SelectedItem = await CatalogCrm.GetSalesItemId(sku.ItemId); ShowItem = true; Price = sku.Rate; Quantity = sku.Quantity; diff --git a/Wonky.Client/Pages/ActivityListCustomerPage.razor.cs b/Wonky.Client/Pages/ActivityListCustomerPage.razor.cs index c255395a..c848db43 100644 --- a/Wonky.Client/Pages/ActivityListCustomerPage.razor.cs +++ b/Wonky.Client/Pages/ActivityListCustomerPage.razor.cs @@ -29,8 +29,8 @@ public partial class ActivityListCustomerPage : IDisposable { [Parameter] public string CompanyId { get; set; } = ""; [Inject] public HttpInterceptorService _interceptor { get; set; } - [Inject] public ICrmActivityHttpRepository CrmActivityRepo { get; set; } - [Inject] public ICrmCompanyHttpRepository CompanyRepo { get; set; } + [Inject] public IActivityCrmHttpRepository ActivityRepo { get; set; } + [Inject] public ICustomerCrmHttpRepository CompanyRepo { get; set; } private List Activities { get; set; } = new(); private CompanyDto Company { get; set; } = new(); private bool Working { get; set; } = true; @@ -48,7 +48,7 @@ public partial class ActivityListCustomerPage : IDisposable private async Task GetActivities() { Working = true; - Activities = await CrmActivityRepo.GetCustomerActivities(CompanyId); + Activities = await ActivityRepo.GetCustomerActivities(CompanyId); if(Activities.Any()) Activities = Activities.OrderByDescending(x => x.OrderDate).ToList(); Working = false; diff --git a/Wonky.Client/Pages/ActivityListTodayCrmPage.razor.cs b/Wonky.Client/Pages/ActivityListTodayCrmPage.razor.cs index ee65739b..0e1dd073 100644 --- a/Wonky.Client/Pages/ActivityListTodayCrmPage.razor.cs +++ b/Wonky.Client/Pages/ActivityListTodayCrmPage.razor.cs @@ -31,8 +31,8 @@ public partial class ActivityListTodayCrmPage : IDisposable [Inject] public ILogger Logger { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public NavigationManager Navigator { get; set; } - [Inject] public ICrmActivityHttpRepository CrmActivityRepo { get; set; } - [Inject] public ICrmReportHttpRepository CrmReportRepo { get; set; } + [Inject] public IActivityCrmHttpRepository ActivityRepo { get; set; } + [Inject] public IReportHttpRepository ReportRepo { get; set; } [Inject] public IToastService Toaster { get; set; } private ReportStatusView? ReportStatusView { get; set; } = new(); private UserPref UserPref { get; set; } = new(); @@ -46,7 +46,7 @@ public partial class ActivityListTodayCrmPage : IDisposable Interceptor.RegisterBeforeSendEvent(); UserPref = await UserProfileService.GetPreferences(); SelectedDate = string.IsNullOrWhiteSpace(UserPref.WorkDate) ? DateTime.Now : DateTime.Parse(UserPref.WorkDate); - ReportExist = await CrmReportRepo.ReportExist($"{SelectedDate:yyyy-MM-dd}"); + ReportExist = await ReportRepo.ReportExist($"{SelectedDate:yyyy-MM-dd}"); await GetActivities($"{SelectedDate:yyyy-MM-dd}"); Working = false; } @@ -57,8 +57,8 @@ public partial class ActivityListTodayCrmPage : IDisposable Toaster.ShowInfo("Vent nogle sekunder for data", "HENTER DATA"); SelectedDate = DateTime.Parse(workDate); ReportStatusView = new ReportStatusView(); - ReportExist = await CrmReportRepo.ReportExist($"{SelectedDate:yyyy-MM-dd}"); - ReportStatusView = await CrmActivityRepo.GetActivities($"{SelectedDate:yyyy-MM-dd}"); + ReportExist = await ReportRepo.ReportExist($"{SelectedDate:yyyy-MM-dd}"); + ReportStatusView = await ActivityRepo.GetActivities($"{SelectedDate:yyyy-MM-dd}"); Logger.LogDebug("Activities => {}", JsonSerializer.Serialize(ReportStatusView)); Working = false; Toaster.ClearAll(); diff --git a/Wonky.Client/Pages/ActivityViewCrmPage.razor.cs b/Wonky.Client/Pages/ActivityViewCrmPage.razor.cs index 32506389..681a8529 100644 --- a/Wonky.Client/Pages/ActivityViewCrmPage.razor.cs +++ b/Wonky.Client/Pages/ActivityViewCrmPage.razor.cs @@ -34,7 +34,7 @@ public partial class ActivityViewCrmPage : IDisposable [Parameter] public string CompanyId { get; set; } = ""; [Parameter] public string OrderId { get; set; } = ""; [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public ICrmActivityHttpRepository ActivityRepo { get; set; } + [Inject] public IActivityCrmHttpRepository ActivityRepo { get; set; } [Inject] public ILogger Logger { get; set; } [Inject] public IToastService Toaster { get; set; } [Inject] public NavigationManager Navigator { get; set; } diff --git a/Wonky.Client/Pages/CatalogCountryPage.razor b/Wonky.Client/Pages/CatalogCountryPage.razor new file mode 100644 index 00000000..930ffc16 --- /dev/null +++ b/Wonky.Client/Pages/CatalogCountryPage.razor @@ -0,0 +1,53 @@ +@* +// 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] +// +*@ + +@page "/price-catalog/{CountryCode}" +@using Wonky.Client.Components +@using Microsoft.AspNetCore.Authorization + +@attribute [Authorize(Roles = "Admin,Office,Warehouse")] + +
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ +
+
+ +@if (Working) +{ + +} diff --git a/Wonky.Client/Pages/CatalogCountryPage.razor.cs b/Wonky.Client/Pages/CatalogCountryPage.razor.cs new file mode 100644 index 00000000..3d84f092 --- /dev/null +++ b/Wonky.Client/Pages/CatalogCountryPage.razor.cs @@ -0,0 +1,121 @@ +// 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; +using System.Collections.Generic; +using System.Threading.Tasks; +using Blazored.LocalStorage; +using Wonky.Client.HttpInterceptors; +using Wonky.Client.HttpRepository; +using Microsoft.AspNetCore.Components; +using Wonky.Client.Components; +using Wonky.Client.HttpInterfaces; +using Wonky.Client.Services; +using Wonky.Entity.DTO; +using Wonky.Entity.Requests; +using Wonky.Entity.Views; + +namespace Wonky.Client.Pages; + +public partial class CatalogCountryPage : IDisposable +{ + [Parameter] public string CountryCode { get; set; } = ""; + [Inject] public ILocalStorageService Storage { get; set; } + [Inject] public ICatalogCrmHttpRepository ItemRepo { get; set; } + [Inject] public HttpInterceptorService Interceptor { get; set; } + [Inject] public UserProfileService ProfileService { get; set; } + private List Items { get; set; } = new(); + private MetaData MetaInfo { get; set; } = new(); + private CatalogPagingParams PageParams = new(); + private UserPref Prefs = new(); + private UserInfoView UserInfo { get; set; } = new(); + private bool Working { get; set; } = true; + + protected override async Task OnParametersSetAsync() + { + Prefs = await ProfileService.GetPreferences(); + UserInfo = await Storage.GetItemAsync("_xu"); + + PageParams.CountryCode = UserInfo.CountryCode; + + PageParams.OrderBy = Prefs.ItemSort; + PageParams.SearchColumn = Prefs.ItemSearch; + PageParams.PageSize = Convert.ToInt32(Prefs.PageSize); + + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); + + await FetchSalesItems(); + } + + private async Task SetSearchPhrase(string searchTerm) + { + Items = new List(); + PageParams.PageNumber = 1; + PageParams.SearchTerm = searchTerm; + await FetchSalesItems(); + } + + private async Task SetPageSize(string pageSize) + { + Items = new List(); + PageParams.PageSize = Convert.ToInt32(pageSize); + PageParams.PageNumber = 1; + await FetchSalesItems(); + } + + private async Task SetSearchCol(string columnName) + { + Items = new List(); + PageParams.PageNumber = 1; + PageParams.SearchColumn = columnName; + await FetchSalesItems(); + } + + private async Task SetSortCol(string orderBy) + { + Items = new List(); + PageParams.OrderBy = orderBy; + await FetchSalesItems(); + } + + private async Task SetSelectedPage(int page) + { + Items = new List(); + PageParams.PageNumber = page; + await FetchSalesItems(); + } + + private async Task SetGroupCol(string groupFilter) + { + Items = new List(); + PageParams.PageNumber = 1; + PageParams.SelectGroup = groupFilter; + await FetchSalesItems(); + } + + private async Task FetchSalesItems() + { + Working = true; + var pagingResponse = await ItemRepo.GetSalesItemsPaged(PageParams, CountryCode); + Working = false; + Items = pagingResponse.Items!; + MetaInfo = pagingResponse.MetaData; + } + + + public void Dispose() => Interceptor.DisposeEvent(); + +} \ No newline at end of file diff --git a/Wonky.Client/Pages/CatalogPage.razor b/Wonky.Client/Pages/CatalogCrmPage.razor similarity index 100% rename from Wonky.Client/Pages/CatalogPage.razor rename to Wonky.Client/Pages/CatalogCrmPage.razor diff --git a/Wonky.Client/Pages/CatalogPage.razor.cs b/Wonky.Client/Pages/CatalogCrmPage.razor.cs similarity index 97% rename from Wonky.Client/Pages/CatalogPage.razor.cs rename to Wonky.Client/Pages/CatalogCrmPage.razor.cs index da655145..d681e3b2 100644 --- a/Wonky.Client/Pages/CatalogPage.razor.cs +++ b/Wonky.Client/Pages/CatalogCrmPage.razor.cs @@ -29,10 +29,10 @@ using Wonky.Entity.Views; namespace Wonky.Client.Pages; -public partial class CatalogPage : IDisposable +public partial class CatalogCrmPage : IDisposable { [Inject] public ILocalStorageService Storage { get; set; } - [Inject] public ICatalogHttpRepository ItemRepo { get; set; } + [Inject] public ICatalogCrmHttpRepository ItemRepo { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public UserProfileService ProfileService { get; set; } private List Items { get; set; } = new(); diff --git a/Wonky.Client/Pages/CustomerCreateCrmPage.razor.cs b/Wonky.Client/Pages/CustomerCreateCrmPage.razor.cs index 06aa3abb..cf9b3553 100644 --- a/Wonky.Client/Pages/CustomerCreateCrmPage.razor.cs +++ b/Wonky.Client/Pages/CustomerCreateCrmPage.razor.cs @@ -43,7 +43,7 @@ namespace Wonky.Client.Pages [Inject] public ILogger Logger { get; set; } [Inject] public ILocalStorageService Storage { get; set; } [Inject] public NavigationManager Navigator { get; set; } - [Inject] public ICrmCompanyHttpRepository CompanyRepo { get; set; } + [Inject] public ICustomerCrmHttpRepository CompanyRepo { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public VatInfoLookupService VatService { get; set; } private EditContext CompanyContext { get; set; } diff --git a/Wonky.Client/Pages/CustomerInvoiceListCrmPage.razor.cs b/Wonky.Client/Pages/CustomerInvoiceListCrmPage.razor.cs index 4e8731ed..d3ad746b 100644 --- a/Wonky.Client/Pages/CustomerInvoiceListCrmPage.razor.cs +++ b/Wonky.Client/Pages/CustomerInvoiceListCrmPage.razor.cs @@ -14,9 +14,9 @@ namespace Wonky.Client.Pages; public partial class CustomerInvoiceListCrmPage : IDisposable { [Parameter] public string CompanyId { get; set; } = ""; - [Inject] public ICrmCompanyHttpRepository CompanyRepo { get; set; } + [Inject] public ICustomerCrmHttpRepository CompanyRepo { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public ICrmHistoryHttpRepository HistoryRepo { get; set; } + [Inject] public ICustomerHistoryCrmHttpRepository HistoryRepo { get; set; } [Inject] public IToastService Toaster { get; set; } [Inject] public ILocalStorageService Storage { get; set; } [Inject] public ILogger Logger { get; set; } diff --git a/Wonky.Client/Pages/CustomerListCountryPage.razor b/Wonky.Client/Pages/CustomerListCountryPage.razor new file mode 100644 index 00000000..f24f3c8e --- /dev/null +++ b/Wonky.Client/Pages/CustomerListCountryPage.razor @@ -0,0 +1,59 @@ +@* +// 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] +// +*@ + +@page "/office/{countryCode}/customers" +@using Wonky.Client.Components +@using Microsoft.AspNetCore.Authorization + +@attribute [Authorize(Roles = "Admin,Office")] + +
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+ + +
+
+
+ +
+ +
+
+ + + +@if (Working) +{ + +} + diff --git a/Wonky.Client/Pages/CustomerListCountryPage.razor.cs b/Wonky.Client/Pages/CustomerListCountryPage.razor.cs new file mode 100644 index 00000000..0ce0fddb --- /dev/null +++ b/Wonky.Client/Pages/CustomerListCountryPage.razor.cs @@ -0,0 +1,151 @@ +// 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; +using System.Collections.Generic; +using System.Threading.Tasks; +using Blazored.LocalStorage; +using Wonky.Client.HttpInterceptors; +using Wonky.Client.HttpRepository; +using Microsoft.AspNetCore.Components; +using Wonky.Client.HttpInterfaces; +using Wonky.Client.Services; +using Wonky.Entity.DTO; +using Wonky.Entity.Requests; +using Wonky.Entity.Views; + +namespace Wonky.Client.Pages +{ + public partial class CustomerListCountryPage : IDisposable + { + [Parameter] public string CountryCode { get; set; } = ""; + [Inject] public ILocalStorageService Storage { get; set; } + [Inject] public UserProfileService ProfileService { get; set; } + [Inject] public ICustomerCrmHttpRepository CompanyRepo { get; set; } + [Inject] public HttpInterceptorService Interceptor { get; set; } + [Inject] public NavigationManager Navigator { get; set; } + private List Companies { get; set; } = new(); + private UserPref Prefs { get; set; } = new(); + private UserInfoView UserInfo { get; set; } = new(); + private string SavedSearch { get; set; } = ""; + private bool IncludeFolded { get; set; } + private bool Working { get; set; } = true; + private MetaData PageData { get; set; } = new(); + private CustomerPaging Paging { get; set; } = new(); + + protected override async Task OnParametersSetAsync() + { + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); + // set preferences + Prefs = await ProfileService.GetPreferences(); + UserInfo = await Storage.GetItemAsync("_xu"); + Paging.OrderBy = Prefs.CompanySort; + Paging.SearchColumn = Prefs.CompanySearch; + Paging.PageSize = Convert.ToInt32(Prefs.PageSize); + Paging.HasFolded = IncludeFolded ? 1 : 0; + Paging.CountryCode = UserInfo.CountryCode; + + // load saved search + SavedSearch = string.IsNullOrWhiteSpace(Prefs.CompanyFilterPhrase) ? "" : Prefs.CompanyFilterPhrase; + Paging.SearchTerm = SavedSearch; + + // get companies + await FetchCustomers(); + Working = false; + + } + + private async Task OnFoldedClick() + { + IncludeFolded = !IncludeFolded; + Companies = new List(); + Paging.PageNumber = 1; + Paging.HasFolded = IncludeFolded ? 1 : 0; + await FetchCustomers(); + } + + private async Task SelectedPage(int page) + { + Companies = new List(); + Paging.PageNumber = page; + await FetchCustomers(); + } + + private async Task SetSearchCol(string searchColumn) + { + Companies = new List(); + Paging.SearchColumn = searchColumn; + Paging.PageNumber = 1; + await FetchCustomers(); + } + private async Task SetPageSize(string pageSize) + { + Companies = new List(); + Paging.PageSize = Convert.ToInt32(pageSize); + Paging.PageNumber = 1; + await FetchCustomers(); + } + + private async Task SetSearchPhrase(string searchTerm) + { + Companies = new List(); + Paging.PageNumber = 1; + Paging.SearchTerm = searchTerm; + await FetchCustomers(); + } + + private async Task SetSortCol(string orderBy) + { + Companies = new List(); + Paging.OrderBy = orderBy; + await FetchCustomers(); + } + + /// + /// Removes a company from CRM + /// + /// + private async Task DeleteCompany(string companyId) + { + Companies = new List(); + await CompanyRepo.DeleteCompany(companyId); + if (Paging.PageNumber > 1 && Companies.Count == 1) + Paging.PageNumber--; + await FetchCustomers(); + } + + private async Task FetchCustomers() + { + Working = true; + var pageRes = await CompanyRepo.GetCompanies(Paging); + Working = false; + if (pageRes.Items.Any()) + { + Companies = pageRes.Items; + PageData = pageRes.MetaData; + } + else + { + Companies = new List(); + PageData = new MetaData(); + } + } + + public void Dispose() => Interceptor.DisposeEvent(); + } +} + + \ No newline at end of file diff --git a/Wonky.Client/Pages/CustomerListCrmPage.razor.cs b/Wonky.Client/Pages/CustomerListCrmPage.razor.cs index f99730a0..3ec296f0 100644 --- a/Wonky.Client/Pages/CustomerListCrmPage.razor.cs +++ b/Wonky.Client/Pages/CustomerListCrmPage.razor.cs @@ -32,7 +32,7 @@ namespace Wonky.Client.Pages { [Inject] public ILocalStorageService Storage { get; set; } [Inject] public UserProfileService ProfileService { get; set; } - [Inject] public ICrmCompanyHttpRepository CompanyRepo { get; set; } + [Inject] public ICustomerCrmHttpRepository CompanyRepo { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public NavigationManager Navigator { get; set; } private List Companies { get; set; } = new(); @@ -42,7 +42,7 @@ namespace Wonky.Client.Pages private bool IncludeFolded { get; set; } private bool Working { get; set; } = true; private MetaData PageData { get; set; } = new(); - private CompanyPagingParams PageParams { get; set; } = new(); + private CustomerPaging Paging { get; set; } = new(); protected override void OnParametersSet() { @@ -56,15 +56,15 @@ namespace Wonky.Client.Pages // set preferences Prefs = await ProfileService.GetPreferences(); UserInfo = await Storage.GetItemAsync("_xu"); - PageParams.OrderBy = Prefs.CompanySort; - PageParams.SearchColumn = Prefs.CompanySearch; - PageParams.PageSize = Convert.ToInt32(Prefs.PageSize); - PageParams.HasFolded = IncludeFolded ? 1 : 0; - PageParams.CountryCode = UserInfo.CountryCode; + Paging.OrderBy = Prefs.CompanySort; + Paging.SearchColumn = Prefs.CompanySearch; + Paging.PageSize = Convert.ToInt32(Prefs.PageSize); + Paging.HasFolded = IncludeFolded ? 1 : 0; + Paging.CountryCode = UserInfo.CountryCode; // load saved search SavedSearch = string.IsNullOrWhiteSpace(Prefs.CompanyFilterPhrase) ? "" : Prefs.CompanyFilterPhrase; - PageParams.SearchTerm = SavedSearch; + Paging.SearchTerm = SavedSearch; // get companies await FetchCompanies(); @@ -75,45 +75,45 @@ namespace Wonky.Client.Pages { IncludeFolded = !IncludeFolded; Companies = new List(); - PageParams.PageNumber = 1; - PageParams.HasFolded = IncludeFolded ? 1 : 0; + Paging.PageNumber = 1; + Paging.HasFolded = IncludeFolded ? 1 : 0; await FetchCompanies(); } private async Task SelectedPage(int page) { Companies = new List(); - PageParams.PageNumber = page; + Paging.PageNumber = page; await FetchCompanies(); } private async Task SetSearchCol(string searchColumn) { Companies = new List(); - PageParams.SearchColumn = searchColumn; - PageParams.PageNumber = 1; + Paging.SearchColumn = searchColumn; + Paging.PageNumber = 1; await FetchCompanies(); } private async Task SetPageSize(string pageSize) { Companies = new List(); - PageParams.PageSize = Convert.ToInt32(pageSize); - PageParams.PageNumber = 1; + Paging.PageSize = Convert.ToInt32(pageSize); + Paging.PageNumber = 1; await FetchCompanies(); } private async Task SetSearchPhrase(string searchTerm) { Companies = new List(); - PageParams.PageNumber = 1; - PageParams.SearchTerm = searchTerm; + Paging.PageNumber = 1; + Paging.SearchTerm = searchTerm; await FetchCompanies(); } private async Task SetSortCol(string orderBy) { Companies = new List(); - PageParams.OrderBy = orderBy; + Paging.OrderBy = orderBy; await FetchCompanies(); } @@ -125,15 +125,15 @@ namespace Wonky.Client.Pages { Companies = new List(); await CompanyRepo.DeleteCompany(companyId); - if (PageParams.PageNumber > 1 && Companies.Count == 1) - PageParams.PageNumber--; + if (Paging.PageNumber > 1 && Companies.Count == 1) + Paging.PageNumber--; await FetchCompanies(); } private async Task FetchCompanies() { Working = true; - var pageRes = await CompanyRepo.GetCompanies(PageParams); + var pageRes = await CompanyRepo.GetCompanies(Paging); Working = false; if (pageRes.Items.Any()) { diff --git a/Wonky.Client/Pages/CustomerListOfficePage.razor b/Wonky.Client/Pages/CustomerListOfficePage.razor deleted file mode 100644 index b84981ef..00000000 --- a/Wonky.Client/Pages/CustomerListOfficePage.razor +++ /dev/null @@ -1,61 +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.Client.Components -@using Microsoft.AspNetCore.Authorization -@attribute [Authorize(Roles = "Admin,Office,Warehouse")] -@page "/office/companies/{CountryCode}" - -
-
-
-
- -
-
- -
-
- -
-
- -
-
-
-
-
- - -
-
-
- -
- -
-
-
- - - -@if (Working) -{ - -} diff --git a/Wonky.Client/Pages/CustomerListOfficePage.razor.cs b/Wonky.Client/Pages/CustomerListOfficePage.razor.cs deleted file mode 100644 index 60f5345c..00000000 --- a/Wonky.Client/Pages/CustomerListOfficePage.razor.cs +++ /dev/null @@ -1,131 +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.Components; -using Wonky.Client.HttpInterceptors; -using Wonky.Client.HttpInterfaces; -using Wonky.Client.Services; -using Wonky.Entity.DTO; -using Wonky.Entity.Requests; - -namespace Wonky.Client.Pages; - -public partial class CustomerListOfficePage : IDisposable -{ - [Parameter] public string UserId { get; set; } = ""; - [Parameter] public string CountryCode { get; set; } = "dk"; - - [Inject] public ILogger Logger { get; set; } - [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public IOfficeCustomerHttpRepository CustomerRepo { get; set; } - [Inject] public UserProfileService UserProfileService { get; set; } - private List _companyList { get; set; } = new(); - private MetaData _metaData { get; set; } = new(); - private CompanyPagingParams _paging = new(); - private UserPref UserPref { get; set; } = new(); - private string _savedSearch { get; set; } = ""; - private bool _includeFolded { get; set; } - private bool Working { get; set; } = true; - - protected override async Task OnParametersSetAsync() - { - Interceptor.DisposeEvent(); - Interceptor.RegisterBeforeSendEvent(); - - // set preferences - UserPref = await UserProfileService.GetPreferences(); - - _paging.CountryCode = CountryCode; - - _paging.OrderBy = UserPref.CompanySort; - _paging.SearchColumn = UserPref.CompanySearch; - _paging.PageSize = Convert.ToInt32(UserPref.PageSize); - _paging.HasFolded = _includeFolded ? 1 : 0; - - // load saved search - _savedSearch = UserPref.CompanyFilterPhrase; - _paging.SearchTerm = _savedSearch; - - await FetchCompanies(); - Working = false; - } - - private async Task OnFoldedClick() - { - _includeFolded = !_includeFolded; - _companyList = new List(); - _paging.PageNumber = 1; - _paging.HasFolded = _includeFolded ? 1 : 0; - await FetchCompanies(); - } - - private async Task SelectedPage(int page) - { - _companyList = new List(); - _paging.PageNumber = page; - await FetchCompanies(); - } - - private async Task SetSearchCol(string searchColumn) - { - _companyList = new List(); - _paging.SearchColumn = searchColumn; - _paging.PageNumber = 1; - await FetchCompanies(); - } - private async Task SetPageSize(string pageSize) - { - _companyList = new List(); - _paging.PageSize = Convert.ToInt32(pageSize); - _paging.PageNumber = 1; - await FetchCompanies(); - } - - private async Task SetSearchPhrase(string searchTerm) - { - // if (!string.IsNullOrWhiteSpace(searchTerm) && searchTerm.Length < 3) return; - - _companyList = new List(); - _paging.PageNumber = 1; - _paging.SearchTerm = searchTerm; - await FetchCompanies(); - if (!string.IsNullOrWhiteSpace(searchTerm) && searchTerm.TrimEnd().Length > 2) - { - _savedSearch = searchTerm; - await UserProfileService.SetCompanyFilterPhrase(searchTerm.Trim()); - } - } - - private async Task SetSortCol(string orderBy) - { - _companyList = new List(); - _paging.OrderBy = orderBy; - await FetchCompanies(); - } - - private async Task FetchCompanies() - { - Working = true; - var pagingResponse = await CustomerRepo.GetCompaniesPagedSalesRep(UserId, _paging); - _companyList = pagingResponse.Items; - _metaData = pagingResponse.MetaData; - Working = false; - } - - public void Dispose() - { - Interceptor.DisposeEvent(); - } -} \ No newline at end of file diff --git a/Wonky.Client/Pages/CustomerProductListCrmPage.razor.cs b/Wonky.Client/Pages/CustomerProductListCrmPage.razor.cs index d0b20dd4..af1042cf 100644 --- a/Wonky.Client/Pages/CustomerProductListCrmPage.razor.cs +++ b/Wonky.Client/Pages/CustomerProductListCrmPage.razor.cs @@ -30,8 +30,8 @@ namespace Wonky.Client.Pages; public partial class CustomerProductListCrmPage : IDisposable { [Parameter] public string CompanyId { get; set; } = ""; - [Inject] public ICrmHistoryHttpRepository HistoryRepo { get; set; } - [Inject] public ICrmCompanyHttpRepository CompanyRepo { get; set; } + [Inject] public ICustomerHistoryCrmHttpRepository HistoryRepo { get; set; } + [Inject] public ICustomerCrmHttpRepository CompanyRepo { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public IToastService Toaster { get; set; } [Inject] public ILogger Logger { get; set; } diff --git a/Wonky.Client/Pages/CustomerViewCrmPage.razor.cs b/Wonky.Client/Pages/CustomerViewCrmPage.razor.cs index 593bf8fc..7b2b1a6a 100644 --- a/Wonky.Client/Pages/CustomerViewCrmPage.razor.cs +++ b/Wonky.Client/Pages/CustomerViewCrmPage.razor.cs @@ -37,9 +37,9 @@ public partial class CustomerViewCrmPage : IDisposable [Inject] public IToastService Toaster { get; set; } [Inject] public ILogger Logger { get; set; } [Inject] public NavigationManager Navigator { get; set; } - [Inject] public ICrmCompanyHttpRepository CompanyRepo { get; set; } - [Inject] public ICrmHistoryHttpRepository HistoryRepo { get; set; } - [Inject] public ICrmContactHttpRepository ContactRepo { get; set; } + [Inject] public ICustomerCrmHttpRepository CompanyRepo { get; set; } + [Inject] public ICustomerHistoryCrmHttpRepository HistoryRepo { get; set; } + [Inject] public IContactCrmHttpRepository ContactRepo { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public VatInfoLookupService VatService { get; set; } [Inject] public ILocalStorageService Storage { get; set; } diff --git a/Wonky.Client/Pages/KrvItemViewAdminPage.razor.cs b/Wonky.Client/Pages/KrvItemViewAdminPage.razor.cs index 70819c02..bada60d5 100644 --- a/Wonky.Client/Pages/KrvItemViewAdminPage.razor.cs +++ b/Wonky.Client/Pages/KrvItemViewAdminPage.razor.cs @@ -28,7 +28,7 @@ public partial class KrvItemViewAdminPage : IDisposable { [Parameter] public string SalesItemId { get; set; } = ""; private SalesItemView _item { get; set; } = new (); - [Inject] public ICatalogHttpRepository _itemRepo { get; set; } + [Inject] public ICatalogCrmHttpRepository _itemRepo { get; set; } [Inject] public HttpInterceptorService _interceptor { get; set; } diff --git a/Wonky.Client/HttpInterfaces/IOfficeReportHttpRepository.cs b/Wonky.Client/Pages/LandingPageAdminCountry.razor similarity index 76% rename from Wonky.Client/HttpInterfaces/IOfficeReportHttpRepository.cs rename to Wonky.Client/Pages/LandingPageAdminCountry.razor index bcb6bf69..81b37bf6 100644 --- a/Wonky.Client/HttpInterfaces/IOfficeReportHttpRepository.cs +++ b/Wonky.Client/Pages/LandingPageAdminCountry.razor @@ -1,3 +1,4 @@ +@* // 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 @@ -12,14 +13,18 @@ // 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 +@attribute [Authorize(Roles = "Admin")] +@page "/office/{CountryCode}" -using Wonky.Entity.Views; -namespace Wonky.Client.HttpInterfaces; -public interface IOfficeReportHttpRepository -{ - Task> GetReports(string userId); - Task GetReport(string userId, string workDate); +@code { + + [Parameter] + public string CountryCode { get; set; } = ""; + } \ No newline at end of file diff --git a/Wonky.Client/Pages/LandingPageAdminUsers.razor b/Wonky.Client/Pages/LandingPageAdminUsers.razor index b7aa8857..e8863c3e 100644 --- a/Wonky.Client/Pages/LandingPageAdminUsers.razor +++ b/Wonky.Client/Pages/LandingPageAdminUsers.razor @@ -17,19 +17,12 @@ @using Microsoft.AspNetCore.Authorization @attribute [Authorize(Roles = "Admin")] -@page "/office/users/office" +@page "/office/{countryCode}/salesreps" -
-
-
-

Administrative brugere

-
-
-
-
- Danmark -
-
+
+
+
+
@code { diff --git a/Wonky.Client/Pages/OrderCreateOfficePage.razor b/Wonky.Client/Pages/OrderCreateOfficePage.razor deleted file mode 100644 index 30036b66..00000000 --- a/Wonky.Client/Pages/OrderCreateOfficePage.razor +++ /dev/null @@ -1,198 +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 = "Admin,Office,Warehouse")] -@page "/office/customers/{CompanyId}/orders/new" - - - -
- -
- -
- -
- -
- -
- -
- -
-
- -
- - -
- - -
- - -
-
- -
- -
- - -
-
-
-
- - - - - - - - - - - - - - - - - - @if (DraftStateProvider != null && DraftStateProvider.Draft.Items.Count > 0) - { - @foreach (var cartItem in DraftStateProvider.Draft.Items) - { - - - - - - - - - - } - } - - - - - - - - -
- Ordrekladde Global kladde (udløber efter @(DraftStateProvider.Draft.TimeToLiveInSeconds / 60)m inaktivitet) - - -
NavnVarenrAntalEnhedsprisLinjesumSAS
@cartItem.Item.Name@cartItem.Item.Sku@cartItem.Quantity@cartItem.Price@cartItem.LineTotal - - - -
Total@DraftStateProvider.Draft.Total - -
-
-
-
-
- @* draft line *@ - @if (_selectedItem != null && ShowItem) - { - - - - - - - - - - - - - - - - - - - - - - - - -
Kladdelinje
AntalPrisRabatSASVarenr.
- - - - - - - - @_selectedItem.Sku - -
- } -
-
- -
-
-
- -
-
- -
-
- -
-
-
-
- -
-
- -
-
-
- - -
- - - -@if (Working) -{ - -} diff --git a/Wonky.Client/Pages/OrderCreateOfficePage.razor.cs b/Wonky.Client/Pages/OrderCreateOfficePage.razor.cs deleted file mode 100644 index cf85067e..00000000 --- a/Wonky.Client/Pages/OrderCreateOfficePage.razor.cs +++ /dev/null @@ -1,196 +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.Globalization; -using System.Text.Json; -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Components.Forms; -using Wonky.Client.HttpInterceptors; -using Wonky.Client.HttpInterfaces; -using Wonky.Client.HttpRepository; -using Wonky.Client.Models; -using Wonky.Client.Shared; -using Wonky.Entity.DTO; -using Wonky.Entity.Views; - -namespace Wonky.Client.Pages; - -public partial class OrderCreateOfficePage : IDisposable -{ - [CascadingParameter] DraftStateProvider DraftStateProvider { get; set; } - [Parameter] public string CompanyId { get; set; } - [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public IOfficeCustomerHttpRepository OfficeCustomerRepo { get; set; } - [Inject] public IUserHttpRepository UserRepo { get; set; } - [Inject] public ICatalogHttpRepository CatalogRepo { get; set; } - [Inject] public ICrmActivityHttpRepository CrmActivityRepo { get; set; } - [Inject] public ILogger Logger { get; set; } - - private ActivityDto _activity { get; set; } = new(); - private EditContext _editContext { get; set; } - private PriceListModal _priceList { get; set; } = new(); - private CompanyDto _company { get; set; } = new(); - private WebUserInfoView _userInfo { get; set; } = new(); - private SalesItemView _selectedItem { get; set; } = new(); - private string Rate { get; set; } = "0"; - private string Quantity { get; set; } = "1"; - private string Price { get; set; } = "0"; - private string Discount { get; set; } = "0"; - private bool ShowItem { get; set; } - private bool Sas { get; set; } - private bool FormInvalid { get; set; } = true; - private bool HideButton { get; set; } - private bool Working { get; set; } = true; - - protected override async Task OnParametersSetAsync() - { - Interceptor.RegisterEvent(); - Interceptor.RegisterBeforeSendEvent(); - _company = await OfficeCustomerRepo.GetByCustomerId(CompanyId); - } - - protected override async Task OnInitializedAsync() - { - - _editContext = new EditContext(_activity); - _editContext.OnFieldChanged += HandleFieldChanged; - _editContext.OnValidationStateChanged += ValidationChanged; - - _userInfo = await UserRepo.GetAdvisorInfo(_company.SalesRepId); - - _activity.ActivityDate = $"{DateTime.Now:yyyy-MM-dd}" ; - - // variable to validate if customer needs phone number update - // _phone = _company.Phone; - if (string.IsNullOrWhiteSpace(_company.Phone) - && !string.IsNullOrWhiteSpace(_company.Account) - && _company.Account != "NY" && _company.Account.Length > 7) - { - _company.Phone = _company.Account[..8]; - } - - _activity.ActivityStatusEnum = "order"; - _activity.ActivityTypeEnum = "phone"; - - // set up identification - _activity.CompanyId = _company.CompanyId; - _activity.BcId = _company.BcId; - _activity.SalesRepId = _company.SalesRepId; - _activity.SalesRep = _company.SalesRep; - _activity.Account = _company.Account; - _activity.VatNumber = _company.VatNumber; - _activity.Email = _company.Email; - _activity.Phone = _company.Phone; - _activity.Mobile = _company.Mobile; - - _activity.Name = _company.Name; - _activity.Address1 = _company.Address1; - _activity.Address2 = _company.Address2; - _activity.ZipCode = _company.ZipCode; - _activity.City = _company.City; - - _activity.DlvName = _company.Name; - _activity.DlvAddress1 = _company.Address1; - _activity.DlvAddress2 = _company.Address2; - _activity.DlvZipCode = _company.ZipCode; - _activity.DlvCity = _company.City; - - Working = false; - - } - private void CallPriceListModal() - { - _priceList.Show(); - } - - private async Task SelectSku(SelectedSku sku) - { - ShowItem = true; - _selectedItem = await CatalogRepo.GetSalesVariantId(sku.ItemId); - Price = sku.Rate; - Quantity = sku.Quantity; - } - - private async Task DeleteDraft() - { - await DraftStateProvider.DeleteDraftAsync(); - } - - private async Task CreateOrder() - { - Working = true; - await CrmActivityRepo.CreateActivity(_activity); - Working = false; - } - private async Task AddItem(SalesItemView salesItem) - { - ShowItem = false; - // create a new cart item - var item = new DraftItem - { - Item = salesItem, - Quantity = Convert.ToInt32(Quantity), - Price = Convert.ToDecimal(Price, CultureInfo.InvariantCulture), - Discount = Convert.ToDecimal(Discount, CultureInfo.InvariantCulture), - Sas = Sas - }; - // reset internals to initial state - Sas = false; - Quantity = "1"; - Price = "0"; - Discount = "0"; - // add it to the cart - DraftStateProvider.Draft.Items.Add(item); - // save the item using the CartStateProvider's save method - await DraftStateProvider.SaveChangesAsync(); - } - private async Task RemoveItem(DraftItem item) - { - // remove item - DraftStateProvider.Draft.Items.Remove(item); - // save the remaining draft - await DraftStateProvider.SaveChangesAsync(); - } - - private void HandleFieldChanged(object sender, FieldChangedEventArgs e) - { - if (DraftStateProvider.Draft.Items.Count == 0) - { - FormInvalid = true; - return; - } - - FormInvalid = !_editContext.Validate(); - StateHasChanged(); - } - private void ValidationChanged(object sender, ValidationStateChangedEventArgs e) - { - FormInvalid = false; - - _editContext.OnFieldChanged -= HandleFieldChanged; - _editContext.OnValidationStateChanged -= ValidationChanged; - _editContext = new EditContext(_activity); - _editContext.OnFieldChanged += HandleFieldChanged; - _editContext.OnValidationStateChanged += ValidationChanged; - } - - public void Dispose() - { - Interceptor.DisposeEvent(); - _editContext.OnFieldChanged -= HandleFieldChanged; - _editContext.OnValidationStateChanged -= ValidationChanged; - } -} \ No newline at end of file diff --git a/Wonky.Client/Pages/OrderViewOfficePage.razor.cs b/Wonky.Client/Pages/OrderViewOfficePage.razor.cs index d22868ed..ed7d10f8 100644 --- a/Wonky.Client/Pages/OrderViewOfficePage.razor.cs +++ b/Wonky.Client/Pages/OrderViewOfficePage.razor.cs @@ -35,7 +35,7 @@ public partial class OrderViewOfficePage : IDisposable [Parameter] public string CompanyId { get; set; } = ""; [Parameter] public string OrderId { get; set; } = ""; [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public ICrmActivityHttpRepository ActivityRepo { get; set; } + [Inject] public IActivityCrmHttpRepository ActivityRepo { get; set; } [Inject] public ISendMailService MailService { get; set; } [Inject] public ILocalStorageService Storage { get; set; } [Inject] public IUserHttpRepository UserRepo { get; set; } diff --git a/Wonky.Client/Pages/PrintCatalogPage.razor.cs b/Wonky.Client/Pages/PrintCatalogPage.razor.cs index a7246b2b..05e994ad 100644 --- a/Wonky.Client/Pages/PrintCatalogPage.razor.cs +++ b/Wonky.Client/Pages/PrintCatalogPage.razor.cs @@ -32,7 +32,7 @@ namespace Wonky.Client.Pages; public partial class PrintCatalogPage : IDisposable { [Inject] public ILocalStorageService Storage { get; set; } - [Inject] public ICatalogHttpRepository ItemRepo { get; set; } + [Inject] public ICatalogCrmHttpRepository ItemRepo { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } private List Items { get; set; } = new(); private UserInfoView UserInfo { get; set; } = new(); diff --git a/Wonky.Client/Pages/QuoteListCrmPage.razor.cs b/Wonky.Client/Pages/QuoteListCrmPage.razor.cs index 556ec6e2..0a52cbae 100644 --- a/Wonky.Client/Pages/QuoteListCrmPage.razor.cs +++ b/Wonky.Client/Pages/QuoteListCrmPage.razor.cs @@ -15,7 +15,7 @@ namespace Wonky.Client.Pages; public partial class QuoteListCrmPage : IDisposable { - [Inject] public ICrmActivityHttpRepository ActivityRepo { get; set; } + [Inject] public IActivityCrmHttpRepository ActivityRepo { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public ILogger Logger { get; set; } [Inject] public IToastService Toaster { get; set; } diff --git a/Wonky.Client/Pages/ReportCreateCrmPage.razor.cs b/Wonky.Client/Pages/ReportCreateCrmPage.razor.cs index 46beacd1..384c3ea4 100644 --- a/Wonky.Client/Pages/ReportCreateCrmPage.razor.cs +++ b/Wonky.Client/Pages/ReportCreateCrmPage.razor.cs @@ -31,8 +31,8 @@ public partial class ReportCreateCrmPage : IDisposable { [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public UserProfileService ProfileService { get; set; } - [Inject] public ICrmActivityHttpRepository CrmActivityRepo { get; set; } - [Inject] public ICrmReportHttpRepository CrmReportRepo { get; set; } + [Inject] public IActivityCrmHttpRepository ActivityRepo { get; set; } + [Inject] public IReportHttpRepository ReportRepo { get; set; } [Inject] public NavigationManager Navigator { get; set; } [Inject] public ILogger Logger { get; set; } [Inject] public IToastService Toaster { get; set; } @@ -130,7 +130,7 @@ public partial class ReportCreateCrmPage : IDisposable return; Working = true; - var result = await CrmReportRepo.PostReport($"{_workDate:yyyy-MM-dd}", Report); + var result = await ReportRepo.CreateReport($"{_workDate:yyyy-MM-dd}", Report); Toaster.ShowInfo($"{result.Message}", $"HTTP Status"); // reset km and date confirmation @@ -250,7 +250,7 @@ public partial class ReportCreateCrmPage : IDisposable InitialValues = new ReportFiguresDto(); Activities = new List(); - var data = await CrmReportRepo.InitializeReportData($"{_workDate:yyyy-MM-dd}"); + var data = await ReportRepo.InitializeReportData($"{_workDate:yyyy-MM-dd}"); if(data.ReportClosed) Navigator.NavigateTo($"/sales-reports/view/{_workDate:yyyy-MM-dd}"); diff --git a/Wonky.Client/Pages/ReportListCrmPage.razor.cs b/Wonky.Client/Pages/ReportListCrmPage.razor.cs index 65c07b1e..c2ffe20b 100644 --- a/Wonky.Client/Pages/ReportListCrmPage.razor.cs +++ b/Wonky.Client/Pages/ReportListCrmPage.razor.cs @@ -24,7 +24,7 @@ namespace Wonky.Client.Pages; public partial class ReportListCrmPage : IDisposable { - [Inject] public ICrmReportHttpRepository ReportRepo { get; set; } + [Inject] public IReportHttpRepository ReportRepo { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public NavigationManager Navigator { get; set; } [Inject] public ILogger Logger { get; set; } diff --git a/Wonky.Client/Pages/ReportListOfficePage.razor.cs b/Wonky.Client/Pages/ReportListOfficePage.razor.cs index d2e990a9..ac62b848 100644 --- a/Wonky.Client/Pages/ReportListOfficePage.razor.cs +++ b/Wonky.Client/Pages/ReportListOfficePage.razor.cs @@ -27,7 +27,7 @@ public partial class ReportListOfficePage : IDisposable { [Parameter] public string UserId { get; set; } = ""; [Parameter] public string CountryCode { get; set; } = ""; - [Inject] public IOfficeReportHttpRepository ReportRepo { get; set; } + [Inject] public IReportHttpRepository ReportRepo { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public IUserHttpRepository UserRepo { get; set; } [Inject] public NavigationManager Navigator { get; set; } @@ -35,6 +35,9 @@ public partial class ReportListOfficePage : IDisposable private bool Working { get; set; } = true; private WebUserInfoView UserInfo { get; set; } = new(); + /// + /// override OnParametersSeAsync + /// protected override async Task OnParametersSetAsync() { Interceptor.RegisterEvent(); @@ -42,13 +45,17 @@ public partial class ReportListOfficePage : IDisposable UserInfo = await UserRepo.GetAdvisorInfo(UserId); - var reports = await ReportRepo.GetReports(UserId); + var reports = await ReportRepo.GetCountryReports(UserId); if (reports.Any()) ActivityReports = reports.OrderByDescending(x => x.ReportDate).ToList(); Working = false; } + /// + /// Callback to shoe the report + /// + /// private void ShowThisReport(string reportDate) { var uri = new Uri(Navigator.Uri); diff --git a/Wonky.Client/Pages/ReportViewCrmPage.razor.cs b/Wonky.Client/Pages/ReportViewCrmPage.razor.cs index dde5d10e..647d2979 100644 --- a/Wonky.Client/Pages/ReportViewCrmPage.razor.cs +++ b/Wonky.Client/Pages/ReportViewCrmPage.razor.cs @@ -26,7 +26,7 @@ namespace Wonky.Client.Pages; public partial class ReportViewCrmPage : IDisposable { [Parameter] public string ReportDate { get; set; } - [Inject] public ICrmReportHttpRepository ReportRepo { get; set; } + [Inject] public IReportHttpRepository ReportRepo { get; set; } [Inject] public NavigationManager Navigator { get; set; } [Inject] public ILocalStorageService Storage { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } diff --git a/Wonky.Client/Pages/ReportViewOfficePage.razor.cs b/Wonky.Client/Pages/ReportViewOfficePage.razor.cs index abb21d03..fb76eb78 100644 --- a/Wonky.Client/Pages/ReportViewOfficePage.razor.cs +++ b/Wonky.Client/Pages/ReportViewOfficePage.razor.cs @@ -40,8 +40,9 @@ public partial class ReportViewOfficePage : IDisposable /// /// Report Date /// - [Parameter] + [Parameter] public string ReportDate { get; set; } = ""; + /// /// Injected interceptor service /// @@ -52,7 +53,7 @@ public partial class ReportViewOfficePage : IDisposable /// Injected administrative report http repo ///
[Inject] - public IOfficeReportHttpRepository ReportRepo { get; set; } + public IReportHttpRepository ReportRepo { get; set; } /// /// Navigation Manager @@ -89,10 +90,10 @@ public partial class ReportViewOfficePage : IDisposable { Interceptor.RegisterEvent(); Interceptor.RegisterBeforeSendEvent(); - + ProfileService.OnChange += ProfileServiceOnOnChange; await ProfileService.SetWorkDate(DateTime.Parse(ReportDate)); - + await FetchUserReport(ReportDate); } @@ -129,35 +130,35 @@ public partial class ReportViewOfficePage : IDisposable } ReportDate = workDate; - + // ensure the browser address bar contains the correct link Navigator.NavigateTo($"/office/users/advisors/{CountryCode}/{UserId}/reports/{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; - + // fetch report - Report = await ReportRepo.GetReport(UserId, workDate); - + Report = await ReportRepo.GetCountryReport(UserId, workDate); + // 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; } @@ -168,7 +169,7 @@ public partial class ReportViewOfficePage : IDisposable Prefs = userPref; Logger.LogDebug("OfficeReportViewPage => ProfileServiceOnOnChange => Prefs.WorkDate <= {}", Prefs.WorkDate); ReportDate = Prefs.WorkDate; - + StateHasChanged(); } diff --git a/Wonky.Client/Pages/TaskItemListCrmPage.razor.cs b/Wonky.Client/Pages/TaskItemListCrmPage.razor.cs index 2af94738..72de9476 100644 --- a/Wonky.Client/Pages/TaskItemListCrmPage.razor.cs +++ b/Wonky.Client/Pages/TaskItemListCrmPage.razor.cs @@ -31,7 +31,7 @@ public partial class TaskItemListCrmPage : IDisposable [Inject] public ILogger Logger { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public NavigationManager Navigator { get; set; } - [Inject] public ICrmTaskItemHttpRepository TaskItemRepo { get; set; } + [Inject] public ITaskItemCrmHttpRepository TaskRepo { get; set; } [Inject] public IToastService Toaster { get; set; } private UserPref Prefs { get; set; } = new(); private string WorkDate { get; set; } = $"{DateTime.Now:yyyy-MM-dd}"; @@ -55,7 +55,7 @@ public partial class TaskItemListCrmPage : IDisposable { Working = true; Toaster.ShowInfo("Vent nogle sekunder for data"); - TaskItems = await TaskItemRepo.GetTaskList(workDate); + TaskItems = await TaskRepo.GetTaskList(workDate); Toaster.ClearAll(); Working = false; diff --git a/Wonky.Client/Pages/TaskItemViewCrmPage.razor.cs b/Wonky.Client/Pages/TaskItemViewCrmPage.razor.cs index 6dd66623..a8800e6b 100644 --- a/Wonky.Client/Pages/TaskItemViewCrmPage.razor.cs +++ b/Wonky.Client/Pages/TaskItemViewCrmPage.razor.cs @@ -28,7 +28,7 @@ public partial class TaskItemViewCrmPage : IDisposable { [Parameter] public string TaskItemId { get; set; } [Inject] public HttpInterceptorService _interceptor { get; set; } - [Inject] public ICrmTaskItemHttpRepository CrmTaskItemRepo { get; set; } + [Inject] public ITaskItemCrmHttpRepository TaskRepo { get; set; } private TaskItemDto _taskItem = new (); private EditContext _editContext { get; set; } private bool Working { get; set; } = true; @@ -39,7 +39,7 @@ public partial class TaskItemViewCrmPage : IDisposable _interceptor.RegisterEvent(); _interceptor.RegisterBeforeSendEvent(); - _taskItem = await CrmTaskItemRepo.GetTaskItem(TaskItemId); + _taskItem = await TaskRepo.GetTaskItem(TaskItemId); Console.WriteLine(JsonSerializer.Serialize(_taskItem)); Working = false; } diff --git a/Wonky.Client/Pages/UserListSalesRepPage.razor.cs b/Wonky.Client/Pages/UserListSalesRepPage.razor.cs index 4b0fed7a..a7118198 100644 --- a/Wonky.Client/Pages/UserListSalesRepPage.razor.cs +++ b/Wonky.Client/Pages/UserListSalesRepPage.razor.cs @@ -29,11 +29,11 @@ public partial class UserListSalesRepPage : IDisposable [Inject] public ILogger Logger { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public IOfficeCustomerHttpRepository CustomerRepo { get; set; } + [Inject] public ICustomerOfficeHttpRepository CustomerRepo { get; set; } [Inject] public UserProfileService UserProfileService { get; set; } private List _companyList { get; set; } = new(); private MetaData _metaData { get; set; } = new(); - private CompanyPagingParams _paging = new(); + private CustomerPaging _paging = new(); private UserPref UserPref { get; set; } = new(); private string _savedSearch { get; set; } = ""; private bool _includeFolded { get; set; } diff --git a/Wonky.Client/Pages/WorkplaceDocumentListPage.razor.cs b/Wonky.Client/Pages/WorkplaceDocumentListPage.razor.cs index 7083f2e9..e9eb19a4 100644 --- a/Wonky.Client/Pages/WorkplaceDocumentListPage.razor.cs +++ b/Wonky.Client/Pages/WorkplaceDocumentListPage.razor.cs @@ -27,7 +27,7 @@ public partial class WorkplaceDocumentListPage [Parameter] public string WorkplaceId { get; set; } = ""; [Inject] public HttpInterceptorService _interceptor { get; set; } - [Inject] public ICrmWorkplaceHttpRepository CrmWorkplaceRepo { get; set; } + [Inject] public IWorkplaceCrmHttpRepository WorkplaceCrmRepo { get; set; } private bool Working { get; set; } = true; } \ No newline at end of file diff --git a/Wonky.Client/Pages/WorkplaceListPage.razor.cs b/Wonky.Client/Pages/WorkplaceListPage.razor.cs index 143fc09b..d1367d51 100644 --- a/Wonky.Client/Pages/WorkplaceListPage.razor.cs +++ b/Wonky.Client/Pages/WorkplaceListPage.razor.cs @@ -27,8 +27,8 @@ namespace Wonky.Client.Pages; public partial class WorkplaceListPage : IDisposable { [Parameter] public string CompanyId { get; set; } = ""; - [Inject] public ICrmWorkplaceHttpRepository CrmWorkplaceRepo { get; set; } - [Inject] public ICrmCompanyHttpRepository _companyRepo { get; set; } + [Inject] public IWorkplaceCrmHttpRepository WorkplaceCrmRepo { get; set; } + [Inject] public ICustomerCrmHttpRepository _companyRepo { get; set; } [Inject] public HttpInterceptorService _interceptor { get; set; } private List _workplaces { get; set; } = new(); private CompanyDto _company { get; set; } = new(); @@ -45,7 +45,7 @@ public partial class WorkplaceListPage : IDisposable protected override async Task OnInitializedAsync() { Working = true; - _workplaces = await CrmWorkplaceRepo.GetWorkplaces(CompanyId); + _workplaces = await WorkplaceCrmRepo.GetWorkplaces(CompanyId); Working = false; } diff --git a/Wonky.Client/Pages/WorkplaceViewPage.razor.cs b/Wonky.Client/Pages/WorkplaceViewPage.razor.cs index 479f2146..c20547c0 100644 --- a/Wonky.Client/Pages/WorkplaceViewPage.razor.cs +++ b/Wonky.Client/Pages/WorkplaceViewPage.razor.cs @@ -29,8 +29,8 @@ public partial class WorkplaceViewPage : IDisposable { [Parameter] public string CompanyId { get; set; } = ""; [Parameter] public string WorkplaceId { get; set; } = ""; - [Inject] public ICrmWorkplaceHttpRepository CrmWorkplaceRepo { get; set; } - [Inject] public ICrmCompanyHttpRepository _companyRepo { get; set; } + [Inject] public IWorkplaceCrmHttpRepository WorkplaceCrmRepo { get; set; } + [Inject] public ICustomerCrmHttpRepository _companyRepo { get; set; } [Inject] public HttpInterceptorService _interceptor { get; set; } [Inject] public NavigationManager _navigator { get; set; } private WorkplaceDto _workplace { get; set; } = new(); @@ -42,7 +42,7 @@ public partial class WorkplaceViewPage : IDisposable _interceptor.RegisterEvent(); _interceptor.RegisterBeforeSendEvent(); - _workplace = await CrmWorkplaceRepo.GetWorkplace(CompanyId, WorkplaceId); + _workplace = await WorkplaceCrmRepo.GetWorkplace(CompanyId, WorkplaceId); Working = false; } @@ -54,14 +54,14 @@ public partial class WorkplaceViewPage : IDisposable private async Task SubmitUpdate() { Working = true; - await CrmWorkplaceRepo.UpdateWorkplace(CompanyId, _workplace); + await WorkplaceCrmRepo.UpdateWorkplace(CompanyId, _workplace); Working = false; } private async Task DeleteWorkplace() { Working = true; - await CrmWorkplaceRepo.DeleteWorkplace(CompanyId, _workplace.WorkplaceId); + await WorkplaceCrmRepo.DeleteWorkplace(CompanyId, _workplace.WorkplaceId); _navigator.NavigateTo($"/companies/{CompanyId}/workplaces"); } diff --git a/Wonky.Client/Program.cs b/Wonky.Client/Program.cs index 013ed6af..7ab56879 100644 --- a/Wonky.Client/Program.cs +++ b/Wonky.Client/Program.cs @@ -54,21 +54,21 @@ builder.Services.Configure(builder.Configuration.GetSection("ApiConfi // app info object builder.Services.Configure(builder.Configuration.GetSection("AppInfo")); // crm 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(); +builder.Services.AddScoped(); // administrative repositories builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); +builder.Services.AddScoped(); +builder.Services.AddScoped(); // warehouse repository builder.Services.AddScoped(); // catalog repository -builder.Services.AddScoped(); +builder.Services.AddScoped(); // mail service builder.Services.AddScoped(); // interceptor diff --git a/Wonky.Client/Shared/ContactModal.razor.cs b/Wonky.Client/Shared/ContactModal.razor.cs index 4cbff697..5c5b685c 100644 --- a/Wonky.Client/Shared/ContactModal.razor.cs +++ b/Wonky.Client/Shared/ContactModal.razor.cs @@ -31,7 +31,7 @@ public partial class ContactModal { [Parameter] public ContactDto ParamContact { get; set; } = new(); [Parameter] public string CompanyName { get; set; } = ""; - [Parameter] public ICrmContactHttpRepository ContactRepo { get; set; } + [Parameter] public IContactCrmHttpRepository ContactRepo { get; set; } [Parameter] public HttpInterceptorService Interceptor { get; set; } [Parameter] public EventCallback OnSaveClicked { get; set; } [Parameter] public EventCallback OnDeleteClicked { get; set; } diff --git a/Wonky.Client/Shared/InventoryReorderModal.razor.cs b/Wonky.Client/Shared/InventoryReorderModal.razor.cs index d2cbdb1a..c257614a 100644 --- a/Wonky.Client/Shared/InventoryReorderModal.razor.cs +++ b/Wonky.Client/Shared/InventoryReorderModal.razor.cs @@ -29,7 +29,7 @@ public partial class InventoryReorderModal { [Parameter] public string CompanyId { get; set; } = ""; [Parameter] public SalesItemView SalesItem { get; set; } = new(); - [Inject] public ICrmHistoryHttpRepository CrmHistoryRepo { get; set; } + [Inject] public ICustomerHistoryCrmHttpRepository CustomerHistoryCrmRepo { get; set; } [Parameter] public EventCallback OnSelected { get; set; } private List? History { get; set; } = new(); private DraftItem SelectedItem { get; set; } = new(); @@ -43,7 +43,7 @@ public partial class InventoryReorderModal if (string.IsNullOrWhiteSpace(SalesItem.Sku)) return; - History = await CrmHistoryRepo.FetchHistory(CompanyId, SalesItem.Sku); + History = await CustomerHistoryCrmRepo.FetchHistory(CompanyId, SalesItem.Sku); if (!History.Any()) await Task.Delay(1000); SelectedItem.Item = SalesItem; diff --git a/Wonky.Client/Shared/InvoiceViewModal.razor.cs b/Wonky.Client/Shared/InvoiceViewModal.razor.cs index 329c7e23..f7e4c396 100644 --- a/Wonky.Client/Shared/InvoiceViewModal.razor.cs +++ b/Wonky.Client/Shared/InvoiceViewModal.razor.cs @@ -30,7 +30,7 @@ public partial class InvoiceViewModal : IDisposable [Parameter] public string CompanyId { get; set; } = ""; [Parameter] public string InvoiceId { get; set; } = ""; [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public ICrmHistoryHttpRepository HistoryRepo { get; set; } + [Inject] public ICustomerHistoryCrmHttpRepository HistoryRepo { get; set; } private string _modalDisplay = ""; private bool _showBackdrop; private InvoiceView Invoice { get; set; } = new(); diff --git a/Wonky.Client/Shared/NavMenu.razor b/Wonky.Client/Shared/NavMenu.razor index a7461b5f..5df0f9d9 100644 --- a/Wonky.Client/Shared/NavMenu.razor +++ b/Wonky.Client/Shared/NavMenu.razor @@ -44,33 +44,22 @@ - + - - - - - - -