using CONTROLLER.Models;
using Microsoft.AspNetCore.Http;

namespace CONTROLLER.Extensions
{
    public static class HttpContextExtensions
    {
        public static RequestTrackingContext GetRequestTrackingContext(this HttpContext context)
        {
            return context.Items["RequestTrackingContext"] as RequestTrackingContext
                   ?? new RequestTrackingContext();
        }

        public static string GetCaller(this HttpContext context)
        {
            return context.GetRequestTrackingContext().Caller;
        }

        public static string? GetDeviceCode(this HttpContext context)
        {
            return context.GetRequestTrackingContext().DeviceCode;
        }

        public static string? GetDeviceName(this HttpContext context)
        {
            return context.GetRequestTrackingContext().DeviceName;
        }
    }
}
