Example #1
0
        public async Task <IActionResult> SaveDataItemAsync([FromRoute] int diffId, [FromRoute] string itemSideName, [FromBody] DataItemRequest request)
        {
            if (!EnumHelper.TryParse(itemSideName, out DiffItemSide itemSide))
            {
                return(NotFound());
            }

            try
            {
                await _diffService.SaveDataItemAsync(diffId, itemSide, request?.Data);

                return(Created($"/v1/diff/{diffId}", diffId));
            }
            catch (InvalidOperationException ex)
            {
                return(BadRequest(ex.Message));
            }
            catch (ArgumentException ex)
            {
                return(BadRequest(ex.Message));
            }
        }