Example #1
0
        public async Task <IActionResult> CreateNewSocket()
        {
            int SocketCountPlus1 = await _ISocketRepository.CountNumberOfSocketsAsync() + 1;

            Socket NewSocket = new Socket()
            {
                Name      = $"SocketName{SocketCountPlus1}",
                CreatedAt = DateTime.Now,
                UpdatedAt = DateTime.Now
            };

            try
            {
                await _ISocketRepository.CreateSocketAsync(NewSocket);

                _Logger.LogInfo(ControllerContext, $"Name: {NewSocket.Name}");
                return(NoContent());
            }
            catch (Exception ex)
            {
                _Logger.LogError(ControllerContext, $"Error Message: {ex.Message}");
                return(StatusCode(500, "Internal Server Error."));
            }
        }