spit on that Thang CHO BOC
spit on that Thang CHO BOC
CC#
Created by spit on that Thang CHO BOC on 2/10/2025 in #help
BL Mapping help
Should I just put raw EF entities instead of CreateDto's?
// Order header record
public class RestauraceObjednavkaHeaderCreateDto
{
public string? HeaderId { get; set; }
public required int StulId { get; set; }
public Status StatusStolu { get; set; } = Status.Open;

// Table Actions of the table
public List<RestauraceAkceStoluCreateDto> AkceStolu { get; set; } = [];

// All the products in the Table
public List<RestauraceObjednavkaPolozkyCreateDto> Polozky { get; set; } = [];
}
// Order header record
public class RestauraceObjednavkaHeaderCreateDto
{
public string? HeaderId { get; set; }
public required int StulId { get; set; }
public Status StatusStolu { get; set; } = Status.Open;

// Table Actions of the table
public List<RestauraceAkceStoluCreateDto> AkceStolu { get; set; } = [];

// All the products in the Table
public List<RestauraceObjednavkaPolozkyCreateDto> Polozky { get; set; } = [];
}
The logic I wanted to concieve: The waiter (role we getting from auth) opens up a table it will create using this DTO He can Directly order items(polozky) on the specified table Id . And the Action will be created immediately because I track Opening tables too. The Entity I am refering to:
public class RestauraceObjednavkaHeader
{
public required string RestauraceObjednavkaHeaderId { get; set; }

// Foreign key | Restaurace_Akce_Stolu N:1 Header
public required ICollection<RestauraceAkceStolu> RestauraceAkceStolu { get; set; } = [];

// Navigation property | Restaurace_Objednavka_Header N:1 Stul
public required int StulId { get; set; }
public required Stul Stul { get; set; }

// Table status
public required Status StatusStolu { get; set; } = Status.Open;

// Navigation property | Restaurace_Transakce_Id N:1 Header
public required ICollection<RestauraceTransakce> Transakce { get; set; } = [];

// Navigation property | Restaurace_Objednavka_Header 1:N Polozka
public required ICollection<RestauraceObjednavkaPolozky> Polozka { get; set; } = [];
}
public class RestauraceObjednavkaHeader
{
public required string RestauraceObjednavkaHeaderId { get; set; }

// Foreign key | Restaurace_Akce_Stolu N:1 Header
public required ICollection<RestauraceAkceStolu> RestauraceAkceStolu { get; set; } = [];

// Navigation property | Restaurace_Objednavka_Header N:1 Stul
public required int StulId { get; set; }
public required Stul Stul { get; set; }

// Table status
public required Status StatusStolu { get; set; } = Status.Open;

// Navigation property | Restaurace_Transakce_Id N:1 Header
public required ICollection<RestauraceTransakce> Transakce { get; set; } = [];

// Navigation property | Restaurace_Objednavka_Header 1:N Polozka
public required ICollection<RestauraceObjednavkaPolozky> Polozka { get; set; } = [];
}
But when I use the CreateDto's I need to specify their Entity too (making sense that I would need it to specify) But that seems to me like Service rather than Mapping as a whole
16 replies
CC#
Created by spit on that Thang CHO BOC on 2/10/2025 in #help
BL Mapping help
Ohh okay I thought directly using [MapProperty]
16 replies
CC#
Created by spit on that Thang CHO BOC on 2/10/2025 in #help
BL Mapping help
The thing is i don't have much experience with mapping and DTO's Should I ignore it or Map it? The child DTO is the question since I have everything required since I had imagined it worked that way I have to define(map) the whole create dto if that scenario happends or can I just opt to ignore it
16 replies
CC#
Created by spit on that Thang CHO BOC on 2/10/2025 in #help
BL Mapping help
Mapperly
16 replies
CC#
Created by spit on that Thang CHO BOC on 2/9/2025 in #help
I don't understand this warning: BL Mapping (Mapperly)
Also One more question regarding DTO mapping do you think using CreateDTO inside another CreateDTO is better than using directly from Entity? Entity attribute
// FK
public required ICollection<RestauraceAkceStolu> RestauraceAkceStolu { get; set; } = [];
// FK
public required ICollection<RestauraceAkceStolu> RestauraceAkceStolu { get; set; } = [];
or what I have currently?
public List<RestauraceAkceStoluCreateDto> AkceStolu { get; set; } = [];
public List<RestauraceAkceStoluCreateDto> AkceStolu { get; set; } = [];
10 replies
CC#
Created by spit on that Thang CHO BOC on 2/9/2025 in #help
I don't understand this warning: BL Mapping (Mapperly)
[MapperIgnoreTarget(nameof(RestauraceAkceStolu.User))]
[MapperIgnoreTarget(nameof(RestauraceAkceStolu.Header))]

[MapperIgnoreSource(nameof(RestauraceAkceStolu.User))]
[MapperIgnoreSource(nameof(RestauraceAkceStolu.Header))]
[MapperIgnoreTarget(nameof(RestauraceAkceStolu.User))]
[MapperIgnoreTarget(nameof(RestauraceAkceStolu.Header))]

[MapperIgnoreSource(nameof(RestauraceAkceStolu.User))]
[MapperIgnoreSource(nameof(RestauraceAkceStolu.Header))]
10 replies
CC#
Created by spit on that Thang CHO BOC on 2/9/2025 in #help
I don't understand this warning: BL Mapping (Mapperly)
So i just ignore it?
10 replies
CC#
Created by spit on that Thang CHO BOC on 2/9/2025 in #help
I don't understand this warning: BL Mapping (Mapperly)
hmmm
10 replies
CC#
Created by spit on that Thang CHO BOC on 2/9/2025 in #help
I don't understand this warning: BL Mapping (Mapperly)
but its a NAV property though?
10 replies
CC#
Created by spit on that Thang CHO BOC on 2/9/2025 in #help
I don't understand this warning: BL Mapping (Mapperly)
10 replies
CC#
Created by spit on that Thang CHO BOC on 2/4/2025 in #help
Keyboard shortcuts always resetting after restart
My bad, just assumed visual studio was the norm but yeah I can't seem to find the reason why keyboard shortcut is being overridden
16 replies
CC#
Created by spit on that Thang CHO BOC on 2/1/2025 in #help
BL - UserManager custom role
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.DependencyInjection;
using ZelnyTrh.EF.BL;
using ZelnyTrh.EF.DAL.Entities;

namespace ZelnyTrh.EF.DAL.Seeders;

public class RoleSeeder
{
public static async Task SeedRolesAndAdminAsync(IServiceProvider serviceProvider)
{
using var scope = serviceProvider.CreateScope();
var roleManager = scope.ServiceProvider.GetRequiredService<RoleManager<IdentityRole>>();
var userManager = scope.ServiceProvider.GetRequiredService<UserManager<ApplicationUser>>();

// Seed roles
string[] roleNames = [UserRoles.Administrator, UserRoles.Moderator, UserRoles.User];
foreach (var roleName in roleNames)
{
if (!await roleManager.RoleExistsAsync(roleName))
{
await roleManager.CreateAsync(new IdentityRole(roleName));
}
}

// Seed admin user
var adminEmail = "[email protected]";
var adminUser = await userManager.FindByEmailAsync(adminEmail);

if (adminUser == null)
{
var admin = new ApplicationUser
{
UserName = adminEmail,
Email = adminEmail,
EmailConfirmed = true,
Name = "System Administrator"
};

// Very bad
// TODO: Fix this
var result = await userManager.CreateAsync(admin, "Admin123!");
if (result.Succeeded)
{
await userManager.AddToRoleAsync(admin, UserRoles.Administrator);
}
}
}
}
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.DependencyInjection;
using ZelnyTrh.EF.BL;
using ZelnyTrh.EF.DAL.Entities;

namespace ZelnyTrh.EF.DAL.Seeders;

public class RoleSeeder
{
public static async Task SeedRolesAndAdminAsync(IServiceProvider serviceProvider)
{
using var scope = serviceProvider.CreateScope();
var roleManager = scope.ServiceProvider.GetRequiredService<RoleManager<IdentityRole>>();
var userManager = scope.ServiceProvider.GetRequiredService<UserManager<ApplicationUser>>();

// Seed roles
string[] roleNames = [UserRoles.Administrator, UserRoles.Moderator, UserRoles.User];
foreach (var roleName in roleNames)
{
if (!await roleManager.RoleExistsAsync(roleName))
{
await roleManager.CreateAsync(new IdentityRole(roleName));
}
}

// Seed admin user
var adminEmail = "[email protected]";
var adminUser = await userManager.FindByEmailAsync(adminEmail);

if (adminUser == null)
{
var admin = new ApplicationUser
{
UserName = adminEmail,
Email = adminEmail,
EmailConfirmed = true,
Name = "System Administrator"
};

// Very bad
// TODO: Fix this
var result = await userManager.CreateAsync(admin, "Admin123!");
if (result.Succeeded)
{
await userManager.AddToRoleAsync(admin, UserRoles.Administrator);
}
}
}
}
but now I might do like I mentioned inside program.cs
public async Task SeedRolesAsync(RoleManager<IdentityRole> roleManager)
{
var defaultRole = "User";
if (!await roleManager.RoleExistsAsync(defaultRole))
{
await roleManager.CreateAsync(new IdentityRole(defaultRole));
}
}
public async Task SeedRolesAsync(RoleManager<IdentityRole> roleManager)
{
var defaultRole = "User";
if (!await roleManager.RoleExistsAsync(defaultRole))
{
await roleManager.CreateAsync(new IdentityRole(defaultRole));
}
}
2 replies
CC#
Created by spit on that Thang CHO BOC on 1/25/2025 in #help
Performance loss on using united id?
this segment: https://github.com/ThangChoBoc/DALandBL/blob/719f553617236e46f98e10093b35cf7cbc6412c7/DAL/Seeders/Seeders.cs#L84-L87 That's already the default? Why do you need that? i think i put everything required so that might be case here (i forgot)
68 replies
CC#
Created by spit on that Thang CHO BOC on 1/25/2025 in #help
Performance loss on using united id?
thank you for the feedback! I have learned a lot from this interaction
68 replies
CC#
Created by spit on that Thang CHO BOC on 1/25/2025 in #help
Performance loss on using united id?
The seeders was a requirement for the course they wanted us to send the sln for them to run the database from scratch and when ran it should not be empty. In my case now with the new project I don't have this concern although I feel like if I want to sell them something they should be able to run locally without the seeders tbh. (maybe seeding for the items like producs) Essentially the new project is a web app that will behave like this site which will be my main competitor if I manage to sucessfully make it work flawlessly (gokasa.cz)
68 replies
CC#
Created by spit on that Thang CHO BOC on 1/25/2025 in #help
Performance loss on using united id?
the thing is i can do basics but i didnt how to use sql strings code might have to look into it if I dont want to seach one table with generated 70+ LOC SQL calls to get the data I wanted like in the Github section i uploaded. Thank you for the insight, and yes I am following this cookbook from my uni course(it's for an standalone app but still using it for a web app) https://github.com/nesfit/ICS/tree/master/src/CookBook
68 replies
CC#
Created by spit on that Thang CHO BOC on 1/25/2025 in #help
Performance loss on using united id?
I will look further in this, thank you for the help 🙏
68 replies
CC#
Created by spit on that Thang CHO BOC on 1/25/2025 in #help
Performance loss on using united id?
I asked copilot so we use Mapper as a setting for the Automapper / Mapperly to get what we want?
You are correct. In a Blazor project, the Data Access Layer (DAL) should not depend on AutoMapper or similar libraries, as it should remain lightweight and focused on data operations. Instead, the Business Layer (BL) can utilize AutoMapper for mapping between entities and DTOs.
You are correct. In a Blazor project, the Data Access Layer (DAL) should not depend on AutoMapper or similar libraries, as it should remain lightweight and focused on data operations. Instead, the Business Layer (BL) can utilize AutoMapper for mapping between entities and DTOs.
68 replies
CC#
Created by spit on that Thang CHO BOC on 1/25/2025 in #help
Performance loss on using united id?
i wanted to make sure that the EF implementation is as good as it can get
68 replies
CC#
Created by spit on that Thang CHO BOC on 1/25/2025 in #help
Performance loss on using united id?
the other things like API and That i skipped because its not the main concern yet
68 replies