Quantcast
Channel: Active questions tagged use-case - Stack Overflow
Viewing all articles
Browse latest Browse all 81

Use case splitting

$
0
0

Which is best way to split Use Case?

I have the following architecture (Clean Architecture):

 - Project.Api - - Project.Api.Controllers.TodoController - Project.Application -- Project.Application.Todos.Commands.CreateTodo - Project.Core - - Project.Repositories.ITodoRepository - - Project.Entities.Todo

CreateTodo command creates and saves TODO through repository.

var todo = new Todo(...);await _todoRepository.Add(todo, cancellationToken);

But after creating TODO i need to make other things. For example:

 - Schedule notification about added TODO - Generate short link for TODO

And if i will do it in same command i will get next:

var todo = new Todo(...);await _todoRepository.Add(todo, cancellationToken);var notification = new Notification(...);await _notificationRepository.Add(...);var shortLink = new ShortLink(todo.Id, ...);await _shortLinkRepository.Add(...);

Also other things can have additional logic(try catch, retry politics, validation etc).

And them can be slow, but i want to return result immediately.

I can create worker service for other things but its see not correct and difficult, also its one use-case is it correct to separate it?

How i can solve it?


Viewing all articles
Browse latest Browse all 81

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>