public ActionResult Delete(string id)
        {
            List <InventoryPeriod>  inventoryPeriods  = InventoryPeriodHelper.GetByCalendarId(Convert.ToInt64(id)).ToList();
            List <PayablePeriod>    payablePeriods    = PayablePeriodHelper.GetByCalendarId(Convert.ToInt64(id)).ToList();
            List <ReceivablePeriod> receivablePeriods = ReceivablePeriodHelper.GetByCalendarId(Convert.ToInt64(id)).ToList();

            if (inventoryPeriods.Any() || payablePeriods.Any() || receivablePeriods.Any())
            {
                throw new Exception("Delete Error", new Exception {
                    Source = "Calendar cannot be deleted because it is being used."
                });
            }

            CalendarHelper.Delete(id);
            return(RedirectToAction("Index"));
        }
        public ActionResult Edit(string id)
        {
            List <InventoryPeriod>  inventoryPeriods  = InventoryPeriodHelper.GetByCalendarId(Convert.ToInt64(id)).ToList();
            List <PayablePeriod>    payablePeriods    = PayablePeriodHelper.GetByCalendarId(Convert.ToInt64(id)).ToList();
            List <ReceivablePeriod> receivablePeriods = ReceivablePeriodHelper.GetByCalendarId(Convert.ToInt64(id)).ToList();

            if (inventoryPeriods.Any() || payablePeriods.Any() || receivablePeriods.Any())
            {
                throw new Exception("Edit Error", new Exception {
                    Source = "Calendar cannot be deleted because it is being used."
                });
            }

            CalendarViewModel model = CalendarHelper.GetCalendar(id);

            return(View(model));
        }