예제 #1
0
        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));
        }