diff --git a/src/FrontOffice.Main/App.razor b/src/FrontOffice.Main/App.razor new file mode 100644 index 0000000..d414dad --- /dev/null +++ b/src/FrontOffice.Main/App.razor @@ -0,0 +1,11 @@ + + + + + + Not found + +

Sorry, there's nothing at this address.

+
+
+
diff --git a/src/FrontOffice.Main/ConfigureServices.cs b/src/FrontOffice.Main/ConfigureServices.cs new file mode 100644 index 0000000..4499cd4 --- /dev/null +++ b/src/FrontOffice.Main/ConfigureServices.cs @@ -0,0 +1,68 @@ +using Blazored.LocalStorage; +using Grpc.Core; +using Grpc.Net.Client.Web; +using Grpc.Net.Client; +using MudBlazor.Services; +using System.Text.Json; +using System.Text.Json.Serialization; +using FrontOffice.BFF.Package.Protobuf.Protos.Package; +using FrontOffice.BFF.User.Protobuf.Protos.User; +using FrontOffice.BFF.UserAddress.Protobuf.Protos.UserAddress; +using FrontOffice.BFF.UserOrder.Protobuf.Protos.UserOrder; + +namespace Microsoft.Extensions.DependencyInjection; + +public static class ConfigureServices +{ + public static IServiceCollection AddCommonServices(this IServiceCollection services) + { + services.AddMudServices(); + services.AddBlazoredLocalStorage(config => + { + config.JsonSerializerOptions.DictionaryKeyPolicy = JsonNamingPolicy.CamelCase; + config.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull; + config.JsonSerializerOptions.IgnoreReadOnlyProperties = true; + config.JsonSerializerOptions.PropertyNameCaseInsensitive = true; + config.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; + config.JsonSerializerOptions.ReadCommentHandling = JsonCommentHandling.Skip; + config.JsonSerializerOptions.WriteIndented = false; + }); + return services; + } + + public static IServiceCollection AddGrpcServices(this IServiceCollection services, IConfiguration configuration) + { + var baseUrl = configuration["GwUrl"]; + var httpClient = new HttpClient(new GrpcWebHandler(GrpcWebMode.GrpcWeb, new HttpClientHandler())); + httpClient.Timeout = TimeSpan.FromMinutes(10); // TODO Check Timeout + var serviceProvider = services.BuildServiceProvider(); + var channel = CreateAuthenticatedChannel(baseUrl, httpClient, serviceProvider); + + services.AddSingleton(sp => new PackageContract.PackageContractClient(channel)); + services.AddSingleton(sp => new UserContract.UserContractClient(channel)); + services.AddSingleton(sp => new UserAddressContract.UserAddressContractClient(channel)); + services.AddSingleton(sp => new UserOrderContract.UserOrderContractClient(channel)); + + return services; + } + + private static GrpcChannel CreateAuthenticatedChannel(string address, HttpClient httpClient, IServiceProvider serviceProvider) + { + var credentials = CallCredentials.FromInterceptor(async (context, metadata) => + { + await Task.CompletedTask; + }); + + // SslCredentials is used here because this channel is using TLS. + // CallCredentials can't be used with ChannelCredentials.Insecure on non-TLS channels. + var channel = GrpcChannel.ForAddress(address, new GrpcChannelOptions + { + UnsafeUseInsecureChannelCallCredentials = true, + Credentials = ChannelCredentials.Create(new SslCredentials(), credentials), + HttpClient = httpClient, + MaxReceiveMessageSize = 1000 * 1024 * 1024, // 1 GB + MaxSendMessageSize = 1000 * 1024 * 1024 // 1 GB + }); + return channel; + } +} diff --git a/src/FrontOffice.Main/FrontOffice.Main.csproj b/src/FrontOffice.Main/FrontOffice.Main.csproj new file mode 100644 index 0000000..6a8ab29 --- /dev/null +++ b/src/FrontOffice.Main/FrontOffice.Main.csproj @@ -0,0 +1,25 @@ + + + + net7.0 + enable + enable + + + + + + + + + + + + + + + + + + + diff --git a/src/FrontOffice.Main/Pages/Error.cshtml b/src/FrontOffice.Main/Pages/Error.cshtml new file mode 100644 index 0000000..7ccbe27 --- /dev/null +++ b/src/FrontOffice.Main/Pages/Error.cshtml @@ -0,0 +1,42 @@ +@page +@model FrontOffice.Main.Pages.ErrorModel + + + + + + + + Error + + + + + +
+
+

Error.

+

An error occurred while processing your request.

+ + @if (Model.ShowRequestId) + { +

+ Request ID: @Model.RequestId +

+ } + +

Development Mode

+

+ Swapping to the Development environment displays detailed information about the error that occurred. +

+

+ The Development environment shouldn't be enabled for deployed applications. + It can result in displaying sensitive information from exceptions to end users. + For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development + and restarting the app. +

+
+
+ + + diff --git a/src/FrontOffice.Main/Pages/Error.cshtml.cs b/src/FrontOffice.Main/Pages/Error.cshtml.cs new file mode 100644 index 0000000..798bec1 --- /dev/null +++ b/src/FrontOffice.Main/Pages/Error.cshtml.cs @@ -0,0 +1,25 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using System.Diagnostics; + +namespace FrontOffice.Main.Pages; +[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] +[IgnoreAntiforgeryToken] +public class ErrorModel : PageModel +{ + public string? RequestId { get; set; } + + public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); + + private readonly ILogger _logger; + + public ErrorModel(ILogger logger) + { + _logger = logger; + } + + public void OnGet() + { + RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; + } +} diff --git a/src/FrontOffice.Main/Pages/Index.razor b/src/FrontOffice.Main/Pages/Index.razor new file mode 100644 index 0000000..e039a47 --- /dev/null +++ b/src/FrontOffice.Main/Pages/Index.razor @@ -0,0 +1,7 @@ +@attribute [Route(RouteConstants.Main.MainPage)] + +خانه + +

Hello, world!

+ +Welcome to your new app. diff --git a/src/FrontOffice.Main/Pages/_Host.cshtml b/src/FrontOffice.Main/Pages/_Host.cshtml new file mode 100644 index 0000000..bca9463 --- /dev/null +++ b/src/FrontOffice.Main/Pages/_Host.cshtml @@ -0,0 +1,37 @@ +@page "/" +@using Microsoft.AspNetCore.Components.Web +@namespace FrontOffice.Main.Pages +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers + + + + + + + + + + + + + + + + + + +
+ + یک خطا رخ داده است. این برنامه ممکن است تا زمان بارگذاری مجدد پاسخگو نباشد. + + + خطای مدیریت‌نشده ای اتفاق افتاده است. برای مشاهده جزئیات، ابزار توسعه (DevTools) مرورگر را بررسی نمایید. + + بارگذاری مجدد + 🗙 +
+ + + + + diff --git a/src/FrontOffice.Main/Program.cs b/src/FrontOffice.Main/Program.cs new file mode 100644 index 0000000..36af858 --- /dev/null +++ b/src/FrontOffice.Main/Program.cs @@ -0,0 +1,48 @@ +using FrontOffice.Main.Utilities; + +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. +builder.Services.AddRazorPages(); +builder.Services.AddServerSideBlazor(); + +#region AddCommonServices + +builder.Services.AddCommonServices(); + +#endregion +#region AddGrpcServices + +builder.Services.AddGrpcServices(builder.Configuration); + +#endregion + +var appSettings = builder.Configuration.Get(); +UrlUtility.DownloadUrl = appSettings.DownloadUrl; + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (!app.Environment.IsDevelopment()) +{ + app.UseExceptionHandler("/Error"); + // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. + app.UseHsts(); +} + +app.UseHttpsRedirection(); + +app.UseStaticFiles(); + +app.UseRouting(); + +app.MapBlazorHub(); +app.MapFallbackToPage("/_Host"); + +app.Run(); + + +public class AppSettings +{ + public string DownloadUrl { get; set; } +} diff --git a/src/FrontOffice.Main/Properties/launchSettings.json b/src/FrontOffice.Main/Properties/launchSettings.json new file mode 100644 index 0000000..68643cb --- /dev/null +++ b/src/FrontOffice.Main/Properties/launchSettings.json @@ -0,0 +1,37 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:59107", + "sslPort": 44381 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "http://localhost:5268", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:7080;http://localhost:5268", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/src/FrontOffice.Main/Shared/MainLayout.razor b/src/FrontOffice.Main/Shared/MainLayout.razor new file mode 100644 index 0000000..ac700df --- /dev/null +++ b/src/FrontOffice.Main/Shared/MainLayout.razor @@ -0,0 +1,16 @@ +@inherits LayoutComponentBase + +فرصت + + + + + + + + + @Body + + + + diff --git a/src/FrontOffice.Main/Shared/MainLayout.razor.cs b/src/FrontOffice.Main/Shared/MainLayout.razor.cs new file mode 100644 index 0000000..1676886 --- /dev/null +++ b/src/FrontOffice.Main/Shared/MainLayout.razor.cs @@ -0,0 +1,12 @@ +using Microsoft.JSInterop; +using MudBlazor; + +namespace FrontOffice.Main.Shared; +public partial class MainLayout +{ + private MudThemeProvider _mudThemeProvider; + private async void Back() + { + await JSRuntime.InvokeVoidAsync("history.back"); + } +} \ No newline at end of file diff --git a/src/FrontOffice.Main/Shared/MainLayout.razor.css b/src/FrontOffice.Main/Shared/MainLayout.razor.css new file mode 100644 index 0000000..e7b71e1 --- /dev/null +++ b/src/FrontOffice.Main/Shared/MainLayout.razor.css @@ -0,0 +1,3 @@ +body{ + +} \ No newline at end of file diff --git a/src/FrontOffice.Main/Shared/NavMenu.razor b/src/FrontOffice.Main/Shared/NavMenu.razor new file mode 100644 index 0000000..c59c830 --- /dev/null +++ b/src/FrontOffice.Main/Shared/NavMenu.razor @@ -0,0 +1,39 @@ + + + + +@code { + private bool collapseNavMenu = true; + + private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null; + + private void ToggleNavMenu() + { + collapseNavMenu = !collapseNavMenu; + } +} diff --git a/src/FrontOffice.Main/Utilities/CustomMudTheme.cs b/src/FrontOffice.Main/Utilities/CustomMudTheme.cs new file mode 100644 index 0000000..490f082 --- /dev/null +++ b/src/FrontOffice.Main/Utilities/CustomMudTheme.cs @@ -0,0 +1,182 @@ +using MudBlazor; + +namespace FrontOffice.Main.Utilities; + +public static class CustomMudTheme +{ + public static MudTheme CustomMudBlazorTheme { get; set; } = new() + { + PaletteLight = new PaletteLight() + { + Primary = "#0380C0", + //Secondary = CustomColor.Secondary.Default, + //Tertiary = CustomColor.Tertiary.Default, + + Background = "#F5F5F5", + AppbarBackground = "#F5F5F5", + + //PrimaryContrastText = "#FFFFFF", + //SecondaryContrastText = "#FFFFFF", + //ErrorContrastText = "#FFFFFF", + //SuccessContrastText = "#FFFFFF", + //InfoContrastText = "#FFFFFF", + //WarningContrastText = "#FFFFFF", + TextPrimary = Colors.Gray.Darken3, + + //// TextSecondary = "#FFFFFF", + + //Error = CustomColor.Error.Default, + //ErrorLighten = CustomColor.Error.Error100, + + //// Info = "#3977AD", + //InfoLighten = CustomColor.Info.Lighten, + //InfoDarken = CustomColor.Info.Darken, + + //// Success = "#05AF82", + //SuccessDarken = CustomColor.Success.Darken, + //SuccessLighten = CustomColor.Success.Lighten, + + ////Warning = "#EF7300", + //WarningDarken = CustomColor.Warning.Lighten, + //WarningLighten = CustomColor.Warning.Lighten, + + //BackgroundGrey = CustomColor.Other.Background, + //GrayDefault = CustomColor.Other.Background, + //GrayDark = CustomColor.Gray.Gray10, + //GrayLight = CustomColor.Gray.Gray60, + //GrayLighter = CustomColor.Gray.Gray80, + + + //TextDisabled = CustomColor.Other.DisableText, + //ActionDisabled = CustomColor.Other.DisableText, + //ActionDisabledBackground = CustomColor.Other.DisableBackground, + + Surface = "#FFFFFF", + Divider = "#B2BFCB", + }, + + Typography = new Typography() + { + Default = new Default() + { + FontFamily = new[] { "Vazir" } + }, + //Display/Large + H1 = new H1() + { + FontFamily = new[] { "Vazir" }, + FontSize = "3.5625rem", + LineHeight = 4, + FontWeight = 500, + LetterSpacing = "0" + }, + //Display/Medium + H2 = new H2() + { + FontFamily = new[] { "Vazir" }, + FontSize = "2.8125rem", + LineHeight = 3.25, + FontWeight = 500, + LetterSpacing = "0" + }, + //Display/Small + H3 = new H3() + { + FontFamily = new[] { "Vazir" }, + FontSize = "2.25rem", + LineHeight = 2.75, + FontWeight = 500, + LetterSpacing = "0" + }, + //Headline/Large + H4 = new H4() + { + FontFamily = new[] { "Vazir" }, + FontSize = "2rem", + LineHeight = 2.5, + FontWeight = 600, + LetterSpacing = "0" + }, + //Headline/Medium + H5 = new H5() + { + FontFamily = new[] { "Vazir" }, + FontSize = "1.75rem", + LineHeight = 2.25, + FontWeight = 600, + LetterSpacing = "0" + }, + //Headline/Small + H6 = new H6() + { + FontFamily = new[] { "Vazir" }, + FontSize = "1.5rem", + LineHeight = 2, + FontWeight = 600, + LetterSpacing = "0" + }, + Button = new Button + { + FontFamily = new[] { "Vazir" }, + FontSize = "0.875rem", + LineHeight = 1.75, + FontWeight = 700, + LetterSpacing = "0" + }, + //Body/Large + Body1 = new Body1 + { + FontFamily = new[] { "Vazir" }, + FontSize = "0.875rem", + LineHeight = 1.75, + FontWeight = 400, + LetterSpacing = "0" + }, + //Body/Medium + Body2 = new Body2 + { + FontFamily = new[] { "Vazir" }, + FontSize = "0.875rem", + LineHeight = 1.43, + FontWeight = 400, + LetterSpacing = "0" + }, + //Body/small + Overline = new Overline + { + FontFamily = new[] { "Vazir" }, + FontSize = "0.75rem", + LineHeight = 1.33, + FontWeight = 400, + LetterSpacing = "0" + }, + //Title/Large + Caption = new Caption + { + FontFamily = new[] { "Vazir" }, + FontSize = "1.125rem", + LineHeight = 1.714, + FontWeight = 700, + LetterSpacing = "0" + }, + //Title/medium + Subtitle1 = new Subtitle1 + { + FontFamily = new[] { "Vazir" }, + FontSize = "1rem", + LineHeight = 1.5, + FontWeight = 700, + LetterSpacing = "0.009em" + }, + //Title/small + Subtitle2 = new Subtitle2 + { + FontFamily = new[] { "Vazir" }, + FontSize = "0.875rem", + LineHeight = 1.43, + FontWeight = 700, + LetterSpacing = "0.006em" + } + } + }; +} \ No newline at end of file diff --git a/src/FrontOffice.Main/Utilities/Extensions.cs b/src/FrontOffice.Main/Utilities/Extensions.cs new file mode 100644 index 0000000..be9cd0e --- /dev/null +++ b/src/FrontOffice.Main/Utilities/Extensions.cs @@ -0,0 +1,407 @@ +using System.ComponentModel.DataAnnotations; +using System.Net; +using System.Reflection; +using System.Text.RegularExpressions; +using Google.Protobuf.WellKnownTypes; +using Microsoft.AspNetCore.Components.Forms; + +namespace FrontOffice.Main.Utilities; + +public static class Extensions +{ + public static string ExtractUserFriendlyMessage(this string errorMessage) + { + // کلیدواژه‌ای که بعد از آن بخش مورد نظر شروع می‌شود + string keyword = "Exception:"; + + // بررسی وجود کلیدواژه در پیام خطا + int keywordIndex = errorMessage.IndexOf(keyword); + + if (keywordIndex >= 0) + { + // استخراج بخش بعد از کلیدواژه + string userFriendlyMessage = errorMessage.Substring(keywordIndex + keyword.Length).Trim(); + if (userFriendlyMessage.EndsWith(")")) + { + userFriendlyMessage = userFriendlyMessage.Substring(0, userFriendlyMessage.Length - 2); + } + return userFriendlyMessage; + } + + // اگر کلیدواژه وجود نداشت، کل پیام خطا برگردانده شود + return errorMessage; + } + public static string DiffDateTime(this DateTime dateTime) + { + const int SECOND = 1; + const int MINUTE = 60 * SECOND; + const int HOUR = 60 * MINUTE; + const int DAY = 24 * HOUR; + const int MONTH = 30 * DAY; + var ts = new TimeSpan(DateTime.Now.Ticks - dateTime.Ticks); + double delta = Math.Abs(ts.TotalSeconds); + if (delta < 1 * MINUTE) + { + return ts.Seconds == 1 ? "لحظه ای قبل" : ts.Seconds + " ثانیه قبل"; + } + if (delta < 2 * MINUTE) + { + return "یک دقیقه قبل"; + } + if (delta < 45 * MINUTE) + { + return ts.Minutes + " دقیقه قبل"; + } + if (delta < 90 * MINUTE) + { + return "یک ساعت قبل"; + } + if (delta < 24 * HOUR) + { + return ts.Hours + " ساعت قبل"; + } + if (delta < 48 * HOUR) + { + return "دیروز"; + } + if (delta < 30 * DAY) + { + return ts.Days + " روز قبل"; + } + if (delta < 12 * MONTH) + { + int months = Convert.ToInt32(Math.Floor((double)ts.Days / 30)); + return months <= 1 ? "یک ماه قبل" : months + " ماه قبل"; + } + int years = Convert.ToInt32(Math.Floor((double)ts.Days / 365)); + return years <= 1 ? "یک سال قبل" : years + " سال قبل"; + } + public static string StripHtmlTags(this string html) + { + if (string.IsNullOrEmpty(html)) + return string.Empty; + + // حذف تمامی تگ‌های HTML + string textOnly = Regex.Replace(html, "<.*?>", string.Empty); + + // تبدیل کاراکترهای HTML به متن معمولی (مثلاً   -> فضای خالی) + textOnly = WebUtility.HtmlDecode(textOnly); + + return textOnly.Trim(); + } + public static string ConfuseId(this string? value) + { + if (!string.IsNullOrWhiteSpace(value) && value.Length > 6) + return string.Concat(value[..3], "*****", value.AsSpan(value.Length - 3, 3)); + else if (!string.IsNullOrWhiteSpace(value) && value.Length > 4) + return string.Concat(value[..2], "*****", value.AsSpan(value.Length - 2, 2)); + else + return value; + } + public static Timestamp DateTimeToTimestamp(this DateTime dateTime) + { + return Timestamp.FromDateTime(DateTime.SpecifyKind(dateTime, DateTimeKind.Utc)); + } + public static Timestamp? DateTimeToTimestamp(this DateTime? dateTime) + { + if (dateTime == null) + return null; + + return Timestamp.FromDateTime(DateTime.SpecifyKind(dateTime.Value, DateTimeKind.Utc)); + } + //public static string ToThousands(this string numberString) + //{ + // if (double.TryParse(numberString, out var number)) + // { + // return string.Format("{0:#,###0.################}", number); + // } + + // return numberString; + //} + + public static string ToThousands(this string numberString) + { + if (double.TryParse(numberString, out var number)) + { + // حذف اعشار + var integerPart = Math.Truncate(number); + + // فرمت‌بندی سه رقمی + return string.Format("{0:#,###0}", integerPart); + } + else + { + if (numberString.Split('.').Length > 1) + return numberString.Split('.')[0]; + } + + return numberString; + } + public static string ToThousands(this long number) + { + return number.ToString().ToThousands(); + } + + public static string ToThousands(this long? number) + { + return number?.ToString().ToThousands(); + } + + public static string ToThousands(this int number) + { + return number.ToString().ToThousands(); + } + + public static string ToThousands(this int? number) + { + return number?.ToString().ToThousands(); + } + + public static string ToThousands(this float number) + { + return number.ToString().ToThousands(); + } + public static string ToThousands(this float? number) + { + return number?.ToString().ToThousands(); + } + + public static string ToThousands(this double number) + { + return number.ToString().ToThousands(); + } + + public static string ToThousands(this double? number) + { + return number?.ToString().ToThousands(); + } + public static long ToIRT(this long number) + { + return (long)(number * 0.1); + } + public static string ToCurrencyUnitIRR(this string str) => str + " ریال"; + public static string ToCurrencyUnitIRT(this string str) => str + " تومان"; + public static string FaToAr(this string str) => str.Replace("ک", "ك").Replace("ی", "ي"); + public static string ArToFa(this string str) => str.Replace("ك", "ک").Replace("ي", "ی"); + + public static string Truncate(this string value, int maxLength, bool isAppendDots = false) + { + if (string.IsNullOrEmpty(value)) return value; + return value.Length <= maxLength ? value : isAppendDots ? value.Substring(0, maxLength) + "..." : value.Substring(0, maxLength); + } + + public static string PersianToEnglish(this string persianStr) + { + return persianStr.Replace("۰", "0") + .Replace("۱", "1") + .Replace("۲", "2") + .Replace("۳", "3") + .Replace("۴", "4") + .Replace("۵", "5") + .Replace("۶", "6") + .Replace("۷", "7") + .Replace("۸", "8") + .Replace("۹", "9"); + } + + public static string GetDisplayName(this System.Enum enumValue) + { + return enumValue.GetType() + .GetMember(enumValue.ToString()) + .First() + .GetCustomAttribute() + .GetName(); + } + + public static async Task ConvertIBrowserFileToBase64(this IBrowserFile? file) + { + if (file == null) + { + return string.Empty; + } + + const long maxAllowedSize = 1024 * 1024 * 200; + var imageBuffers = new byte[file.Size]; + using (var stream = file.OpenReadStream(maxAllowedSize)) + { + await stream.ReadAsync(imageBuffers); + } + return $"data:{file.ContentType};base64," + Convert.ToBase64String(imageBuffers); + } + + public static string GetNumberToPersianString(this string txt) + { + string RET = " ", STRVA = " "; + string[] MainStr = STR_To_Int(txt); + int Q = 0; + for (int i = MainStr.Length - 1; i >= 0; i--) + { + STRVA = " "; + if (RET != " " && RET != null) + STRVA = " و "; + if (string.IsNullOrWhiteSpace(Convert_STR(GETCountStr(MainStr[i]), Q))) + RET = Convert_STR(GETCountStr(MainStr[i]), Q) + RET; + else + RET = Convert_STR(GETCountStr(MainStr[i]), Q) + STRVA + RET; + + Q++; + } + + if (RET == " " || RET == null || RET == " ") + RET = "صفر"; + return RET; + } + private static string[] STR_To_Int(string STR) + { + STR = GETCountStr(STR); + string[] RET = new string[STR.Length / 3]; + int Q = 0; + for (int I = 0; I < STR.Length; I += 3) + { + RET[Q] = STR.Substring(I, 3); + Q++; + } + + return RET; + } + + private static string GETCountStr(string STR) + { + string RET = STR; + int LEN = (STR.Length / 3 + 1) * 3 - STR.Length; + if (LEN < 3) + { + for (int i = 0; i < LEN; i++) + { + RET = "0" + RET; + } + } + + if (RET == "") + return "000"; + return RET; + } + + private static string Convert_STR(string INT, int Count) + { + string RET = ""; + //یک صد + if (Count == 0) + { + if (INT.Substring(1, 1) == "1" && INT.Substring(2, 1) != "0") + { + RET = GET_Number(3, Convert.ToInt32(INT.Substring(0, 1)), " ") + GET_Number(1, Convert.ToInt32(INT.Substring(2, 1)), ""); + } + else + { + string STR = GET_Number(0, Convert.ToInt32(INT.Substring(2, 1)), ""); + RET = GET_Number(3, Convert.ToInt32(INT.Substring(0, 1)), GET_Number(2, Convert.ToInt32(INT.Substring(1, 1)), "") + STR) + GET_Number(2, Convert.ToInt32(INT.Substring(1, 1)), STR) + GET_Number(0, Convert.ToInt32(INT.Substring(2, 1)), ""); + } + } + //هزار + else if (Count == 1) + { + RET = Convert_STR(INT, 0); + if (string.IsNullOrWhiteSpace(RET)) + return string.Empty; + RET += " هزار"; + } + //میلیون + else if (Count == 2) + { + RET = Convert_STR(INT, 0); + if (string.IsNullOrWhiteSpace(RET)) + return string.Empty; + RET += " میلیون"; + } + //میلیارد + else if (Count == 3) + { + RET = Convert_STR(INT, 0); + if (string.IsNullOrWhiteSpace(RET)) + return string.Empty; + RET += " میلیارد"; + } + //میلیارد + else if (Count == 4) + { + RET = Convert_STR(INT, 0); + if (string.IsNullOrWhiteSpace(RET)) + return string.Empty; + RET += " تیلیارد"; + } + //میلیارد + else if (Count == 5) + { + RET = Convert_STR(INT, 0); + if (string.IsNullOrWhiteSpace(RET)) + return string.Empty; + RET += " بیلیارد"; + } + else + { + RET = Convert_STR(INT, 0); + if (string.IsNullOrWhiteSpace(RET)) + return string.Empty; + RET += Count.ToString(); + } + + return RET; + } + + private static string GET_Number(int Count, int Number, string VA) + { + string RET = ""; + + if (VA != "" && VA != null) + { + VA = " و "; + } + + if (Count == 0 || Count == 1) + { + bool IsDah = Convert.ToBoolean(Count); + string[] MySTR = new string[10]; + MySTR[1] = IsDah ? "یازده" : "یک" + VA; + MySTR[2] = IsDah ? "دوازده" : "دو" + VA; + MySTR[3] = IsDah ? "سیزده" : "سه" + VA; + MySTR[4] = IsDah ? "چهارده" : "چهار" + VA; + MySTR[5] = IsDah ? "پانزده" : "پنج" + VA; + MySTR[6] = IsDah ? "شانزده" : "شش" + VA; + MySTR[7] = IsDah ? "هفده" : "هفت" + VA; + MySTR[8] = IsDah ? "هجده" : "هشت" + VA; + MySTR[9] = IsDah ? "نوزده" : "نه" + VA; + return MySTR[Number]; + } + else if (Count == 2) + { + string[] MySTR = new string[10]; + MySTR[1] = "ده"; + MySTR[2] = "بیست" + VA; + MySTR[3] = "سی" + VA; + MySTR[4] = "چهل" + VA; + MySTR[5] = "پنجاه" + VA; + MySTR[6] = "شصت" + VA; + MySTR[7] = "هفتاد" + VA; + MySTR[8] = "هشتاد" + VA; + MySTR[9] = "نود" + VA; + return MySTR[Number]; + } + else if (Count == 3) + { + string[] MySTR = new string[10]; + MySTR[1] = "یکصد" + VA; + MySTR[2] = "دویست" + VA; + MySTR[3] = "سیصد" + VA; + MySTR[4] = "چهارصد" + VA; + MySTR[5] = "پانصد" + VA; + MySTR[6] = "ششصد" + VA; + MySTR[7] = "هفتصد" + VA; + MySTR[8] = "هشتصد" + VA; + MySTR[9] = "نهصد" + VA; + return MySTR[Number]; + } + + return RET; + } +} \ No newline at end of file diff --git a/src/FrontOffice.Main/Utilities/GlobalConstants.cs b/src/FrontOffice.Main/Utilities/GlobalConstants.cs new file mode 100644 index 0000000..94821a8 --- /dev/null +++ b/src/FrontOffice.Main/Utilities/GlobalConstants.cs @@ -0,0 +1,9 @@ +namespace FrontOffice.Main.Utilities; + +public static class GlobalConstants +{ + public const string DateFormat = "MMM dd, yyyy"; + public const string DateTimeFormat = "MMM dd, yyyy - HH:mm"; + public const string SuccessMsg = "با موفقیت انجام شد"; + +} \ No newline at end of file diff --git a/src/FrontOffice.Main/Utilities/RouteConstants.cs b/src/FrontOffice.Main/Utilities/RouteConstants.cs new file mode 100644 index 0000000..f82b596 --- /dev/null +++ b/src/FrontOffice.Main/Utilities/RouteConstants.cs @@ -0,0 +1,9 @@ +namespace FrontOffice.Main.Utilities; + +public static class RouteConstants +{ + public static class Main + { + public const string MainPage = "/"; + } +} \ No newline at end of file diff --git a/src/FrontOffice.Main/Utilities/UrlUtility.cs b/src/FrontOffice.Main/Utilities/UrlUtility.cs new file mode 100644 index 0000000..ae03683 --- /dev/null +++ b/src/FrontOffice.Main/Utilities/UrlUtility.cs @@ -0,0 +1,6 @@ +namespace FrontOffice.Main.Utilities; + +public static class UrlUtility +{ + public static string DownloadUrl { get; set; } +} \ No newline at end of file diff --git a/src/FrontOffice.Main/_Imports.razor b/src/FrontOffice.Main/_Imports.razor new file mode 100644 index 0000000..50c7a9a --- /dev/null +++ b/src/FrontOffice.Main/_Imports.razor @@ -0,0 +1,18 @@ +@using System.Net.Http +@using Microsoft.AspNetCore.Authorization +@using Microsoft.AspNetCore.Components.Authorization +@using Microsoft.AspNetCore.Components.Forms +@using Microsoft.AspNetCore.Components.Routing +@using Microsoft.AspNetCore.Components.Web +@using Microsoft.AspNetCore.Components.Web.Virtualization +@using Microsoft.JSInterop +@using FrontOffice.Main +@using FrontOffice.Main.Shared +@using MudBlazor +@using FrontOffice.Main.Utilities + + +@inject NavigationManager Navigation +@inject IDialogService DialogService +@inject IJSRuntime JSRuntime +@inject ISnackbar Snackbar \ No newline at end of file diff --git a/src/FrontOffice.Main/appsettings.Development.json b/src/FrontOffice.Main/appsettings.Development.json new file mode 100644 index 0000000..770d3e9 --- /dev/null +++ b/src/FrontOffice.Main/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "DetailedErrors": true, + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/src/FrontOffice.Main/appsettings.json b/src/FrontOffice.Main/appsettings.json new file mode 100644 index 0000000..f6fae33 --- /dev/null +++ b/src/FrontOffice.Main/appsettings.json @@ -0,0 +1,12 @@ +{ + //"GwUrl": "https://afrinogw.afrino.co", + "GwUrl": "https://localhost:34781", + "DownloadUrl": "https://dl.afrino.co", + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/src/FrontOffice.Main/wwwroot/css/site.css b/src/FrontOffice.Main/wwwroot/css/site.css new file mode 100644 index 0000000..84dc842 --- /dev/null +++ b/src/FrontOffice.Main/wwwroot/css/site.css @@ -0,0 +1,42 @@ +/*#region Fonts*/ + +@font-face { + font-family: 'Vazir'; + font-style: normal; + font-weight: 300; + font-display: swap; + src: url(../fonts/Vazir-Light.ttf) format('woff2'); +} + +@font-face { + font-family: 'Vazir'; + font-style: normal; + font-weight: 400; + font-display: swap; + src: url(../fonts/Vazir-Regular.ttf) format('woff2'); +} + +@font-face { + font-family: 'Vazir'; + font-style: normal; + font-weight: 500; + font-display: swap; + src: url(../fonts/Vazir-Medium.ttf) format('woff2'); +} + +@font-face { + font-family: 'Vazir'; + font-style: normal; + font-weight: 700; + font-display: swap; + src: url(../fonts/Vazir-Bold.ttf) format('woff2'); +} + +@font-face { + font-family: 'Vazir'; + font-style: normal; + font-weight: 900; + font-display: swap; + src: url(../fonts/Vazir-Bold.ttf) format('woff2'); +} +/*#endregion*/ diff --git a/src/FrontOffice.Main/wwwroot/favicon.png b/src/FrontOffice.Main/wwwroot/favicon.png new file mode 100644 index 0000000..8422b59 Binary files /dev/null and b/src/FrontOffice.Main/wwwroot/favicon.png differ diff --git a/src/FrontOffice.Main/wwwroot/fonts/Vazir-Bold.ttf b/src/FrontOffice.Main/wwwroot/fonts/Vazir-Bold.ttf new file mode 100644 index 0000000..5d1a81b Binary files /dev/null and b/src/FrontOffice.Main/wwwroot/fonts/Vazir-Bold.ttf differ diff --git a/src/FrontOffice.Main/wwwroot/fonts/Vazir-Light.ttf b/src/FrontOffice.Main/wwwroot/fonts/Vazir-Light.ttf new file mode 100644 index 0000000..e236769 Binary files /dev/null and b/src/FrontOffice.Main/wwwroot/fonts/Vazir-Light.ttf differ diff --git a/src/FrontOffice.Main/wwwroot/fonts/Vazir-Medium.ttf b/src/FrontOffice.Main/wwwroot/fonts/Vazir-Medium.ttf new file mode 100644 index 0000000..15016eb Binary files /dev/null and b/src/FrontOffice.Main/wwwroot/fonts/Vazir-Medium.ttf differ diff --git a/src/FrontOffice.Main/wwwroot/fonts/Vazir-Regular.ttf b/src/FrontOffice.Main/wwwroot/fonts/Vazir-Regular.ttf new file mode 100644 index 0000000..42c6a36 Binary files /dev/null and b/src/FrontOffice.Main/wwwroot/fonts/Vazir-Regular.ttf differ diff --git a/src/FrontOffice.Main/wwwroot/fonts/Vazir-Thin.ttf b/src/FrontOffice.Main/wwwroot/fonts/Vazir-Thin.ttf new file mode 100644 index 0000000..8ecc6ca Binary files /dev/null and b/src/FrontOffice.Main/wwwroot/fonts/Vazir-Thin.ttf differ diff --git a/src/FrontOffice.sln b/src/FrontOffice.sln new file mode 100644 index 0000000..03dd620 --- /dev/null +++ b/src/FrontOffice.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FrontOffice.Main", "FrontOffice.Main\FrontOffice.Main.csproj", "{D9407E46-027D-4D44-B9FB-1F8DECB14270}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D9407E46-027D-4D44-B9FB-1F8DECB14270}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D9407E46-027D-4D44-B9FB-1F8DECB14270}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D9407E46-027D-4D44-B9FB-1F8DECB14270}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D9407E46-027D-4D44-B9FB-1F8DECB14270}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal