public async Task <IActionResult> Find([FromRoute] long id) { var catalog = new ItemCatalog(_dbContext, _messageBroker); var tenantId = User.Claims.TenantId(); await catalog.Find(tenantId, id); if (catalog.ItemNotExists) { return(new ItemNotFoundError()); } return(new ItemJson(catalog.Item)); }
public async Task <IActionResult> Update([FromRoute] long id, [FromBody] SaveItemJson json) { var catalog = new ItemCatalog(_dbContext, _messageBroker); var tenantId = User.Claims.TenantId(); await catalog.Find(tenantId, id); if (catalog.ItemNotExists) { return(new ItemNotFoundError()); } json.MapTo(catalog.Item); await catalog.Update(); if (catalog.GroupNotExists) { return(new ItemGroupNotFoundError()); } return(new ItemJson(catalog.Item)); }