I’ve been studying backend development using .NET for about six months, creating personal projects that involve full-stack development. At first, I was comfortable with simple operations like GET requests and POST methods to save information to SQL Server. I felt like I was making good progress.
Then came the challenge of a complex endpoint. This one required multitasking, such as verifying foreign keys from three different tables, checking product inventory, updating stock levels, and recording orders all at once.
To complicate matters, I have a CreateOrderDto that includes a CustomerDto and a list of OrderItemDtos, and each OrderItemDto references a ProductDto. Now I’m tasked with mapping all that back to my EF Core entities through AutoMapper or manual methods.
I’m left wondering how to tackle this. Should I implement all of this logic within the controller, or break it out into separate services? How do I manage transactions where several database actions need to succeed or fail together?
Basic tutorials tend to simplify things, showing how to save a product but not tackling the complexities of handling multiple linked operations. How did you manage when you faced similar challenges? Did you find techniques or strategies that made the process easier?