KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Lets say I have an entity called User which has many Posts. My service looks like this for the deletion of a post: void DeletePost(int postId, int userId); Where does my validation code go? (ensure that the user has permission to delete). Should I do this in the repository with 1 database call? Or should I do this check in the Service layer where I make 2 calls: Get the user by userId. Call delete after validation has been done on the user. I will have 2 repositories, 1 for the user and 1 for the post, each looking like this: // From the PostRepository. void Delete(int postId); //May have to add a userId param if I do validation in repository //From the UserRepository. User GetUser(int userId);
Tags (comma-separated)
Save Edits
Cancel