diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..3e8a931 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: ['https://coffeebede.ir/mjebrahimi'] diff --git a/.github/workflows/dotnet-core.yml b/.github/workflows/dotnet-core.yml index bebe9eb..8bd0a61 100644 --- a/.github/workflows/dotnet-core.yml +++ b/.github/workflows/dotnet-core.yml @@ -3,19 +3,27 @@ name: .NET Core on: push: paths-ignore: - - 'readme.md' + - 'README.md' pull_request: paths-ignore: - - 'readme.md' + - 'README.md' jobs: build: - runs-on: windows-latest + runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v2 + - name: Checkout + uses: actions/checkout@v2.4.0 + + - name: Setup .NET Core + uses: actions/setup-dotnet@v1.9.0 + with: + dotnet-version: '6.0.x' - - name: Build (Release) - run: dotnet build --configuration Release + - name: Install Dependencies + run: dotnet restore + + - name: Build (Release) + run: dotnet build --configuration Release --no-restore diff --git a/Common/Common.csproj b/Common/Common.csproj index d335519..c5d9bf2 100644 --- a/Common/Common.csproj +++ b/Common/Common.csproj @@ -1,13 +1,14 @@  - netcoreapp3.1 + net6.0 + 9.0 - - + + - + diff --git a/Common/Exceptions/BadRequestException.cs b/Common/Exceptions/BadRequestException.cs index 6f6bd3d..4436771 100644 --- a/Common/Exceptions/BadRequestException.cs +++ b/Common/Exceptions/BadRequestException.cs @@ -5,32 +5,32 @@ namespace Common.Exceptions public class BadRequestException : AppException { public BadRequestException() - : base(ApiResultStatusCode.BadRequest) + : base(ApiResultStatusCode.BadRequest, System.Net.HttpStatusCode.BadRequest) { } public BadRequestException(string message) - : base(ApiResultStatusCode.BadRequest, message) + : base(ApiResultStatusCode.BadRequest, message, System.Net.HttpStatusCode.BadRequest) { } public BadRequestException(object additionalData) - : base(ApiResultStatusCode.BadRequest, additionalData) + : base(ApiResultStatusCode.BadRequest, null, System.Net.HttpStatusCode.BadRequest, additionalData) { } public BadRequestException(string message, object additionalData) - : base(ApiResultStatusCode.BadRequest, message, additionalData) + : base(ApiResultStatusCode.BadRequest, message, System.Net.HttpStatusCode.BadRequest, additionalData) { } public BadRequestException(string message, Exception exception) - : base(ApiResultStatusCode.BadRequest, message, exception) + : base(ApiResultStatusCode.BadRequest, message, exception, System.Net.HttpStatusCode.BadRequest) { } public BadRequestException(string message, Exception exception, object additionalData) - : base(ApiResultStatusCode.BadRequest, message, exception, additionalData) + : base(ApiResultStatusCode.BadRequest, message, System.Net.HttpStatusCode.BadRequest, exception, additionalData) { } } diff --git a/Common/Exceptions/NotFoundException.cs b/Common/Exceptions/NotFoundException.cs index c301722..c7e01d9 100644 --- a/Common/Exceptions/NotFoundException.cs +++ b/Common/Exceptions/NotFoundException.cs @@ -5,32 +5,32 @@ namespace Common.Exceptions public class NotFoundException : AppException { public NotFoundException() - : base(ApiResultStatusCode.NotFound) + : base(ApiResultStatusCode.NotFound, System.Net.HttpStatusCode.NotFound) { } public NotFoundException(string message) - : base(ApiResultStatusCode.NotFound, message) + : base(ApiResultStatusCode.NotFound, message, System.Net.HttpStatusCode.NotFound) { } public NotFoundException(object additionalData) - : base(ApiResultStatusCode.NotFound, additionalData) + : base(ApiResultStatusCode.NotFound, null, System.Net.HttpStatusCode.NotFound, additionalData) { } public NotFoundException(string message, object additionalData) - : base(ApiResultStatusCode.NotFound, message, additionalData) + : base(ApiResultStatusCode.NotFound, message, System.Net.HttpStatusCode.NotFound, additionalData) { } public NotFoundException(string message, Exception exception) - : base(ApiResultStatusCode.NotFound, message, exception) + : base(ApiResultStatusCode.NotFound, message, exception, System.Net.HttpStatusCode.NotFound) { } public NotFoundException(string message, Exception exception, object additionalData) - : base(ApiResultStatusCode.NotFound, message, exception, additionalData) + : base(ApiResultStatusCode.NotFound, message, System.Net.HttpStatusCode.NotFound, exception, additionalData) { } } diff --git a/Data/Data.csproj b/Data/Data.csproj index c9c9db2..0ada808 100644 --- a/Data/Data.csproj +++ b/Data/Data.csproj @@ -1,12 +1,13 @@ - netcoreapp3.1 + net6.0 + 9.0 - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Entities/Common/BaseEntity.cs b/Entities/Common/BaseEntity.cs index 7113a8d..8ad8b58 100644 --- a/Entities/Common/BaseEntity.cs +++ b/Entities/Common/BaseEntity.cs @@ -4,7 +4,12 @@ public interface IEntity { } - public abstract class BaseEntity : IEntity + public interface IEntity : IEntity + { + TKey Id { get; set; } + } + + public abstract class BaseEntity : IEntity { public TKey Id { get; set; } } diff --git a/Entities/Entities.csproj b/Entities/Entities.csproj index bf6d64e..fcf69d1 100644 --- a/Entities/Entities.csproj +++ b/Entities/Entities.csproj @@ -1,11 +1,12 @@  - netcoreapp3.1 + net6.0 + 9.0 - + diff --git a/Entities/User/User.cs b/Entities/User/User.cs index e28303e..285f4cc 100644 --- a/Entities/User/User.cs +++ b/Entities/User/User.cs @@ -7,13 +7,13 @@ namespace Entities { - public class User : IdentityUser, IEntity + public class User : IdentityUser, IEntity { public User() { IsActive = true; } - + [Required] [StringLength(100)] public string FullName { get; set; } diff --git a/MyApi/Api.xml b/MyApi/Api.xml deleted file mode 100644 index a6d73b8..0000000 --- a/MyApi/Api.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - MyApi - - - - - This method is for generate jwt token - - The username of user - The password of user - return generated jwt token - - - - userame field - - - - - email field - - - - diff --git a/MyApi/Models/UserDto.cs b/MyApi/Models/UserDto.cs index 19f834e..67754b9 100644 --- a/MyApi/Models/UserDto.cs +++ b/MyApi/Models/UserDto.cs @@ -2,10 +2,11 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using WebFramework.Api; namespace MyApi.Models { - public class UserDto : IValidatableObject + public class UserDto : BaseDto, IValidatableObject { [Required] [StringLength(100)] diff --git a/MyApi/MyApi.csproj b/MyApi/MyApi.csproj index a8c8f30..964cdd2 100644 --- a/MyApi/MyApi.csproj +++ b/MyApi/MyApi.csproj @@ -1,25 +1,18 @@  - netcoreapp3.1 - - - + net6.0 + 9.0 MyApi.xml - bin\Debug\ - - - - - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + diff --git a/MyApi/Program.cs b/MyApi/Program.cs index c72a49e..7a90860 100644 --- a/MyApi/Program.cs +++ b/MyApi/Program.cs @@ -97,7 +97,7 @@ private static void UsingCodeConfiguration() // If DSN is not set, the SDK will look for an environment variable called SENTRY_DSN. If // nothing is found, SDK is disabled. - options.Dsn = new Dsn("https://a48f67497c814561aca2c66fa5ee37fc:a5af1a051d6f4f09bdd82472d5c2629d@sentry.io/1340240"); + options.Dsn = "https://a48f67497c814561aca2c66fa5ee37fc:a5af1a051d6f4f09bdd82472d5c2629d@sentry.io/1340240"; options.AttachStacktrace = true; options.SendDefaultPii = true; // Send Personal Identifiable information like the username of the user logged in to the device diff --git a/README.md b/README.md index 0a13623..adf4c36 100644 --- a/README.md +++ b/README.md @@ -48,8 +48,10 @@ If you like this project, learn something or you are using it in your applicatio در این دوره سعی شده بهترین و محبوب ترین تکنولوژی ها، کتابخانه ها و ابزار ها داخل پروژه استفاده بشه. همچنین Best Practice های پرفرمنسی و امنیتی بعلاوه تکنیک های پرکاربرد را بررسی و در قالب یک معماری حرفه ای و اصولی استفاده می کنیم. **توجه:** -- **برنچ master این مخزن همواره به آخرین نسخه ASP.NET Core (به همراه تمام Dependency هایش) بروز رسانی شده و خواهد شد** +- **برنچ master این مخزن همواره به آخرین نسخه ASP.NET Core (به همراه تمام Dependency هایش) بروز رسانی شده و خواهد شد (در حال حاضر ASP.NET Core 6.0 می باشد)** - **جهت دسترسی به کد اولیه پروژه که با ASP.NET Core 2.1 در هنگام تهیه دوره نوشته بود [به این برنچ مراجعه کنید](https://github.com/dotnetzoom/AspNetCore-WebApi-Course/tree/AspNetCore2.1)** +- **جهت دسترسی به کد پروژه در ورژن ASP.NET Core 3.1 [به این برنچ مراجعه کنید](https://github.com/dotnetzoom/AspNetCore-WebApi-Course/tree/AspNetCore3.1)** +- **جهت دسترسی به کد پروژه در ورژن ASP.NET Core 5.0 [به این برنچ مراجعه کنید](https://github.com/dotnetzoom/AspNetCore-WebApi-Course/tree/AspNetCore5.0)** - **همچنین جهت اطلاعات بیشتر از تغییرات که به هنگام Upgrade پروژه از نسخه 2.1 به 3.1 انجام شد، میتونین به قسمت [ChangeLog](https://github.com/dotnetzoom/AspNetCore-WebApi-Course/blob/master/CHANGELOG.md) مراجعه کنید** ## تکنولوژی، ابزار ها و قابلیت ها @@ -119,7 +121,7 @@ If you like this project, learn something or you are using it in your applicatio 1. تسلط نسبی بر روی زبان سی شارپ 2. آشنایی با پروتکل Http و REST 3. آشنایی با Entity Framework (ترجیحا EF Core) -4. آشنایی با معماری ASP.NET MVC یا ASP.NET Core (و ترجیحا آشنایی با WebAPI) +4. آشنایی با ASP.NET MVC یا ASP.NET Core (و ترجیحا آشنایی با WebAPI) ## ارتباط با مدرس جهت ارتباط با مدرس و ارائه هرگونه پیشنهاد، انتقاد، نظر و سوالاتتون میتونین با اکانت تلگرام **محمد جواد ابراهیمی** در ارتباط باشین [**mjebrahimi@**](https://t.me/mjebrahimi) diff --git a/Services/Services.csproj b/Services/Services.csproj index ebd9303..2cab0d1 100644 --- a/Services/Services.csproj +++ b/Services/Services.csproj @@ -1,13 +1,17 @@ - + - netcoreapp3.1 + net6.0 + 9.0 - - - + + + + + + diff --git a/WebFramework/Api/BaseDto.cs b/WebFramework/Api/BaseDto.cs index db9ef66..975eb6d 100644 --- a/WebFramework/Api/BaseDto.cs +++ b/WebFramework/Api/BaseDto.cs @@ -7,7 +7,7 @@ namespace WebFramework.Api { public abstract class BaseDto : IHaveCustomMapping where TDto : class, new() - where TEntity : BaseEntity, new() + where TEntity : class, IEntity, new() { [Display(Name = "ردیف")] public TKey Id { get; set; } @@ -55,7 +55,7 @@ public virtual void CustomMappings(IMappingExpression mapping) public abstract class BaseDto : BaseDto where TDto : class, new() - where TEntity : BaseEntity, new() + where TEntity : class, IEntity, new() { } diff --git a/WebFramework/Api/CrudController.cs b/WebFramework/Api/CrudController.cs index f198a83..f781e39 100644 --- a/WebFramework/Api/CrudController.cs +++ b/WebFramework/Api/CrudController.cs @@ -14,7 +14,7 @@ namespace WebFramework.Api public class CrudController : BaseController where TDto : BaseDto , new() where TSelectDto : BaseDto, new() - where TEntity : BaseEntity, new() + where TEntity : class, IEntity, new() { protected readonly IRepository Repository; protected readonly IMapper Mapper; @@ -88,7 +88,7 @@ public virtual async Task Delete(TKey id, CancellationToken cancellat public class CrudController : CrudController where TDto : BaseDto , new() where TSelectDto : BaseDto, new() - where TEntity : BaseEntity, new() + where TEntity : class, IEntity, new() { public CrudController(IRepository repository, IMapper mapper) : base(repository, mapper) @@ -98,7 +98,7 @@ public CrudController(IRepository repository, IMapper mapper) public class CrudController : CrudController where TDto : BaseDto , new() - where TEntity : BaseEntity, new() + where TEntity : class, IEntity, new() { public CrudController(IRepository repository, IMapper mapper) : base(repository, mapper) diff --git a/WebFramework/CustomMapping/AutoMapperConfiguration.cs b/WebFramework/CustomMapping/AutoMapperConfiguration.cs index 0284625..b7182f8 100644 --- a/WebFramework/CustomMapping/AutoMapperConfiguration.cs +++ b/WebFramework/CustomMapping/AutoMapperConfiguration.cs @@ -18,10 +18,6 @@ public static void InitializeAutoMapper(this IServiceCollection services, params services.AddAutoMapper(config => { config.AddCustomMappingProfile(); - config.Advanced.BeforeSeal(configProvicer => - { - configProvicer.CompileMappings(); - }); }, assemblies); #region Deprecated (Use AutoMapper Instance instead) diff --git a/WebFramework/WebFramework.csproj b/WebFramework/WebFramework.csproj index 68fa9f5..71085e9 100644 --- a/WebFramework/WebFramework.csproj +++ b/WebFramework/WebFramework.csproj @@ -1,28 +1,25 @@  - netcoreapp3.1 + net6.0 + 9.0 - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + +

AltStyle によって変換されたページ (->オリジナル) /