Exemple #1
0
 // 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());
 }
Exemple #2
0
        public IActionResult Get(int id)
        {
            CitataRepository citataRepository = CitataRepository.getInstance();

            Citata citata = citataRepository.Select(id);

            if (citata == null)
            {
                return(NotFound());
            }

            return(new ObjectResult(citata));
        }
Exemple #3
0
 public HomeController(CitataRepository context, ILogger <Startup> _logger)
 {
     db     = context;
     logger = _logger;
 }