improvements, fixes...
This commit is contained in:
parent
20d728f28a
commit
733fdd2484
|
|
@ -54,7 +54,7 @@ namespace TIAM.Database.Test
|
|||
|
||||
[TestMethod]
|
||||
[DataRow("540271F6-C604-4C16-8160-D5A7CAFEDF00")]
|
||||
public void SerializeUserModelDto_ReturnDeserializedUser_WhenUserAndRelationsExists(string userIdString)
|
||||
public async Task SerializeUserModelDto_ReturnDeserializedUser_WhenUserAndRelationsExists(string userIdString)
|
||||
{
|
||||
var userId = Guid.Parse(userIdString);
|
||||
|
||||
|
|
@ -64,12 +64,13 @@ namespace TIAM.Database.Test
|
|||
NullValueHandling = NullValueHandling.Ignore
|
||||
};
|
||||
|
||||
var userModel = Dal.GetUserModelDtoById(userId);
|
||||
var userModel = await Dal.GetUserModelDtoByIdAsync(userId).ConfigureAwait(false);
|
||||
|
||||
var serializedUserModel = JsonConvert.SerializeObject(userModel, options);
|
||||
userModel = JsonConvert.DeserializeObject<UserModelDto>(serializedUserModel);
|
||||
|
||||
Assert.IsNotNull(userModel);
|
||||
Assert.IsNotNull(userModel.UserDto);
|
||||
Assert.IsNotNull(userModel.Profile);
|
||||
|
||||
Assert.IsTrue(userModel.Products.Count > 0);
|
||||
|
|
|
|||
|
|
@ -32,8 +32,9 @@ namespace TIAM.Database.DataLayers.Users
|
|||
return Context.Users.ToListAsync();
|
||||
}
|
||||
|
||||
public UserModelDto? GetUserModelDtoById(Guid userId) => Session(x => x.GetUserModelDtoById(userId));
|
||||
public UserModelDto? GetUserModelDtoByEmail(string email) => Session(x => x.GetUserModelDtoByEmail(email));
|
||||
public Task<UserModelDto?> GetUserModelDtoByIdAsync(Guid userId) => SessionAsync(x => x.GetUserModelDtoById(userId));
|
||||
public Task<UserModelDto?> GetUserModelDtoByEmailAsync(string email) => SessionAsync(x => x.GetUserModelDtoByEmail(email));
|
||||
public Task<List<UserModelDto>> GetAllUsersModelDtoAsync() => SessionAsync(x => x.GetAllUsersModelDto().ToList());
|
||||
|
||||
public Task<User?> GetUserByPhoneNumberAsync(string phoneNumber)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -26,4 +26,8 @@ public static class UserDbSetExtensions
|
|||
|
||||
public static UserModelDto? GetUserModelDtoByEmail(this IUserDbSet ctx, string email)
|
||||
=> ctx.GetUsersByEmail(email).Select(x => new UserModelDto(x, x.Profile, x.UserProductMappings, x.Products)).FirstOrDefault();
|
||||
|
||||
public static IQueryable<UserModelDto> GetAllUsersModelDto(this IUserDbSet ctx)
|
||||
=> ctx.Users.Select(x => new UserModelDto(x, x.Profile, x.UserProductMappings, x.Products));
|
||||
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ using System.Text;
|
|||
using AyCode.Interfaces.StorageHandlers;
|
||||
using Newtonsoft.Json;
|
||||
using TIAM.Entities.Users;
|
||||
using TIAM.Models.Dtos.Users;
|
||||
using TIAMWebApp.Shared.Application.Interfaces;
|
||||
using TIAMWebApp.Shared.Application.Models;
|
||||
using TIAMWebApp.Shared.Application.Models.ClientSide;
|
||||
|
|
@ -49,7 +50,7 @@ namespace TIAMMobileApp.Services
|
|||
{
|
||||
|
||||
var hasProperties = await _serviceProviderDataService.GetPropertiesByOwnerIdAsync(dbUser.Id);
|
||||
var user = new UserSessionModel(dbUser.Id, UserType.User, dbUser.EmailAddress, hasProperties, 1);
|
||||
var user = new UserSessionModel(dbUser.Id, UserType.User, dbUser.Profile?.Name, hasProperties, 1);
|
||||
|
||||
return user;
|
||||
}
|
||||
|
|
@ -117,14 +118,14 @@ namespace TIAMMobileApp.Services
|
|||
return (isSuccess, result);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<User>?> GetUsersAsync()
|
||||
public async Task<IEnumerable<UserModelDto>?> GetUsersAsync()
|
||||
{
|
||||
return await http.GetFromJsonAsync<IEnumerable<User>>(APIUrls.GetUsers);
|
||||
return await http.GetFromJsonAsync<IEnumerable<UserModelDto>>(APIUrls.GetUsers);
|
||||
}
|
||||
|
||||
public async Task<User?> GetUserByEmailAsync(string email)
|
||||
public async Task<UserModelDto?> GetUserByEmailAsync(string email)
|
||||
{
|
||||
return await http.GetFromJsonAsync<User?>(APIUrls.GetUserByEmail);
|
||||
return await http.GetFromJsonAsync<UserModelDto?>(APIUrls.GetUserByEmail);
|
||||
}
|
||||
public async Task<User?> GetUserByIdAsync(Guid Id)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ Loading....
|
|||
string _email = jsontoken.Claims.First(claim => claim.Type == JwtRegisteredClaimNames.Email).Value;
|
||||
var user = await UserDataService.IsLoggedInAsync(Guid.Parse(_userId));
|
||||
sessionService.User = user;
|
||||
logToBrowserConsole.LogToBC($"Saved user in db is: {user.Email}, setting autenthicated state");
|
||||
logToBrowserConsole.LogToBC($"Saved user in db is: {user.DisplayName}, setting autenthicated state");
|
||||
sessionService.IsAuthenticated = true;
|
||||
NavManager.NavigateTo("/index");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@
|
|||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Email = sessionService.User.Email;
|
||||
Email = sessionService.User.DisplayName;
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
</div>
|
||||
<p class="tm-8 cw-480 mt-2">
|
||||
<h3> @Localizer.GetString("DestinationName")</h3>
|
||||
@FormSubmitResult
|
||||
@_formSubmitResult
|
||||
</p>
|
||||
|
||||
@code {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace TIAMSharedUI.Pages.Components
|
|||
public partial class InputWizard : ComponentBase
|
||||
{
|
||||
[Inject]
|
||||
LogToBrowserConsole logToBrowserConsole { get; set; }
|
||||
public required LogToBrowserConsole LogToBrowserConsole { get; set; }
|
||||
|
||||
public Dictionary<int, Guid> FormSteps { get; set; } = new Dictionary<int, Guid>();
|
||||
public int CurrentStep { get; set; } = 0;
|
||||
|
|
@ -28,37 +28,37 @@ namespace TIAMSharedUI.Pages.Components
|
|||
public object Data { get; set; } = new object();
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<object> onSubmit { get; set; }
|
||||
public EventCallback<object> OnSubmit { get; set; }
|
||||
|
||||
|
||||
string PhoneMask { get; set; } = "(999)000-0000";
|
||||
string FormSubmitResult = "";
|
||||
private string spinnerClass = "";
|
||||
string _phoneMask = "(999)000-0000";
|
||||
string _formSubmitResult = "";
|
||||
private string _spinnerClass = "";
|
||||
|
||||
async Task HandleValidSubmit()
|
||||
{
|
||||
spinnerClass = "spinner-border spinner-border-sm";
|
||||
_spinnerClass = "spinner-border spinner-border-sm";
|
||||
await Task.Delay(500);
|
||||
FormSubmitResult = "You have been registred successully.";
|
||||
spinnerClass = "";
|
||||
_formSubmitResult = "You have been registred successully.";
|
||||
_spinnerClass = "";
|
||||
|
||||
await onSubmit.InvokeAsync(Data);
|
||||
await OnSubmit.InvokeAsync(Data);
|
||||
|
||||
}
|
||||
void HandleInvalidSubmit()
|
||||
{
|
||||
FormSubmitResult = "Please correct all errors";
|
||||
_formSubmitResult = "Please correct all errors";
|
||||
}
|
||||
|
||||
public void OnNext(MouseEventArgs args)
|
||||
{
|
||||
logToBrowserConsole.LogToBC("OnNext called");
|
||||
LogToBrowserConsole.LogToBC("OnNext called");
|
||||
CurrentStep++;
|
||||
}
|
||||
|
||||
public void OnPrevious(MouseEventArgs args)
|
||||
{
|
||||
logToBrowserConsole.LogToBC("OnPrev called");
|
||||
LogToBrowserConsole.LogToBC("OnPrev called");
|
||||
CurrentStep--;
|
||||
}
|
||||
|
||||
|
|
@ -66,7 +66,7 @@ namespace TIAMSharedUI.Pages.Components
|
|||
{
|
||||
|
||||
var _type = Data.GetType();
|
||||
logToBrowserConsole.LogToBC("Hellooooo " + _type.AssemblyQualifiedName);
|
||||
LogToBrowserConsole.LogToBC("Hellooooo " + _type.AssemblyQualifiedName);
|
||||
|
||||
var propertyList = _type.GetProperties();
|
||||
//var propertyList = typeof(TestUserData).GetProperties();
|
||||
|
|
@ -100,7 +100,7 @@ namespace TIAMSharedUI.Pages.Components
|
|||
var access = Expression.Property(Expression.Constant(Data), property.Name);
|
||||
var lambda = Expression.Lambda(typeof(Func<>).MakeGenericType(property.PropertyType), access);
|
||||
|
||||
logToBrowserConsole.LogToBC(lambda.ToString());
|
||||
LogToBrowserConsole.LogToBC(lambda.ToString());
|
||||
|
||||
layoutItemBuilder.OpenElement(i++, "div");//open div
|
||||
layoutItemBuilder.AddAttribute(i++, "id", _stepID.ToString());
|
||||
|
|
@ -116,7 +116,7 @@ namespace TIAMSharedUI.Pages.Components
|
|||
layoutItemBuilder.AddAttribute(i++, "ColSpanMd", 12);
|
||||
//layoutItemBuilder.AddAttribute(i++, "CssClass", "form-field");
|
||||
|
||||
layoutItemBuilder.AddAttribute(i++, "Template", (RenderFragment<Object>)((context) => ((editor) =>
|
||||
layoutItemBuilder.AddAttribute(i++, "Template", (RenderFragment<object>)((context) => ((editor) =>
|
||||
{
|
||||
var j = 0;
|
||||
switch (attrList.DataType)
|
||||
|
|
@ -125,11 +125,11 @@ namespace TIAMSharedUI.Pages.Components
|
|||
case DataType.Text:
|
||||
{
|
||||
editor.OpenComponent<DxTextBox>(j++);
|
||||
logToBrowserConsole.LogToBC($"{property.Name}, {property.PropertyType}");
|
||||
LogToBrowserConsole.LogToBC($"{property.Name}, {property.PropertyType}");
|
||||
editor.AddAttribute(j++, "Text", property.GetValue(Data));
|
||||
editor.AddAttribute(j++, "TextExpression", lambda);
|
||||
editor.AddAttribute(j++, "CssClass", "form-field");
|
||||
editor.AddAttribute(j++, "TextChanged", EventCallback.Factory.Create<System.String>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.AddAttribute(j++, "TextChanged", EventCallback.Factory.Create<string>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.CloseComponent();
|
||||
break;
|
||||
}
|
||||
|
|
@ -141,17 +141,17 @@ namespace TIAMSharedUI.Pages.Components
|
|||
editor.AddAttribute(j++, "NullText", "Password");
|
||||
editor.AddAttribute(j++, "Text", property.GetValue(Data));
|
||||
editor.AddAttribute(j++, "TextExpression", lambda);
|
||||
editor.AddAttribute(j++, "TextChanged", EventCallback.Factory.Create<System.String>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.AddAttribute(j++, "TextChanged", EventCallback.Factory.Create<string>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.CloseComponent();
|
||||
break;
|
||||
}
|
||||
case DataType.PhoneNumber:
|
||||
{
|
||||
editor.OpenComponent<DxMaskedInput<String>>(j++);
|
||||
editor.OpenComponent<DxMaskedInput<string>>(j++);
|
||||
editor.AddAttribute(j++, "Value", property.GetValue(Data));
|
||||
editor.AddAttribute(j++, "Mask", PhoneMask);
|
||||
editor.AddAttribute(j++, "Mask", _phoneMask);
|
||||
editor.AddAttribute(j++, "ValueExpression", lambda);
|
||||
editor.AddAttribute(j++, "ValueChanged", EventCallback.Factory.Create<System.String>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.AddAttribute(j++, "ValueChanged", EventCallback.Factory.Create<string>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.CloseComponent();
|
||||
break;
|
||||
}
|
||||
|
|
@ -160,7 +160,7 @@ namespace TIAMSharedUI.Pages.Components
|
|||
editor.OpenComponent<DxDateEdit<DateTime>>(j);
|
||||
editor.AddAttribute(j++, "Date", property.GetValue(Data));
|
||||
editor.AddAttribute(j++, "DateExpression", lambda);
|
||||
editor.AddAttribute(j++, "DateChanged", EventCallback.Factory.Create<System.DateTime>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.AddAttribute(j++, "DateChanged", EventCallback.Factory.Create<DateTime>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.CloseComponent();
|
||||
break;
|
||||
|
||||
|
|
@ -177,7 +177,7 @@ namespace TIAMSharedUI.Pages.Components
|
|||
editor.AddAttribute(j++, "Mask", "n6");
|
||||
editor.AddAttribute(j++, "ValueExpression", lambda);
|
||||
editor.AddAttribute(j++, "CssClass", "form-field");
|
||||
editor.AddAttribute(j++, "ValueChanged", EventCallback.Factory.Create<System.Double>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.AddAttribute(j++, "ValueChanged", EventCallback.Factory.Create<double>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.CloseComponent();
|
||||
break;
|
||||
}
|
||||
|
|
@ -191,18 +191,18 @@ namespace TIAMSharedUI.Pages.Components
|
|||
editor.AddAttribute(j++, "Mask", "n0");
|
||||
editor.AddAttribute(j++, "ValueExpression", lambda);
|
||||
editor.AddAttribute(j++, "CssClass", "form-field");
|
||||
editor.AddAttribute(j++, "ValueChanged", EventCallback.Factory.Create<System.Int32>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.AddAttribute(j++, "ValueChanged", EventCallback.Factory.Create<int>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.CloseComponent();
|
||||
break;
|
||||
}
|
||||
else if (property.PropertyType == typeof(string) && property.Name == "Occupation")
|
||||
{
|
||||
|
||||
editor.OpenComponent<DxComboBox<String, String>>(j);
|
||||
editor.OpenComponent<DxComboBox<string, string>>(j);
|
||||
editor.AddAttribute(j++, "Data", AdditionalData.Occupations);
|
||||
editor.AddAttribute(j++, "Value", property.GetValue(Data));
|
||||
editor.AddAttribute(j++, "ValueExpression", lambda);
|
||||
editor.AddAttribute(j++, "ValueChanged", EventCallback.Factory.Create<System.String>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.AddAttribute(j++, "ValueChanged", EventCallback.Factory.Create<string>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.CloseComponent();
|
||||
break;
|
||||
}
|
||||
|
|
@ -211,6 +211,8 @@ namespace TIAMSharedUI.Pages.Components
|
|||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
case DataType.MultilineText:
|
||||
{
|
||||
|
|
@ -218,7 +220,7 @@ namespace TIAMSharedUI.Pages.Components
|
|||
editor.AddAttribute(j++, "Text", property.GetValue(Data));
|
||||
editor.AddAttribute(j++, "TextExpression", lambda);
|
||||
editor.AddAttribute(j++, "CssClass", "form-field");
|
||||
editor.AddAttribute(j++, "TextChanged", EventCallback.Factory.Create<System.String>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.AddAttribute(j++, "TextChanged", EventCallback.Factory.Create<string>(this, str => { property.SetValue(Data, str); }));
|
||||
editor.CloseComponent();
|
||||
break;
|
||||
|
||||
|
|
@ -258,14 +260,14 @@ namespace TIAMSharedUI.Pages.Components
|
|||
layoutItemBuilder.CloseElement();
|
||||
|
||||
|
||||
logToBrowserConsole.LogToBC($"loop {j}, {propertyList.Length}");
|
||||
LogToBrowserConsole.LogToBC($"loop {j}, {propertyList.Length}");
|
||||
j++;
|
||||
|
||||
}
|
||||
layoutItemBuilder.OpenComponent<DxFormLayoutItem>(i++);
|
||||
layoutItemBuilder.AddAttribute(i++, "Template", (RenderFragment<Object>)((context) => ((editor) =>
|
||||
layoutItemBuilder.AddAttribute(i++, "Template", (RenderFragment<object>)((context) => ((editor) =>
|
||||
{
|
||||
logToBrowserConsole.LogToBC($"Submit button {CurrentStep}, {propertyList.Length}");
|
||||
LogToBrowserConsole.LogToBC($"Submit button {CurrentStep}, {propertyList.Length}");
|
||||
editor.OpenComponent<DxButton>(i++);
|
||||
editor.AddAttribute(i++, "SubmitFormOnClick", true);
|
||||
editor.AddAttribute(i++, "Text", "Submit");
|
||||
|
|
@ -279,7 +281,7 @@ namespace TIAMSharedUI.Pages.Components
|
|||
editor.AddAttribute(i++, "Visible", false);
|
||||
}
|
||||
editor.OpenElement(i++, "span");
|
||||
editor.AddAttribute(i++, "class", spinnerClass);
|
||||
editor.AddAttribute(i++, "class", _spinnerClass);
|
||||
editor.CloseElement();
|
||||
editor.CloseComponent();
|
||||
})));
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@
|
|||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Email = sessionService.User.Email;
|
||||
Email = sessionService.User.DisplayName;
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
@if (Users == null)
|
||||
@using AyCode.Utils.Extensions
|
||||
@if (Users == null)
|
||||
{
|
||||
<p>
|
||||
<em>Loading ...</em>
|
||||
|
|
@ -11,7 +12,9 @@ else
|
|||
|
||||
@foreach (var dest in Users)
|
||||
{
|
||||
<p>@dest.EmailAddress</p>
|
||||
<p>
|
||||
@(dest.Profile == null ? dest.UserDto.Id.ToString() : dest.Profile.Name)
|
||||
</p>
|
||||
}
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TIAM.Entities.Users;
|
||||
using TIAM.Models.Dtos.Users;
|
||||
using TIAMWebApp.Shared.Application.Interfaces;
|
||||
using TIAMWebApp.Shared.Application.Models;
|
||||
|
||||
|
|
@ -19,7 +20,7 @@ namespace TIAMSharedUI.Pages
|
|||
get;
|
||||
set;
|
||||
}
|
||||
public List<TIAM.Entities.Users.User>? Users
|
||||
public required List<UserModelDto> Users
|
||||
{
|
||||
get;
|
||||
set;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
<hr/>
|
||||
<DbTestComponent></DbTestComponent>
|
||||
|
||||
<InputWizard Data=@myModel onSubmit="SubmitForm"></InputWizard>
|
||||
<InputWizard Data=@myModel OnSubmit="SubmitForm"></InputWizard>
|
||||
</div>
|
||||
@code {
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@
|
|||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Aycode.Blazor\AyCode.Blazor.Components\AyCode.Blazor.Components.csproj" />
|
||||
<ProjectReference Include="..\..\Aycode.Blazor\AyCode.Blazor.Models\AyCode.Blazor.Models.csproj" />
|
||||
<ProjectReference Include="..\TIAM.Entities\TIAM.Entities.csproj" />
|
||||
<ProjectReference Include="..\TIAM.Models\TIAM.Models.csproj" />
|
||||
<ProjectReference Include="..\TIAMResources\TIAM.Resources.csproj" />
|
||||
<ProjectReference Include="..\TIAMWebApp\Shared\TIAMWebApp.Shared.Application.csproj" />
|
||||
</ItemGroup>
|
||||
|
|
@ -34,6 +36,15 @@
|
|||
<Reference Include="AyCode.Interfaces">
|
||||
<HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Interfaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="AyCode.Models">
|
||||
<HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Models.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="AyCode.Services">
|
||||
<HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Services.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="AyCode.Utils">
|
||||
<HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Utils.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ using TIAMWebApp.Shared.Application.Models.PageModels;
|
|||
using TIAMWebApp.Shared.Application.Utility;
|
||||
using AyCode.Interfaces.StorageHandlers;
|
||||
using AyCode.Core.Logger;
|
||||
using TIAM.Models.Dtos.Users;
|
||||
|
||||
|
||||
namespace TIAMWebApp.Client.Services
|
||||
|
|
@ -37,26 +38,26 @@ namespace TIAMWebApp.Client.Services
|
|||
|
||||
public async Task<UserSessionModel> IsLoggedInAsync(Guid id)
|
||||
{
|
||||
UserSessionModel User = null;
|
||||
UserSessionModel user = null;
|
||||
//api call to get user
|
||||
var dbUser = await GetUserByIdAsync(id);
|
||||
var userModelDto = await GetUserByIdAsync(id);
|
||||
|
||||
if (dbUser != null)
|
||||
if (userModelDto != null)
|
||||
{
|
||||
var a = dbUser.UserProductMappings.FirstOrDefault().Product;
|
||||
var a = userModelDto.UserProductMappings.FirstOrDefault()?.Product;
|
||||
|
||||
if (a != null)
|
||||
logToBrowserConsole.LogToBC($"{a.Name}");
|
||||
|
||||
//get user's properties
|
||||
var hasProperties = await serviceProviderDataService.GetPropertiesByOwnerIdAsync(dbUser.Id);
|
||||
var hasProperties = await serviceProviderDataService.GetPropertiesByOwnerIdAsync(userModelDto.Id);
|
||||
|
||||
if (hasProperties != null)
|
||||
logToBrowserConsole.LogToBC($"{hasProperties.Count} properties found");
|
||||
|
||||
//create user session model
|
||||
User = new UserSessionModel(dbUser.Id, UserType.User, dbUser.EmailAddress, hasProperties, 1);
|
||||
return User;
|
||||
user = new UserSessionModel(userModelDto.Id, UserType.User, userModelDto.Profile?.Name, hasProperties, 1);
|
||||
return user;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -130,24 +131,24 @@ namespace TIAMWebApp.Client.Services
|
|||
return (isSuccess, result);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<User>?> GetUsersAsync()
|
||||
public async Task<IEnumerable<UserModelDto>?> GetUsersAsync()
|
||||
{
|
||||
return await http.GetFromJsonAsync<IEnumerable<User>>(APIUrls.GetUsers);
|
||||
return await http.GetFromJsonAsync<IEnumerable<UserModelDto>>(APIUrls.GetUsers);
|
||||
}
|
||||
|
||||
public async Task<User?> GetUserByEmailAsync(string email)
|
||||
public async Task<UserModelDto?> GetUserByEmailAsync(string email)
|
||||
{
|
||||
var url = $"{Setting.BaseUrl}/{APIUrls.GetUserByEmail}";
|
||||
return await http.GetFromJsonAsync<User?>(url);
|
||||
return await http.GetFromJsonAsync<UserModelDto?>(url);
|
||||
}
|
||||
|
||||
public async Task<User?> GetUserByIdAsync(Guid Id)
|
||||
public async Task<UserModelDto?> GetUserByIdAsync(Guid id)
|
||||
{
|
||||
var url = $"{Setting.BaseUrl}/{APIUrls.GetUserById}";
|
||||
logToBrowserConsole.LogToBC("GetUserByIdAsync url: " + url + ", " + Id.ToString());
|
||||
var response = await http.PostAsJsonAsync(url, Id);
|
||||
logToBrowserConsole.LogToBC("GetUserByIdAsync url: " + url + ", " + id.ToString());
|
||||
var response = await http.PostAsJsonAsync(url, id);
|
||||
var result = await response.Content.ReadAsStringAsync();
|
||||
var user = JsonConvert.DeserializeObject<User>(result);
|
||||
var user = JsonConvert.DeserializeObject<UserModelDto>(result);
|
||||
return user;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ using Microsoft.EntityFrameworkCore;
|
|||
using TIAM.Database.DataLayers.Users;
|
||||
using AyCode.Utils.Helpers;
|
||||
using TIAM.Entities.Users;
|
||||
using TIAM.Models.Dtos.Users;
|
||||
using TIAMWebApp.Server.ModelsTIAMWebApp.Shared.Application.Models;
|
||||
using TIAMWebApp.Shared.Application.Utility;
|
||||
|
||||
|
|
@ -322,34 +323,33 @@ namespace TIAMWebApp.Server.Controllers
|
|||
[AllowAnonymous]
|
||||
[HttpGet]
|
||||
[Route("GetUsers")]
|
||||
public Task<List<User>> GetUsers()
|
||||
public Task<List<UserModelDto>> GetUsers()
|
||||
{
|
||||
//var users = await _userDal.Ctx.Users.ToListAsync();//.GetUsersAsync();
|
||||
//return users;
|
||||
return _userDal.GetUsersAsync();
|
||||
return _userDal.GetAllUsersModelDtoAsync();
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpGet]
|
||||
[Route("GetUserByEmail")]
|
||||
public async Task<User?> GetUserByEmail(string email)
|
||||
public Task<UserModelDto?> GetUserByEmail(string email)
|
||||
{
|
||||
return await _userDal.GetUserByEmailAsync(email);
|
||||
return _userDal.GetUserModelDtoByEmailAsync(email);
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
[Route("GetUserById")]
|
||||
public User? GetUserById([FromBody] Guid id)
|
||||
public Task<UserModelDto?> GetUserById([FromBody] Guid id)
|
||||
{
|
||||
Logger.Info($"GetUserById called with id: {id}");
|
||||
var result = _userDal.GetUserById(id);
|
||||
var b = result.UserProductMappings.FirstOrDefault(x => x.Id != null);
|
||||
var result = _userDal.GetUserModelDtoByIdAsync(id);
|
||||
|
||||
var a = JsonSerializer.Serialize(result);
|
||||
//var b = result.UserProductMappings.FirstOrDefault(x => x.Id != null);
|
||||
//var a = JsonSerializer.Serialize(result);
|
||||
//Console.WriteLine($"GetUserById result: {a}");
|
||||
|
||||
|
||||
Console.WriteLine($"GetUserById result: {a}");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TIAM.Entities.Users;
|
||||
using TIAM.Models.Dtos.Users;
|
||||
using TIAMWebApp.Shared.Application.Models;
|
||||
using TIAMWebApp.Shared.Application.Models.PageModels;
|
||||
|
||||
|
|
@ -21,8 +22,8 @@ namespace TIAMWebApp.Shared.Application.Interfaces
|
|||
|
||||
//public Task<Dictionary<int, string>> GetUserRolesAsync(UserModel userModel);
|
||||
|
||||
public Task<IEnumerable<User>?> GetUsersAsync();
|
||||
public Task<User?> GetUserByEmailAsync(string email);
|
||||
public Task<IEnumerable<UserModelDto>?> GetUsersAsync();
|
||||
public Task<UserModelDto?> GetUserByEmailAsync(string email);
|
||||
Task<bool> RefreshToken();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using TIAM.Entities.Users;
|
||||
|
||||
namespace TIAMWebApp.Shared.Application.Models
|
||||
|
|
@ -7,17 +8,18 @@ namespace TIAMWebApp.Shared.Application.Models
|
|||
{
|
||||
public Guid UserId { get; set; }
|
||||
public UserType UserType { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string? UserName { get; set; }
|
||||
public string DisplayName => string.IsNullOrWhiteSpace(UserName) ? UserId.ToString() : UserName;
|
||||
|
||||
public Dictionary<Guid, string>? HasProperties { get; set; }
|
||||
public int UserRoles { get; set; }
|
||||
public Dictionary<int, string> UserRolesDictionary { get; set; }
|
||||
|
||||
public UserSessionModel(Guid userId, UserType userType, string email, Dictionary<Guid, string>? hasProperties, int userRoles)
|
||||
public UserSessionModel(Guid userId, UserType userType, string? userName, Dictionary<Guid, string>? hasProperties, int userRoles)
|
||||
{
|
||||
UserId = userId;
|
||||
UserType = userType;
|
||||
Email = email;
|
||||
UserName = userName;
|
||||
HasProperties = hasProperties;
|
||||
//UserRoles = userRoles;
|
||||
//UserRolesDictionary = new Dictionary<int, string>();
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
<ProjectReference Include="..\..\TIAM.Entities.Server\TIAM.Entities.Server.csproj" />
|
||||
<ProjectReference Include="..\..\TIAM.Entities\TIAM.Entities.csproj" />
|
||||
<ProjectReference Include="..\..\TIAM.Models\TIAM.Models.csproj" />
|
||||
<ProjectReference Include="..\..\TIAMResources\TIAM.Resources.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -33,9 +33,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AyCode.Blazor.Models", "..\
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AyCode.Blazor.Models.Server", "..\Aycode.Blazor\AyCode.Blazor.Models.Server\AyCode.Blazor.Models.Server.csproj", "{A36322E8-F485-455E-84AA-B911948B6702}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TIAM.Models", "TIAM.Models\TIAM.Models.csproj", "{6037FF79-88D2-457C-BA3A-9AC978873741}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TIAM.Models", "TIAM.Models\TIAM.Models.csproj", "{6037FF79-88D2-457C-BA3A-9AC978873741}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TIAM.Resources", "TIAMResources\TIAM.Resources.csproj", "{2A300982-AA2E-4E62-97F2-6EF4C97939B2}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TIAM.Resources", "TIAMResources\TIAM.Resources.csproj", "{2A300982-AA2E-4E62-97F2-6EF4C97939B2}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
|
@ -105,6 +105,14 @@ Global
|
|||
{A36322E8-F485-455E-84AA-B911948B6702}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A36322E8-F485-455E-84AA-B911948B6702}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A36322E8-F485-455E-84AA-B911948B6702}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6037FF79-88D2-457C-BA3A-9AC978873741}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6037FF79-88D2-457C-BA3A-9AC978873741}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6037FF79-88D2-457C-BA3A-9AC978873741}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6037FF79-88D2-457C-BA3A-9AC978873741}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2A300982-AA2E-4E62-97F2-6EF4C97939B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2A300982-AA2E-4E62-97F2-6EF4C97939B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2A300982-AA2E-4E62-97F2-6EF4C97939B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2A300982-AA2E-4E62-97F2-6EF4C97939B2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
|||
Loading…
Reference in New Issue