using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using AspNetCoreCorsSample.Models;
using Microsoft.AspNetCore.Cors;

namespace AspNetCoreCorsSample.Controllers
{
    //[EnableCors("AllowSpecificOrigin1")]
    public class HomeController : Controller
    {
        //[DisableCors]
        public IActionResult Index()
        {
            return View();
        }

        [HttpGet]
        //[EnableCors("AllowLocalHost5002")]
        public IActionResult GetDateTime()
        {
            return Json(new { Data = DateTime.Now });
        }

        //[EnableCors("AllowSpecificOrigin2")]
        public IActionResult Privacy()
        {
            return View();
        }

        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }
    }
}
