Skip to content

Commit

Permalink
[Front] Merge PhotoList | MovePhoto onSuccess - [Back] ProductPostMov…
Browse files Browse the repository at this point in the history
…ePhoto
  • Loading branch information
Aloento committed Feb 28, 2024
1 parent d13b0ab commit 3d9c6b2
Show file tree
Hide file tree
Showing 11 changed files with 805 additions and 622 deletions.
21 changes: 9 additions & 12 deletions TSystems.LoveOTC/AdminHub/Product/Post.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,38 +38,35 @@ public async Task<uint> ProductPostCreate(string name) {
* <remarks>
* @author Aloento
* @since 0.5.0
* @version 0.1.0
* @version 1.0.0
* </remarks>
*/
public async Task<bool> ProductPostMovePhoto(uint photoId, bool up) {
var orders = await this.Db.Photos
var photos = await this.Db.Photos
.Where(x => x.ProductId == this.Db.Photos
.Where(y => y.PhotoId == photoId)
.Select(z => z.ProductId)
.Single())
.OrderBy(x => x.Order)
.ToListAsync();

var index = orders.FindIndex(x => x.PhotoId == photoId);
var current = orders[index].Order;
var index = photos.FindIndex(x => x.PhotoId == photoId);
var current = photos[index].Order;

if (up) {
if (current == 1)
throw new HubException("Photo already at top");

orders[index - 1].Order = current;
orders[index].Order = (byte)(current - 1);
photos[index - 1].Order = current;
photos[index].Order = (byte)(current - 1);
} else {
if (current == orders.Last().Order)
if (current == photos.Last().Order)
throw new HubException("Photo already at bottom");

orders[index + 1].Order = current;
orders[index].Order = (byte)(current + 1);
photos[index + 1].Order = current;
photos[index].Order = (byte)(current + 1);
}

for (byte i = 0; i < orders.Count; i++)
orders[i].Order = (byte)(i + 1);

await this.Db.SaveChangesAsync();
return true;
}
Expand Down
18 changes: 9 additions & 9 deletions TSystems.LoveOTC/TSystems.LoveOTC.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,23 @@
<ItemGroup>
<PackageReference Include="DocumentFormat.OpenXml" Version="3.0.1" />
<PackageReference Include="JetBrains.Annotations" Version="2023.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.1">
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="8.0.2" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="8.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.1">
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="8.0.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.2" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.2" />
<PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="8.101.2.1" />
<PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="8.102.1.1" />
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "loveotc",
"private": true,
"version": "1.3.5",
"version": "1.4.0",
"type": "module",
"author": {
"name": "Aloento",
Expand All @@ -15,9 +15,9 @@
"update": "npx npm-check-updates -u"
},
"dependencies": {
"@fluentui/react-components": "^9.46.4",
"@fluentui/react-components": "^9.46.6",
"@fluentui/react-hooks": "^8.6.36",
"@fluentui/react-icons": "^2.0.227",
"@fluentui/react-icons": "^2.0.230",
"@griffel/react": "^1.5.20",
"@lexical/clipboard": "0.10.0",
"@lexical/code": "0.10.0",
Expand Down Expand Up @@ -52,10 +52,10 @@
},
"devDependencies": {
"@types/lodash-es": "^4.17.12",
"@types/react": "^18.2.56",
"@types/react": "^18.2.60",
"@types/react-dom": "^18.2.19",
"@vitejs/plugin-react-swc": "^3.6.0",
"typescript": "^5.3.3",
"vite": "^5.1.3"
"vite": "^5.1.4"
}
}
Loading

0 comments on commit 3d9c6b2

Please sign in to comment.