@@ -42,27 +42,6 @@ public ActionResult<CustomerDto[]> GetAll()
4242 }
4343 }
4444
45- /// <summary>
46- /// Retrieves all customers along with their associated orders.
47- /// </summary>
48- /// <returns>
49- /// An <see cref="ActionResult{T}"/> containing an array of <see cref="CustomerDto"/> objects.
50- /// </returns>
51- [ HttpGet ( "WithOrders" ) ]
52- public ActionResult < CustomerDto [ ] > GetAllCustomersWithOrders ( )
53- {
54- try
55- {
56- var customers = this . customerService . GetAllCustomersWithOrders ( ) ;
57- return Ok ( this . mapper . Map < CustomerDb [ ] , CustomerDto [ ] > ( customers ) ) ;
58- }
59- catch ( Exception error )
60- {
61- logger . LogError ( error . Message ) ;
62- return StatusCode ( 500 ) ;
63- }
64- }
65-
6645 /// <summary>
6746 /// Fetches all customers or a page of customers based on the provided parameters.
6847 /// </summary>
@@ -142,6 +121,21 @@ public ActionResult<CountResultDto> GetCustomersCount()
142121 }
143122 }
144123
124+ [ HttpGet ( "WithOrders" ) ]
125+ public ActionResult < CustomerDto [ ] > GetAllCustomersWithOrders ( )
126+ {
127+ try
128+ {
129+ var customers = this . customerService . GetAllCustomersWithOrders ( ) ;
130+ return Ok ( this . mapper . Map < CustomerDb [ ] , CustomerDto [ ] > ( customers ) ) ;
131+ }
132+ catch ( Exception error )
133+ {
134+ logger . LogError ( error . Message ) ;
135+ return StatusCode ( 500 ) ;
136+ }
137+ }
138+
145139 [ HttpGet ( "{id}" ) ]
146140 public ActionResult < CustomerDto > GetById ( string id )
147141 {
@@ -178,6 +172,21 @@ public ActionResult<OrderDto[]> GetOrdersByCustomerId(string id)
178172 }
179173 }
180174
175+ [ HttpGet ( "{id}/Orders/WithDetails" ) ]
176+ public ActionResult < OrderDto [ ] > GetOrdersAndOrderDetailsByCustomerId ( string id )
177+ {
178+ try
179+ {
180+ var orders = this . orderService . GetOrdersWithDetailsByCustomerId ( id ) ;
181+ return Ok ( this . mapper . Map < OrderDb [ ] , OrderDto [ ] > ( orders ) ) ;
182+ }
183+ catch ( Exception error )
184+ {
185+ logger . LogError ( error . Message ) ;
186+ return StatusCode ( 500 ) ;
187+ }
188+ }
189+
181190 [ HttpPost ]
182191 [ Authorize ]
183192 public ActionResult < CustomerDto > Create ( CustomerDto model )
0 commit comments