コード例 #1
0
        ////
        //// POST: /DataManagement/RecurrenceIntervalOptions
        //[HttpPost]
        //public JsonResult GetRecurrenceIntervalOptions()
        //{
        //    try
        //    {
        //        JourListDMContainer dm = new JourListDMContainer();
        //        var list = dm.RecurrenceIntervals.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 Inventory Actions

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

                foreach (var a in dm.InventoryActions)
                {
                    InventoryActionModel item = new InventoryActionModel();
                    item.Id          = a.Id;
                    item.Description = a.Description;
                    list.Add(item);
                }

                return(Json(new { Result = "OK", Records = list }));
            }
            catch (Exception e)
            {
                return(Json(new { Result = "ERROR", Message = e.Message }));
            }
        }
コード例 #2
0
        public JsonResult CreateInventoryAction(InventoryActionModel 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 inventory action."
                }));
            }

            try
            {
                JourListDMContainer dm = new JourListDMContainer();

                InventoryAction item = new InventoryAction();
                item.Description = model.Description;
                dm.AddToInventoryActions(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 }));
            }
        }
コード例 #3
0
        public JsonResult UpdateInventoryAction(InventoryActionModel 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 inventory action."
                    }));
                }

                JourListDMContainer dm = new JourListDMContainer();

                InventoryAction item = dm.InventoryActions.Single(z => z.Id == model.Id);
                item.Description = model.Description;
                dm.SaveChanges();

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