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,28 +170,33 @@ 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)
{ {
UserName = request.PhoneNumber, user = new ApplicationUser
PhoneNumber = request.PhoneNumber, {
FirstName = request.FirstName, UserName = request.PhoneNumber,
LastName = request.LastName, PhoneNumber = request.PhoneNumber,
NationalId = request.NationalId, FirstName = request.FirstName,
BirthDate = DateTimeExtensions.UnixTimeStampToDateTime(request.BirthDateTimeStamp), LastName = request.LastName,
Gender = request.Gender, NationalId = request.NationalId,
SignUpStatus = SignUpStatus.SignUpCompleted BirthDate = DateTimeExtensions.UnixTimeStampToDateTime(request.BirthDateTimeStamp),
}; Gender = request.Gender,
if (!request.Password.IsNullOrEmpty()) SignUpStatus = SignUpStatus.SignUpCompleted
{ };
var result = await _userManager.CreateAsync(user, request.Password);
if (!result.Succeeded) if (!request.Password.IsNullOrEmpty())
throw new AppException(string.Join('|', result.Errors.Select(e => e.Description))); {
} var result = await _userManager.CreateAsync(user, request.Password);
else if (!result.Succeeded)
{ throw new AppException(string.Join('|', result.Errors.Select(e => e.Description)));
var result = await _userManager.CreateAsync(user); }
if (!result.Succeeded) else
throw new AppException(string.Join('|', result.Errors.Select(e => e.Description))); {
var result = await _userManager.CreateAsync(user);
if (!result.Succeeded)
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);
@ -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"
}
}