This sample allows you to highlight C# source code. Highlighting is based on http://hilite.me web service, which is called from a background job in a truly asynchronous way – neither controller, nor any other entity is waiting for a completion. Results are delivered via WebSockets using SignalR.

All the snippets are removed every day at 12:00 AM UTC.

    [AllowAnonymous]
    public async Task<SessionResult> CancelSessionAsync(Guid InstructorId, Guid SessionId, Guid Nonce)
    {
        // Nonce security required

        var entity = await Repository.FindAsync(SessionId);
        if (entity == null)
        {
            return new SessionResult
            {
                Successful = false,
                Code = SessionResult.UnknownSession,
                Message = L["Result:" + SessionResult.UnknownSession]
            };
        }

        using var tenantScope = CurrentTenant.Change(entity.TenantId);

        entity.SetSessionCancelled();
        await Repository.UpdateAsync(entity);

        return new SessionResult
        {
            Successful = true,
            Code = SessionResult.SuccessfullyCancelled,
            Message = L["Result:" + SessionResult.SuccessfullyCancelled]
        };
    }
Console.WriteLine("Hello, world!");