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(); } }