Exemplo n.º 1
0
        public async Task <IActionResult> UpdateSocket(int id)
        {
            try
            {
                Socket SocketToUpdate = await _ISocketRepository.GetSocketByIDAsync(id);

                if (SocketToUpdate == null)
                {
                    _Logger.LogError(ControllerContext, $"Error Message: Socket with the id: {id} is not in the database.");
                    return(StatusCode(500, "Internal Server Error."));
                }
                _Logger.LogInfo(ControllerContext, $"Socket with the id: {id} has been updated.");

                SocketToUpdate.UpdatedAt = DateTime.Now;
                await _ISocketRepository.UpdateSocketAsync(SocketToUpdate);

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