Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

how to convert this to a static class

$
0
0

Hi,

I use this class in my test project. I want to use it a static class. how to convert it. public static void Language()

1- IUnitOfWork  is a interface. sample is down that it is. 

2- HttpContext is that you know what it is.

using System;
using System.Linq;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Localization;
using MIS.WebUI.Repository.Abstract;
namespace MIS.WebUI.Infrastructure
{
    public class SetLanguage
    {
        private IUnitOfWork UnitOfWork;
        private HttpContext HttpContext;
        public SetLanguage(IUnitOfWork unitOfWork, HttpContext httpContext)
        {
            UnitOfWork = unitOfWork;
            HttpContext = httpContext;
        }
        public void Language()
        {
            var languageId = HttpContext.Session.GetString("LanguageId");//reads from the session
            var cultureName = UnitOfWork.Languages.GetAll()
                                            .Where(i => i.LanguageId == Convert.ToInt32(languageId))
                                            .FirstOrDefault().Culture.ToString();

            .......
        }
    }
}
namespace MIS.WebUI.Repository.Abstract
{
    public interface IUnitOfWork : IDisposable
    {
        ILanguageRepository Languages { get; }
        ........

        int SaveChanges();
    }
}


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>