public JsonResult CreateReccurenceInterval(RecurrenceIntervalModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new
                {
                    Result = "ERROR",
                    Message = "Form is not valid! " +
                              "Please correct it and try again."
                }));
            }

            if (!User.IsInRole("Officer"))
            {
                return(Json(new
                {
                    Result = "ERROR",
                    Message = "You do not have the authority to create a new interval."
                }));
            }

            try
            {
                JourListDMContainer dm = new JourListDMContainer();

                RecurrenceInterval item = new RecurrenceInterval();
                item.Description = model.Description;
                item.Minutes     = model.Minutes;
                dm.AddToRecurrenceIntervals(item);
                dm.SaveChanges();

                model.Id = item.Id;

                return(Json(new { Result = "OK", Record = model }));
            }
            catch (Exception e)
            {
                return(Json(new { Result = "ERROR", Message = e.Message }));
            }
        }
        public JsonResult UpdateRecurrenceInterval(RecurrenceIntervalModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(Json(new
                    {
                        Result = "ERROR",
                        Message = "Form is not valid! " +
                                  "Please correct it and try again."
                    }));
                }

                if (!User.IsInRole("Officer"))
                {
                    return(Json(new
                    {
                        Result = "ERROR",
                        Message = "You do not have the authority to update this interval."
                    }));
                }

                JourListDMContainer dm = new JourListDMContainer();

                RecurrenceInterval item = dm.RecurrenceIntervals.Single(z => z.Id == model.Id);
                item.Description = model.Description;
                item.Minutes     = model.Minutes;
                item.Active      = model.Active;
                dm.SaveChanges();

                return(Json(new { Result = "OK" }));
            }
            catch (Exception e)
            {
                return(Json(new { Result = "ERROR", Message = e.Message }));
            }
        }
        ////
        //// POST: /DataManagement/GetItemCategoryOptions
        //[HttpPost]
        //public JsonResult GetItemCategoryOptions()
        //{
        //    try
        //    {
        //        JourListDMContainer dm = new JourListDMContainer();
        //        var list = dm.ItemCategories.Select(z => new { DisplayText = z.Description, Value = z.Id });
        //        return Json(new { Result = "OK", Options = list });
        //    }
        //    catch (Exception e)
        //    {
        //        return Json(new { Result = "ERROR", Message = e.Message });
        //    }
        //}

        #endregion

        #region ReccurenceIntervals

        // POST: /DataManagement/RecurrenceIntervalList
        public JsonResult RecurrenceIntervalList()
        {
            try
            {
                JourListDMContainer            dm   = new JourListDMContainer();
                List <RecurrenceIntervalModel> list = new List <RecurrenceIntervalModel>();

                foreach (var a in dm.RecurrenceIntervals.Where(z => z.Active == true))
                {
                    RecurrenceIntervalModel item = new RecurrenceIntervalModel();
                    item.Id          = a.Id;
                    item.Description = a.Description;
                    item.Minutes     = a.Minutes;
                    item.Active      = a.Active;
                    list.Add(item);
                }

                return(Json(new { Result = "OK", Records = list }));
            }
            catch (Exception e)
            {
                return(Json(new { Result = "ERROR", Message = e.Message }));
            }
        }