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 }); } }
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 }); } }
// 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 }); } }