update .net to .net 8
parent
e494f16542
commit
080088528e
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
|
|
|
@ -54,5 +54,5 @@ public class UserController : ICarterModule
|
|||
|
||||
// DELETE:Delete Entity
|
||||
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));
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -12,6 +12,7 @@ public interface IUserService : IScopedDependency
|
|||
Task<bool> EditUserAsync(UserActionRequestDto request, CancellationToken cancellationToken);
|
||||
Task<bool> EditUserProfileAsync(UserActionRequestDto request, 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);
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
using System.Security.Claims;
|
||||
using System.Threading;
|
||||
using Brizco.Domain.CommandQueries.Queries;
|
||||
using Brizco.Domain.Mappers;
|
||||
using Mapster;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Brizco.Core.EntityServices;
|
||||
|
||||
|
@ -172,28 +170,33 @@ public class UserService : IUserService
|
|||
if (!Guid.TryParse(_currentUserService.ComplexId, out Guid complexId))
|
||||
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,
|
||||
PhoneNumber = request.PhoneNumber,
|
||||
FirstName = request.FirstName,
|
||||
LastName = request.LastName,
|
||||
NationalId = request.NationalId,
|
||||
BirthDate = DateTimeExtensions.UnixTimeStampToDateTime(request.BirthDateTimeStamp),
|
||||
Gender = request.Gender,
|
||||
SignUpStatus = SignUpStatus.SignUpCompleted
|
||||
};
|
||||
if (!request.Password.IsNullOrEmpty())
|
||||
{
|
||||
var result = await _userManager.CreateAsync(user, request.Password);
|
||||
if (!result.Succeeded)
|
||||
throw new AppException(string.Join('|', result.Errors.Select(e => e.Description)));
|
||||
}
|
||||
else
|
||||
{
|
||||
var result = await _userManager.CreateAsync(user);
|
||||
if (!result.Succeeded)
|
||||
throw new AppException(string.Join('|', result.Errors.Select(e => e.Description)));
|
||||
user = new ApplicationUser
|
||||
{
|
||||
UserName = request.PhoneNumber,
|
||||
PhoneNumber = request.PhoneNumber,
|
||||
FirstName = request.FirstName,
|
||||
LastName = request.LastName,
|
||||
NationalId = request.NationalId,
|
||||
BirthDate = DateTimeExtensions.UnixTimeStampToDateTime(request.BirthDateTimeStamp),
|
||||
Gender = request.Gender,
|
||||
SignUpStatus = SignUpStatus.SignUpCompleted
|
||||
};
|
||||
|
||||
if (!request.Password.IsNullOrEmpty())
|
||||
{
|
||||
var result = await _userManager.CreateAsync(user, request.Password);
|
||||
if (!result.Succeeded)
|
||||
throw new AppException(string.Join('|', result.Errors.Select(e => e.Description)));
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
|
@ -291,6 +294,19 @@ public class UserService : IUserService
|
|||
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)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<!--<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"sdk": {
|
||||
"version": "7.0.400"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue