Newer
Older
TestingWithoutInterfaces / src / BlazorAdmin / JavaScript / Cookies.cs
@Derek Comartin Derek Comartin on 5 Dec 2022 552 bytes Init
using System.Threading.Tasks;
using Microsoft.JSInterop;

namespace BlazorAdmin.JavaScript;

public class Cookies
{
    private readonly IJSRuntime _jsRuntime;

    public Cookies(IJSRuntime jsRuntime)
    {
        _jsRuntime = jsRuntime;
    }

    public async Task DeleteCookie(string name)
    {
        await _jsRuntime.InvokeAsync<string>(JSInteropConstants.DeleteCookie, name);
    }

    public async Task<string> GetCookie(string name)
    {
        return await _jsRuntime.InvokeAsync<string>(JSInteropConstants.GetCookie, name);
    }
}