public ActionResult AddDisplayQuarter()
        {
            ScheduleManager manager = new ScheduleManager();

            QuarterItemModel newModel = new QuarterItemModel();
            ViewBag.QuarterList = manager.GetHPQuarterList();

            return PartialView("_AddDisplayQuarter", newModel);
        }
        public JsonResult AddDisplayQuarter(QuarterItemModel entity)
        {
            ScheduleManager manager = new ScheduleManager();

            if (manager.AddNewDisplayQuarter(entity))
            {

                return Json(new { success = true });
            }
            else
            {
                return Json(new { success = false });
            }
        }
        public ActionResult AddDisplayQuarter(QuarterItemModel item)
        {
            ScheduleAdmin admin = new ScheduleAdmin();

            bool result = admin.AddQuarterToAvailableList(item.YearQuarterID, item.Title, item.UrlName);

            if (result == true)
            {
                return RedirectToAction("DisplayQuarters");
            }
            else
            {

                return View(item);
            }
        }
 public ActionResult AddDisplayQuarter()
 {
     QuarterItemModel model = new QuarterItemModel();
     return View(model);
 }
        public ActionResult RemoveDisplayQuarter(QuarterItemModel entity)
        {
            ScheduleManager manager = new ScheduleManager();

            if (manager.RemoveDisplayQuarter(entity.DisplayQuarterID))
            {
                return RedirectToAction("ManageQuarters");
            }
            else
            {
                var model = manager.GetQuarterItemFromId(entity.DisplayQuarterID);
                return View(model);
            }
        }
        public bool AddNewDisplayQuarter(QuarterItemModel entity)
        {
            bool result = false;

            using (ScheduleDataContext ctx = new ScheduleDataContext())
            {

                DisplayQuarter quarter = new DisplayQuarter();

                quarter.Title = entity.Title;
                quarter.UrlName = entity.UrlName;
                quarter.YearQuarterID = entity.YearQuarterID;

                ctx.DisplayQuarters.InsertOnSubmit(quarter);

                try
                {
                    ctx.SubmitChanges();
                    result = true;

                }
                catch (Exception ex)
                {
                    throw new Exception("Unable to add Display Quarter: " + ex.Message);
                }

            }

            return result;
        }
        /// <summary>
        /// GetQuarterItemFromYRQ - Gets a QuarterItemModel based on a Quarter Code
        /// </summary>
        /// <param name="yrq">A YRQ Code, such as "B012"</param>
        /// <returns>A QuarterItemModel loaded with quarterly information.</returns>
        public QuarterItemModel GetQuarterItemFromYRQ(string yrq)
        {
            QuarterItemModel result = new QuarterItemModel();

            using (ScheduleDataContext ctx = new ScheduleDataContext())
            {

                var item = ctx.DisplayQuarters.Where(d => d.YearQuarterID == yrq).SingleOrDefault<DisplayQuarter>();

                try
                {

                    result.YearQuarterID = item.YearQuarterID;
                    result.UrlName = item.UrlName;
                    result.Title = item.Title;
                    result.DisplayQuarterID = item.DisplayQuarterID;

                }
                catch (Exception ex)
                {
                    throw new SystemException("Unable to locate specified quarter '" + yrq + "':" + ex.Message);
                }

            }

            return result;
        }