Skip to content

Commit a07207a

Browse files
committed
Merge branch 'dev' of https://github.com/dotnet/eShopOnContainers into dev
2 parents 6f8512f + 696610e commit a07207a

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff 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)

src/Services/Ordering/Ordering.Infrastructure/OrderingContext.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff 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
}

test/Services/FunctionalTests/Services/Catalog/CatalogScenariosBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)