schwartzmj
schwartzmj
Explore posts from servers
CC#
Created by schwartzmj on 8/12/2024 in #help
Catching unique constraint violations and returning the field(s) violating it in a "service" class
I appreciate the help!
36 replies
CC#
Created by schwartzmj on 8/12/2024 in #help
Catching unique constraint violations and returning the field(s) violating it in a "service" class
yea - i was hoping that this just existed in EF and I wasn't finding it
36 replies
CC#
Created by schwartzmj on 8/12/2024 in #help
Catching unique constraint violations and returning the field(s) violating it in a "service" class
Thanks — I saw this while I was searching around but I'm hesitant to add libraries without understanding all my options, but I'll look more into it
36 replies
CC#
Created by schwartzmj on 8/12/2024 in #help
Catching unique constraint violations and returning the field(s) violating it in a "service" class
Yeah I can imagine... I appreciate the help. I think I'll just add the unique checks before the create/update and call it a day
36 replies
CC#
Created by schwartzmj on 8/12/2024 in #help
Catching unique constraint violations and returning the field(s) violating it in a "service" class
(if i wanted to simplify this and keep moving)
36 replies
CC#
Created by schwartzmj on 8/12/2024 in #help
Catching unique constraint violations and returning the field(s) violating it in a "service" class
So basically, do a check on the slug and return a helpful error if it is taken. If the unlikely scenario happens where its taken right after the check, then just return a generic exception since it will probably never happen anyway
36 replies
CC#
Created by schwartzmj on 8/12/2024 in #help
Catching unique constraint violations and returning the field(s) violating it in a "service" class
Ok, thanks. So I might be best off making some sort of helper and re-using it in my services like this?
36 replies
CC#
Created by schwartzmj on 8/12/2024 in #help
Catching unique constraint violations and returning the field(s) violating it in a "service" class
this could still error after checking though (theoretically — if one was created in between)
36 replies
CC#
Created by schwartzmj on 8/12/2024 in #help
Catching unique constraint violations and returning the field(s) violating it in a "service" class
i've created a few helpers as you can see here, but i'm hoping to return some helpful information in my exception
36 replies
CC#
Created by schwartzmj on 8/12/2024 in #help
Catching unique constraint violations and returning the field(s) violating it in a "service" class
public async Task<Result<PostDto>> CreatePost(PostUpsertDto newPostDto)
{
try
{
var newPost = await dbContext.Posts.AddAsync(newPostDto.ToEntity());
await dbContext.SaveChangesAsync();
return Success(PostDto.FromPost(newPost.Entity));
} catch (DbUpdateException)
{
return Failure<PostDto>(new ErrorDetails("...", ErrorCode.Conflict));
}
}
public async Task<Result<PostDto>> CreatePost(PostUpsertDto newPostDto)
{
try
{
var newPost = await dbContext.Posts.AddAsync(newPostDto.ToEntity());
await dbContext.SaveChangesAsync();
return Success(PostDto.FromPost(newPost.Entity));
} catch (DbUpdateException)
{
return Failure<PostDto>(new ErrorDetails("...", ErrorCode.Conflict));
}
}
36 replies
FFilament
Created by schwartzmj on 4/25/2024 in #❓┊help
Subdomain / Domain based routing w/ Multitenancy. 419 Page Expired
or, i guess, rethink my app requirements and simplify it. dont allow a user to belong to multiple tenants etc 🤷‍♂️ . seems like i dont have a good enough grasp on the moving pieces here
12 replies
FFilament
Created by schwartzmj on 4/25/2024 in #❓┊help
Subdomain / Domain based routing w/ Multitenancy. 419 Page Expired
between these session issues, spatie's package and filament
12 replies
FFilament
Created by schwartzmj on 4/25/2024 in #❓┊help
Subdomain / Domain based routing w/ Multitenancy. 419 Page Expired
whole thing is quite confusing, might just have to ignore the filament tenancy stuff and handle it with policies or whatever
12 replies
FFilament
Created by schwartzmj on 4/25/2024 in #❓┊help
Subdomain / Domain based routing w/ Multitenancy. 419 Page Expired
nah, single-db multi-tenancy
12 replies
FFilament
Created by schwartzmj on 4/25/2024 in #❓┊help
Subdomain / Domain based routing w/ Multitenancy. 419 Page Expired
im actually getting a bit confused here. SESSION_DRIVER set to file seems to work now? (instead of database) i do get odd issues though like trying to login at the root domain is successful but then redirects you to the default tenant where you have to login again
12 replies
FFilament
Created by schwartzmj on 4/25/2024 in #❓┊help
Subdomain / Domain based routing w/ Multitenancy. 419 Page Expired
It seems this is caused by the isPersistent: true configuration option for admin panel middleware
12 replies
CC#
Created by schwartzmj on 4/26/2024 in #help
URL Parameters and/or data loading in layout files
if i have to do the logic in a page anyway
13 replies