﻿using AlaCarte.WebUI.Models;
using System.Web.Mvc;
using System;

namespace AlaCarte.WebUI.Controllers
{
    public class AdminController : BaseController
    {
        public ActionResult Dashboard()
        {
            Administration administration = new Administration(ViewBag.EmployeeID);
            ViewBag.ReturnToHub = Resources.Literals.ReturnToControlCenter;
            return View(administration);
        }

        public ActionResult Remove(long id)
        {
            Administration administration = new Administration(ViewBag.EmployeeID);
            administration.Delete(id);
            ViewBag.ReturnToHub = Resources.Literals.ReturnToControlCenter;
            return View("Dashboard", administration);
        }

        [HttpPost]
        [OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
        public ActionResult OverDue()
        {
            Administration administration = new Administration(ViewBag.EmployeeID);
            return PartialView("_OverDue", administration);
        }

        [HttpPost]
        [OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
        public ActionResult OverDueDetails(string name, DateTime dueDate)
        {
            Administration administration = new Administration(ViewBag.EmployeeID);
            ViewBag.Name = name;
            ViewBag.DueDate = dueDate.ToShortDateString();
            return PartialView("_OverDueDetails", administration);
        }

        [HttpPost]
        [OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
        public ActionResult Open()
        {
            Administration administration = new Administration(ViewBag.EmployeeID);
            return PartialView("_Open", administration);
        }

        [HttpPost]
        [OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
        public ActionResult OpenDetails(string name, DateTime dueDate)
        {
            Administration administration = new Administration(ViewBag.EmployeeID);
            ViewBag.Name = name;
            ViewBag.DueDate = dueDate.ToShortDateString();
            return PartialView("_OpenDetails", administration);
        }

        [HttpPost]
        [OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
        public ActionResult Completed()
        {
            Administration administration = new Administration(ViewBag.EmployeeID);
            return PartialView("_Completed", administration);
        }

        [HttpPost]
        [OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
        public ActionResult CompletedDetails(string name, DateTime dueDate)
        {
            Administration administration = new Administration(ViewBag.EmployeeID);
            ViewBag.Name = name;
            ViewBag.DueDate = dueDate.ToShortDateString();
            return PartialView("_CompletedDetails", administration);
        }
    }
}
