update .net to .net 8

master
Amir Hossein Khademi 2023-11-29 13:02:59 +03:30
parent e494f16542
commit 080088528e
9 changed files with 46 additions and 34 deletions

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS> <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>

View File

@ -54,5 +54,5 @@ public class UserController : ICarterModule
// DELETE:Delete Entity // DELETE:Delete Entity
public async Task<IResult> Delete(Guid id, IUserService userService, CancellationToken cancellationToken) public async Task<IResult> Delete(Guid id, IUserService userService, CancellationToken cancellationToken)
=> TypedResults.Ok(await userService.RemoveUserAsync(id, cancellationToken)); => TypedResults.Ok(await userService.RemoveUserFromComplexAsync(id, cancellationToken));
} }

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>

View File

@ -12,6 +12,7 @@ public interface IUserService : IScopedDependency
Task<bool> EditUserAsync(UserActionRequestDto request, CancellationToken cancellationToken); Task<bool> EditUserAsync(UserActionRequestDto request, CancellationToken cancellationToken);
Task<bool> EditUserProfileAsync(UserActionRequestDto request, CancellationToken cancellationToken); Task<bool> EditUserProfileAsync(UserActionRequestDto request, CancellationToken cancellationToken);
Task<bool> RemoveUserAsync(Guid userId, CancellationToken cancellationToken); Task<bool> RemoveUserAsync(Guid userId, CancellationToken cancellationToken);
Task<bool> RemoveUserFromComplexAsync(Guid userId, CancellationToken cancellationToken);
Task<List<ApplicationRole>> GetRolesAsync(int page = 0, CancellationToken cancellationToken = default); Task<List<ApplicationRole>> GetRolesAsync(int page = 0, CancellationToken cancellationToken = default);

View File

@ -1,9 +1,7 @@
using System.Security.Claims; using System.Security.Claims;
using System.Threading;
using Brizco.Domain.CommandQueries.Queries; using Brizco.Domain.CommandQueries.Queries;
using Brizco.Domain.Mappers; using Brizco.Domain.Mappers;
using Mapster; using Mapster;
using Newtonsoft.Json.Linq;
namespace Brizco.Core.EntityServices; namespace Brizco.Core.EntityServices;
@ -172,7 +170,10 @@ public class UserService : IUserService
if (!Guid.TryParse(_currentUserService.ComplexId, out Guid complexId)) if (!Guid.TryParse(_currentUserService.ComplexId, out Guid complexId))
throw new AppException("Wrong authorize token , ComplexId needed"); throw new AppException("Wrong authorize token , ComplexId needed");
var user = new ApplicationUser var user = await _userManager.FindByNameAsync(request.PhoneNumber);
if (user == null)
{
user = new ApplicationUser
{ {
UserName = request.PhoneNumber, UserName = request.PhoneNumber,
PhoneNumber = request.PhoneNumber, PhoneNumber = request.PhoneNumber,
@ -183,6 +184,7 @@ public class UserService : IUserService
Gender = request.Gender, Gender = request.Gender,
SignUpStatus = SignUpStatus.SignUpCompleted SignUpStatus = SignUpStatus.SignUpCompleted
}; };
if (!request.Password.IsNullOrEmpty()) if (!request.Password.IsNullOrEmpty())
{ {
var result = await _userManager.CreateAsync(user, request.Password); var result = await _userManager.CreateAsync(user, request.Password);
@ -195,6 +197,7 @@ public class UserService : IUserService
if (!result.Succeeded) if (!result.Succeeded)
throw new AppException(string.Join('|', result.Errors.Select(e => e.Description))); throw new AppException(string.Join('|', result.Errors.Select(e => e.Description)));
} }
}
await _sender.Send(new CreateComplexUserCommand(complexId, user.Id, request.RoleIds), cancellationToken); await _sender.Send(new CreateComplexUserCommand(complexId, user.Id, request.RoleIds), cancellationToken);
return user; return user;
@ -291,6 +294,19 @@ public class UserService : IUserService
return true; return true;
} }
public async Task<bool> RemoveUserFromComplexAsync(Guid userId, CancellationToken cancellationToken)
{
if (_currentUserService.ComplexId.IsNullOrEmpty())
throw new AppException("Wrong authorize token , ComplexId needed");
if (!Guid.TryParse(_currentUserService.ComplexId, out Guid complexId))
throw new AppException("Wrong authorize token , ComplexId needed");
var user = await _userManager.FindByIdAsync(userId.ToString());
if (user == null)
throw new AppException("User not found", ApiResultStatusCode.NotFound);
await _sender.Send(new DeleteComplexUserCommand(userId, complexId), cancellationToken);
return true;
}
public async Task<List<ApplicationRole>> GetRolesAsync(int page = 0, CancellationToken cancellationToken = default) public async Task<List<ApplicationRole>> GetRolesAsync(int page = 0, CancellationToken cancellationToken = default)

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<!--<PropertyGroup> <!--<PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>

View File

@ -1,5 +0,0 @@
{
"sdk": {
"version": "7.0.400"
}
}