File tree Expand file tree Collapse file tree
Catalog/Catalog.API/Controllers
Ordering/Ordering.Infrastructure
test/Services/FunctionalTests/Services/Catalog Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -130,6 +130,7 @@ public async Task<IActionResult> CatalogBrands()
130130 return Ok ( items ) ;
131131 }
132132
133+ //POST api/v1/[controller]/edit
133134 [ Route ( "edit" ) ]
134135 [ HttpPost ]
135136 public async Task < IActionResult > EditProduct ( [ FromBody ] CatalogItem product )
@@ -164,6 +165,7 @@ public async Task<IActionResult> EditProduct([FromBody]CatalogItem product)
164165 return Ok ( ) ;
165166 }
166167
168+ //POST api/v1/[controller]/create
167169 [ Route ( "create" ) ]
168170 [ HttpPost ]
169171 public async Task < IActionResult > CreateProduct ( [ FromBody ] CatalogItem product )
@@ -184,6 +186,7 @@ public async Task<IActionResult> CreateProduct([FromBody]CatalogItem product)
184186 return Ok ( ) ;
185187 }
186188
189+ //DELETE api/v1/[controller]/id
187190 [ Route ( "{id}" ) ]
188191 [ HttpDelete ]
189192 public async Task < IActionResult > DeleteProduct ( int id )
Original file line number Diff line number Diff line change @@ -237,10 +237,18 @@ void ConfigureCardTypes(EntityTypeBuilder<CardType> cardTypesConfiguration)
237237
238238 public async Task < int > SaveEntitiesAsync ( CancellationToken cancellationToken = default ( CancellationToken ) )
239239 {
240+ // Dispatch Domain Events collection.
241+ // Choices:
242+ // A) Right BEFORE committing data (EF SaveChanges) into the DB will make a single transaction including
243+ // side effects from the domain event handlers which are using the same DbContext with "InstancePerLifetimeScope" or "scoped" lifetime
244+ // B) Right AFTER committing data (EF SaveChanges) into the DB will make multiple transactions.
245+ // You will need to handle eventual consistency and compensatory actions in case of failures in any of the Handlers.
246+ await _mediator . DispatchDomainEventsAsync ( this ) ;
247+
248+
249+ // After executing this line all the changes performed thought the DbContext will be commited
240250 var result = await base . SaveChangesAsync ( ) ;
241251
242- // Dispatch the Domain Events collection right after saving/committing data into the database
243- await _mediator . DispatchDomainEventsAsync ( this ) ;
244252 return result ;
245253 }
246254 }
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ public static string ProductByName(string name)
3434
3535 public static class Post
3636 {
37- public static string UpdateCatalogProduct = "api/v1/catalog" ;
37+ public static string UpdateCatalogProduct = "api/v1/catalog/edit " ;
3838 }
3939 }
4040}
You can’t perform that action at this time.
0 commit comments