예제 #1
0
        public IActionResult Post([FromBody] Launch launch)
        {
            var schema = JsonSchema <Launch> .IsValid(launch, "launch-schema.json");

            if (schema.valid)
            {
                return(new CreatedResult("", launch));
            }

            return(new ConflictObjectResult(schema.mesage));
        }
예제 #2
0
        public IActionResult Post([FromBody] Transfer transfer)
        {
            var(valid, mesage) = JsonSchema <Transfer> .IsValid(transfer, "transfer-schema.json");

            if (valid)
            {
                try
                {
                    var result = _transferService.Transfer(transfer);
                    if (result == OperationStatus.Success)
                    {
                        return(new CreatedResult(string.Empty, null));
                    }

                    return(new BadRequestObjectResult(new { message = result.Description() }));
                }
                catch
                {
                    return(new BadRequestResult());
                }
            }

            return(new ConflictObjectResult(mesage));
        }