public ComputerController() { _computerService = new ComputerServices(); _auditLogService = new AuditLogServices(); _userId = Convert.ToInt32(((ClaimsIdentity)User.Identity).Claims.Where(c => c.Type == "user_id") .Select(c => c.Value).SingleOrDefault()); _auditLog = new AuditLogEntity(); _auditLog.ObjectType = "Computer"; _auditLog.UserId = _userId; var user = new UserServices().GetUser(_userId); if (user != null) { _auditLog.UserName = user.Name; } }