using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using JtkMainServer.Managers;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;


namespace JtkMainServer.Pages.PCBang {
    public class DetailsModel : PageModel {
        IHostingEnvironment _env;
        public DetailsModel(IHostingEnvironment env) {
            _env = env;
        }
        public IActionResult OnGet() {
            ViewData["env"] = _env;
            //var pcBangIds = h
            if (HttpContext.Request.Query.TryGetValue("id", out var placeIds) == false || placeIds.Count < 1) {
                return RedirectToPage("./Index");
            }
            var placeId = placeIds[0];

            var place = DbManager.GetPlace(placeId);
            if (place == null) {
                return RedirectToPage("./Index");
            }

            ViewData["Place"] = place;
            //ViewData["PlaceId"] = place.Id;
            //ViewData["PlaceName"] = place.Name;
            //ViewData["PlaceMap"] = place.PcMap;
            //ViewData["Location"] = place.Location;
            //ViewData["Address"] = place.Address;

            return Page();
        }
    }
}