Shady nagy/net6 (#614)
* udated to .net6 * used the .net6 version RC2 * added editconfig. * App core new Scoped Namespaces style. * BlazorAdmin new Scoped Namespaces style. * Blazor Shared new Scoped Namespaces style. * Infra new Scoped Namespaces style. * public api new Scoped Namespaces style. * web new Scoped Namespaces style. * FunctionalTests new Scoped Namespaces style. * Integrational tests new Scoped Namespaces style. * unit tests new Scoped Namespaces style. * update github action. * update github action. * change the global.
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
using System;
|
||||
|
||||
namespace BlazorShared.Attributes
|
||||
namespace BlazorShared.Attributes;
|
||||
|
||||
public class EndpointAttribute : Attribute
|
||||
{
|
||||
public class EndpointAttribute : Attribute
|
||||
{
|
||||
public string Name { get; set; }
|
||||
}
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
namespace BlazorShared.Authorization
|
||||
namespace BlazorShared.Authorization;
|
||||
|
||||
public class ClaimValue
|
||||
{
|
||||
public class ClaimValue
|
||||
public ClaimValue()
|
||||
{
|
||||
public ClaimValue()
|
||||
{
|
||||
}
|
||||
|
||||
public ClaimValue(string type, string value)
|
||||
{
|
||||
Type = type;
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public string Type { get; set; }
|
||||
public string Value { get; set; }
|
||||
}
|
||||
|
||||
public ClaimValue(string type, string value)
|
||||
{
|
||||
Type = type;
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public string Type { get; set; }
|
||||
public string Value { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
namespace BlazorShared.Authorization
|
||||
namespace BlazorShared.Authorization;
|
||||
|
||||
public static class Constants
|
||||
{
|
||||
public static class Constants
|
||||
public static class Roles
|
||||
{
|
||||
public static class Roles
|
||||
{
|
||||
public const string ADMINISTRATORS = "Administrators";
|
||||
}
|
||||
public const string ADMINISTRATORS = "Administrators";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BlazorShared.Authorization
|
||||
namespace BlazorShared.Authorization;
|
||||
|
||||
public class UserInfo
|
||||
{
|
||||
public class UserInfo
|
||||
{
|
||||
public static readonly UserInfo Anonymous = new UserInfo();
|
||||
public bool IsAuthenticated { get; set; }
|
||||
public string NameClaimType { get; set; }
|
||||
public string RoleClaimType { get; set; }
|
||||
public string Token { get; set; }
|
||||
public IEnumerable<ClaimValue> Claims { get; set; }
|
||||
}
|
||||
public static readonly UserInfo Anonymous = new UserInfo();
|
||||
public bool IsAuthenticated { get; set; }
|
||||
public string NameClaimType { get; set; }
|
||||
public string RoleClaimType { get; set; }
|
||||
public string Token { get; set; }
|
||||
public IEnumerable<ClaimValue> Claims { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
namespace BlazorShared
|
||||
{
|
||||
public class BaseUrlConfiguration
|
||||
{
|
||||
public const string CONFIG_NAME = "baseUrls";
|
||||
namespace BlazorShared;
|
||||
|
||||
public string ApiBase { get; set; }
|
||||
public string WebBase { get; set; }
|
||||
}
|
||||
public class BaseUrlConfiguration
|
||||
{
|
||||
public const string CONFIG_NAME = "baseUrls";
|
||||
|
||||
public string ApiBase { get; set; }
|
||||
public string WebBase { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RootNamespace>BlazorShared</RootNamespace>
|
||||
<AssemblyName>BlazorShared</AssemblyName>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -2,15 +2,14 @@
|
||||
using System.Threading.Tasks;
|
||||
using BlazorShared.Models;
|
||||
|
||||
namespace BlazorShared.Interfaces
|
||||
namespace BlazorShared.Interfaces;
|
||||
|
||||
public interface ICatalogItemService
|
||||
{
|
||||
public interface ICatalogItemService
|
||||
{
|
||||
Task<CatalogItem> Create(CreateCatalogItemRequest catalogItem);
|
||||
Task<CatalogItem> Edit(CatalogItem catalogItem);
|
||||
Task<string> Delete(int id);
|
||||
Task<CatalogItem> GetById(int id);
|
||||
Task<List<CatalogItem>> ListPaged(int pageSize);
|
||||
Task<List<CatalogItem>> List();
|
||||
}
|
||||
Task<CatalogItem> Create(CreateCatalogItemRequest catalogItem);
|
||||
Task<CatalogItem> Edit(CatalogItem catalogItem);
|
||||
Task<string> Delete(int id);
|
||||
Task<CatalogItem> GetById(int id);
|
||||
Task<List<CatalogItem>> ListPaged(int pageSize);
|
||||
Task<List<CatalogItem>> List();
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
using BlazorShared.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using BlazorShared.Models;
|
||||
|
||||
namespace BlazorShared.Interfaces
|
||||
namespace BlazorShared.Interfaces;
|
||||
|
||||
public interface ICatalogLookupDataService<TLookupData> where TLookupData : LookupData
|
||||
{
|
||||
public interface ICatalogLookupDataService<TLookupData> where TLookupData : LookupData
|
||||
{
|
||||
Task<List<TLookupData>> List();
|
||||
}
|
||||
Task<List<TLookupData>> List();
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
using BlazorShared.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using BlazorShared.Models;
|
||||
|
||||
namespace BlazorShared.Interfaces
|
||||
namespace BlazorShared.Interfaces;
|
||||
|
||||
public interface ILookupDataResponse<TLookupData> where TLookupData : LookupData
|
||||
{
|
||||
public interface ILookupDataResponse<TLookupData> where TLookupData : LookupData
|
||||
{
|
||||
List<TLookupData> List { get; set; }
|
||||
}
|
||||
List<TLookupData> List { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
using BlazorShared.Attributes;
|
||||
|
||||
namespace BlazorShared.Models
|
||||
namespace BlazorShared.Models;
|
||||
|
||||
[Endpoint(Name = "catalog-brands")]
|
||||
public class CatalogBrand : LookupData
|
||||
{
|
||||
[Endpoint(Name = "catalog-brands")]
|
||||
public class CatalogBrand : LookupData
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
using BlazorShared.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
using BlazorShared.Interfaces;
|
||||
|
||||
namespace BlazorShared.Models
|
||||
namespace BlazorShared.Models;
|
||||
|
||||
public class CatalogBrandResponse : ILookupDataResponse<CatalogBrand>
|
||||
{
|
||||
public class CatalogBrandResponse : ILookupDataResponse<CatalogBrand>
|
||||
{
|
||||
[JsonPropertyName("CatalogBrands")]
|
||||
public List<CatalogBrand> List { get; set; } = new List<CatalogBrand>();
|
||||
}
|
||||
[JsonPropertyName("CatalogBrands")]
|
||||
public List<CatalogBrand> List { get; set; } = new List<CatalogBrand>();
|
||||
}
|
||||
|
||||
@@ -4,85 +4,84 @@ using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using BlazorInputFile;
|
||||
|
||||
namespace BlazorShared.Models
|
||||
namespace BlazorShared.Models;
|
||||
|
||||
public class CatalogItem
|
||||
{
|
||||
public class CatalogItem
|
||||
public int Id { get; set; }
|
||||
|
||||
public int CatalogTypeId { get; set; }
|
||||
public string CatalogType { get; set; } = "NotSet";
|
||||
|
||||
public int CatalogBrandId { get; set; }
|
||||
public string CatalogBrand { get; set; } = "NotSet";
|
||||
|
||||
[Required(ErrorMessage = "The Name field is required")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "The Description field is required")]
|
||||
public string Description { get; set; }
|
||||
|
||||
// decimal(18,2)
|
||||
[RegularExpression(@"^\d+(\.\d{0,2})*$", ErrorMessage = "The field Price must be a positive number with maximum two decimals.")]
|
||||
[Range(0.01, 1000)]
|
||||
[DataType(DataType.Currency)]
|
||||
public decimal Price { get; set; }
|
||||
|
||||
public string PictureUri { get; set; }
|
||||
public string PictureBase64 { get; set; }
|
||||
public string PictureName { get; set; }
|
||||
|
||||
private const int ImageMaximumBytes = 512000;
|
||||
|
||||
public static string IsValidImage(string pictureName, string pictureBase64)
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public int CatalogTypeId { get; set; }
|
||||
public string CatalogType { get; set; } = "NotSet";
|
||||
|
||||
public int CatalogBrandId { get; set; }
|
||||
public string CatalogBrand { get; set; } = "NotSet";
|
||||
|
||||
[Required(ErrorMessage = "The Name field is required")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "The Description field is required")]
|
||||
public string Description { get; set; }
|
||||
|
||||
// decimal(18,2)
|
||||
[RegularExpression(@"^\d+(\.\d{0,2})*$", ErrorMessage = "The field Price must be a positive number with maximum two decimals.")]
|
||||
[Range(0.01, 1000)]
|
||||
[DataType(DataType.Currency)]
|
||||
public decimal Price { get; set; }
|
||||
|
||||
public string PictureUri { get; set; }
|
||||
public string PictureBase64 { get; set; }
|
||||
public string PictureName { get; set; }
|
||||
|
||||
private const int ImageMaximumBytes = 512000;
|
||||
|
||||
public static string IsValidImage(string pictureName, string pictureBase64)
|
||||
if (string.IsNullOrEmpty(pictureBase64))
|
||||
{
|
||||
if (string.IsNullOrEmpty(pictureBase64))
|
||||
{
|
||||
return "File not found!";
|
||||
}
|
||||
var fileData = Convert.FromBase64String(pictureBase64);
|
||||
return "File not found!";
|
||||
}
|
||||
var fileData = Convert.FromBase64String(pictureBase64);
|
||||
|
||||
if (fileData.Length <= 0)
|
||||
{
|
||||
return "File length is 0!";
|
||||
}
|
||||
|
||||
if (fileData.Length > ImageMaximumBytes)
|
||||
{
|
||||
return "Maximum length is 512KB";
|
||||
}
|
||||
|
||||
if (!IsExtensionValid(pictureName))
|
||||
{
|
||||
return "File is not image";
|
||||
}
|
||||
|
||||
return null;
|
||||
if (fileData.Length <= 0)
|
||||
{
|
||||
return "File length is 0!";
|
||||
}
|
||||
|
||||
public static async Task<string> DataToBase64(IFileListEntry fileItem)
|
||||
if (fileData.Length > ImageMaximumBytes)
|
||||
{
|
||||
using ( var reader = new StreamReader(fileItem.Data))
|
||||
{
|
||||
using (var memStream = new MemoryStream())
|
||||
{
|
||||
await reader.BaseStream.CopyToAsync(memStream);
|
||||
var fileData = memStream.ToArray();
|
||||
var encodedBase64 = Convert.ToBase64String(fileData);
|
||||
|
||||
return encodedBase64;
|
||||
}
|
||||
}
|
||||
return "Maximum length is 512KB";
|
||||
}
|
||||
|
||||
private static bool IsExtensionValid(string fileName)
|
||||
if (!IsExtensionValid(pictureName))
|
||||
{
|
||||
var extension = Path.GetExtension(fileName);
|
||||
return "File is not image";
|
||||
}
|
||||
|
||||
return string.Equals(extension, ".jpg", StringComparison.OrdinalIgnoreCase) ||
|
||||
string.Equals(extension, ".png", StringComparison.OrdinalIgnoreCase) ||
|
||||
string.Equals(extension, ".gif", StringComparison.OrdinalIgnoreCase) ||
|
||||
string.Equals(extension, ".jpeg", StringComparison.OrdinalIgnoreCase);
|
||||
return null;
|
||||
}
|
||||
|
||||
public static async Task<string> DataToBase64(IFileListEntry fileItem)
|
||||
{
|
||||
using (var reader = new StreamReader(fileItem.Data))
|
||||
{
|
||||
using (var memStream = new MemoryStream())
|
||||
{
|
||||
await reader.BaseStream.CopyToAsync(memStream);
|
||||
var fileData = memStream.ToArray();
|
||||
var encodedBase64 = Convert.ToBase64String(fileData);
|
||||
|
||||
return encodedBase64;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsExtensionValid(string fileName)
|
||||
{
|
||||
var extension = Path.GetExtension(fileName);
|
||||
|
||||
return string.Equals(extension, ".jpg", StringComparison.OrdinalIgnoreCase) ||
|
||||
string.Equals(extension, ".png", StringComparison.OrdinalIgnoreCase) ||
|
||||
string.Equals(extension, ".gif", StringComparison.OrdinalIgnoreCase) ||
|
||||
string.Equals(extension, ".jpeg", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
using BlazorShared.Attributes;
|
||||
|
||||
namespace BlazorShared.Models
|
||||
namespace BlazorShared.Models;
|
||||
|
||||
[Endpoint(Name = "catalog-types")]
|
||||
public class CatalogType : LookupData
|
||||
{
|
||||
[Endpoint(Name = "catalog-types")]
|
||||
public class CatalogType : LookupData
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
using BlazorShared.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
using BlazorShared.Interfaces;
|
||||
|
||||
namespace BlazorShared.Models
|
||||
namespace BlazorShared.Models;
|
||||
|
||||
public class CatalogTypeResponse : ILookupDataResponse<CatalogType>
|
||||
{
|
||||
public class CatalogTypeResponse : ILookupDataResponse<CatalogType>
|
||||
{
|
||||
|
||||
[JsonPropertyName("CatalogTypes")]
|
||||
public List<CatalogType> List { get; set; } = new List<CatalogType>();
|
||||
}
|
||||
[JsonPropertyName("CatalogTypes")]
|
||||
public List<CatalogType> List { get; set; } = new List<CatalogType>();
|
||||
}
|
||||
|
||||
@@ -1,28 +1,27 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace BlazorShared.Models
|
||||
namespace BlazorShared.Models;
|
||||
|
||||
public class CreateCatalogItemRequest
|
||||
{
|
||||
public class CreateCatalogItemRequest
|
||||
{
|
||||
public int CatalogTypeId { get; set; }
|
||||
public int CatalogTypeId { get; set; }
|
||||
|
||||
public int CatalogBrandId { get; set; }
|
||||
public int CatalogBrandId { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "The Name field is required")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
[Required(ErrorMessage = "The Name field is required")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
[Required(ErrorMessage = "The Description field is required")]
|
||||
public string Description { get; set; } = string.Empty;
|
||||
[Required(ErrorMessage = "The Description field is required")]
|
||||
public string Description { get; set; } = string.Empty;
|
||||
|
||||
// decimal(18,2)
|
||||
[RegularExpression(@"^\d+(\.\d{0,2})*$", ErrorMessage = "The field Price must be a positive number with maximum two decimals.")]
|
||||
[Range(0.01, 1000)]
|
||||
[DataType(DataType.Currency)]
|
||||
public decimal Price { get; set; } = 0;
|
||||
// decimal(18,2)
|
||||
[RegularExpression(@"^\d+(\.\d{0,2})*$", ErrorMessage = "The field Price must be a positive number with maximum two decimals.")]
|
||||
[Range(0.01, 1000)]
|
||||
[DataType(DataType.Currency)]
|
||||
public decimal Price { get; set; } = 0;
|
||||
|
||||
public string PictureUri { get; set; } = string.Empty;
|
||||
public string PictureBase64 { get; set; } = string.Empty;
|
||||
public string PictureName { get; set; } = string.Empty;
|
||||
public string PictureUri { get; set; } = string.Empty;
|
||||
public string PictureBase64 { get; set; } = string.Empty;
|
||||
public string PictureName { get; set; } = string.Empty;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
namespace BlazorShared.Models
|
||||
namespace BlazorShared.Models;
|
||||
|
||||
public class CreateCatalogItemResponse
|
||||
{
|
||||
public class CreateCatalogItemResponse
|
||||
{
|
||||
public CatalogItem CatalogItem { get; set; } = new CatalogItem();
|
||||
}
|
||||
public CatalogItem CatalogItem { get; set; } = new CatalogItem();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
namespace BlazorShared.Models
|
||||
namespace BlazorShared.Models;
|
||||
|
||||
public class DeleteCatalogItemResponse
|
||||
{
|
||||
public class DeleteCatalogItemResponse
|
||||
{
|
||||
public string Status { get; set; } = "Deleted";
|
||||
}
|
||||
public string Status { get; set; } = "Deleted";
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
namespace BlazorShared.Models
|
||||
namespace BlazorShared.Models;
|
||||
|
||||
public class EditCatalogItemResult
|
||||
{
|
||||
public class EditCatalogItemResult
|
||||
{
|
||||
public CatalogItem CatalogItem { get; set; } = new CatalogItem();
|
||||
}
|
||||
public CatalogItem CatalogItem { get; set; } = new CatalogItem();
|
||||
}
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
using System.Text.Json;
|
||||
|
||||
namespace BlazorShared.Models
|
||||
namespace BlazorShared.Models;
|
||||
|
||||
public class ErrorDetails
|
||||
{
|
||||
public class ErrorDetails
|
||||
public int StatusCode { get; set; }
|
||||
public string Message { get; set; }
|
||||
public override string ToString()
|
||||
{
|
||||
public int StatusCode { get; set; }
|
||||
public string Message { get; set; }
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonSerializer.Serialize(this);
|
||||
}
|
||||
return JsonSerializer.Serialize(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
namespace BlazorShared.Models
|
||||
namespace BlazorShared.Models;
|
||||
|
||||
public abstract class LookupData
|
||||
{
|
||||
public abstract class LookupData
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BlazorShared.Models
|
||||
namespace BlazorShared.Models;
|
||||
|
||||
public class PagedCatalogItemResponse
|
||||
{
|
||||
public class PagedCatalogItemResponse
|
||||
{
|
||||
public List<CatalogItem> CatalogItems { get; set; } = new List<CatalogItem>();
|
||||
public int PageCount { get; set; } = 0;
|
||||
}
|
||||
public List<CatalogItem> CatalogItems { get; set; } = new List<CatalogItem>();
|
||||
public int PageCount { get; set; } = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user