Clean architectures involves handler which takes commands as input and responses as outputs For example: We have a model

public class Lecture
    public int Id { get; set; }
    public string Name { get; set; }
    public List<Student> Students { get; set; }

and a Sync Controller Action which takes all students and lectures to save them in database in one call.

My question is how many handlers we should make in this scenerio? Only SyncLecture Handler or SyncStudent Handler as well ?

Another problem is that how can we include multiple repositories in single handler? Is it semantic approach?

Finally, if we use multiple repositories or even multiple handler in the same controller action, How can we make it atomic. So that students are saved but we we got some error on lectures so student must not be saved either. We do this using transaction in DB context. but in this scenerio. I don't know how to deal with it.

Please help me thank you

  • \$\begingroup\$ This question is not asking for a review, it is asking for an answer. This is off-topic for CodeReview.SE. Here, you are expected to posting working code to have it reviewed for improvement. \$\endgroup\$
    – Flater
    Nov 23 at 11:24