public JsonResult CreateUnitType(UnitTypeModel 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 unit type."
                });
            }

            try
            {
                JourListDMContainer dm = new JourListDMContainer();

                UnitType newUnitType = new UnitType();
                newUnitType.Description = model.Description;
                dm.AddToUnitTypes(newUnitType);
                dm.SaveChanges();

                model.Id = newUnitType.Id;

                return Json(new { Result = "OK", Record = model });
            }
            catch (Exception e)
            {
                return Json(new { Result = "ERROR", Message = e.Message });
            }
        }
        // POST: /DataManagement/UnitTypeList
        public JsonResult UnitTypeList()
        {
            try
            {
                JourListDMContainer dm = new JourListDMContainer();
                List<UnitTypeModel> list = new List<UnitTypeModel>();

                foreach (var a in dm.UnitTypes.Where(z => z.Active == true))
                {
                    UnitTypeModel item = new UnitTypeModel();
                    item.Id = a.Id;
                    item.Description = a.Description;
                    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 });
            }
        }
        public JsonResult UpdateUnitType(UnitTypeModel 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 unit type."
                    });
                }

                JourListDMContainer dm = new JourListDMContainer();

                UnitType item = dm.UnitTypes.Single(z => z.Id == model.Id);
                item.Description = model.Description;
                item.Active = model.Active;
                dm.SaveChanges();

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