﻿using System;
using Microsoft.AspNetCore.Mvc;
using ArragroCMS.BusinessLayer.Domains;
using ArragroCMS.Core.Web.Enums;
using System.Threading.Tasks;
using ArragroCMS.BusinessLayer.Interfaces.CacheDomains;

// For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860

namespace ArragroCMS.Management.Controllers
{
    public class MarkdownPageController : Controller
    {
        private readonly ICacheContents _contents;

        public MarkdownPageController(
            ICacheContents contents)
        {
            _contents = contents;
        }

        // GET: /<controller>/
        public async Task<IActionResult> Index(Guid id, Status status)
        {
            var content = await _contents.FindAsync(id, status);
            if (content == null)
                return new NotFoundResult();
            
            return View(content);
        }
    }
}
