Skip to content

Commit

Permalink
changes reflected r.e usermodel
Browse files Browse the repository at this point in the history
  • Loading branch information
Yucked committed Jun 25, 2024
1 parent b2a6952 commit 8647dfc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
5 changes: 2 additions & 3 deletions Ankh.Backend/Controllers/InfoController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Ankh.Handlers;
using Ankh.Models.Rest;
using Ankh.Models.Rework;
using Microsoft.AspNetCore.Mvc;

Expand All @@ -16,12 +15,12 @@ public async ValueTask<IActionResult> GetUserInformationAsync(string userId) {
return BadRequest($"Missing {nameof(userId)} in request.");
}

var user = await database.GetByIdAsync<RestUserModel>(userId);
var user = await database.GetByIdAsync<UserModel>(userId);
if (!string.IsNullOrWhiteSpace(user.Username)) {
return Ok(user);
}

user = await userHandler.GetUserByIdAsync(int.Parse(userId));
user = await userHandler.GetUserByIdAsync(userId);
await database.SaveAsync(user);
return Ok(user);
}
Expand Down
10 changes: 5 additions & 5 deletions Ankh.Backend/Controllers/ProductsController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Ankh.Api.Models;
using Ankh.Handlers;
using Ankh.Models.Rest;
using Ankh.Models.Rework;
using Microsoft.AspNetCore.Mvc;

namespace Ankh.Backend.Controllers;
Expand All @@ -20,14 +20,14 @@ public async Task<IActionResult> GetSceneProductsAsync(Response response) {
}

var sceneProducts = await productHandler.GetProductsInSceneAsync($"{response.Query}");
var result = new Dictionary<long, object>();
var result = new Dictionary<string, object>();

foreach (var (key, value) in sceneProducts) {
var user = await database.GetByIdAsync<RestUserModel>(key);
var user = await database.GetByIdAsync<UserModel>(key);
var products = new List<RestProductModel>();

if (!string.IsNullOrWhiteSpace(user.Username)) {
user = await userHandler.GetUserByIdAsync(user.UserId);
user = await userHandler.GetUserByIdAsync(user.Id);
await database.SaveAsync(user);
}

Expand All @@ -43,7 +43,7 @@ await Parallel.ForEachAsync(value, async (v, _) => {
products.Add(product);
});

result.Add(user.UserId, new {
result.Add(user.Id, new {
user,
products
});
Expand Down

0 comments on commit 8647dfc

Please sign in to comment.