// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(options => { options.LoginPath = new Microsoft.AspNetCore.Http.PathString("/Account/Login"); }); services.AddControllersWithViews(); services.AddSingleton(c => UserRepository.getInstance()); services.AddSingleton(c => CitataRepository.getInstance()); }
public IActionResult Get(int id) { CitataRepository citataRepository = CitataRepository.getInstance(); Citata citata = citataRepository.Select(id); if (citata == null) { return(NotFound()); } return(new ObjectResult(citata)); }
public HomeController(CitataRepository context, ILogger <Startup> _logger) { db = context; logger = _logger; }