Example #1
0
        public async Task <IActionResult> CreateGateway([FromBody] Gateway gateway)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                await _context.CreateGateway(gateway);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message, ex);
                return(StatusCode(500, "A problem happened while handling you request."));
            }


            return(CreatedAtAction("GetGateway", new { SerialNumber = gateway.SerialNumber }, gateway));
        }