public JsonResult GetInventoryItem(string ItemId)
 {
     InventoryItem InventoryViewModel = new InventoryItem();
     var lodgeFileName = Server.MapPath("\\App_Data\\") + MasonMasterData.GetUserProfile(User.Identity.Name).DatabaseName;
     var IvnItem = InventoryDataXml.GetInventoryItem(ItemId, lodgeFileName);
     return Json(new { Data = IvnItem }, JsonRequestBehavior.AllowGet);
 }
 public static string AddEditInventoryItem(InventoryItem inventoryItem, string xmlFileName)
 {
     string success = "ono";
     try
     {
         XmlDocument xdoc = new XmlDocument();
         xdoc.Load(xmlFileName);
         XmlNode InventoryNode = xdoc.SelectSingleNode("//Inventory");
         XmlNode InventoryItemNode;
         if (inventoryItem.ItemId == null)
         {
             InventoryItemNode = xdoc.CreateElement("Item");
             inventoryItem.ItemId = Guid.NewGuid().ToString();
             XmlAttribute ItemId = xdoc.CreateAttribute("Id"); ItemId.InnerText = inventoryItem.ItemId; InventoryItemNode.Attributes.Append(ItemId);
             XmlAttribute ItemType = xdoc.CreateAttribute("Type"); ItemType.InnerText = inventoryItem.ItemType; InventoryItemNode.Attributes.Append(ItemType);
             XmlAttribute Desc = xdoc.CreateAttribute("Desc"); Desc.InnerText = inventoryItem.ItemDesc; InventoryItemNode.Attributes.Append(Desc);
             XmlAttribute Location = xdoc.CreateAttribute("Location"); Location.InnerText = inventoryItem.ItemLoc; InventoryItemNode.Attributes.Append(Location);
             XmlAttribute ItemDetail = xdoc.CreateAttribute("ItemDetail"); ItemDetail.InnerText = inventoryItem.ItemDetail; InventoryItemNode.Attributes.Append(ItemDetail);
             InventoryNode.AppendChild(InventoryItemNode);
         }
         else
         {
             InventoryItemNode = xdoc.SelectSingleNode("//Inventory//Item[@Id='" + inventoryItem.ItemId + "']");
             InventoryItemNode.Attributes["Type"].InnerText = inventoryItem.ItemType;
             InventoryItemNode.Attributes["Desc"].InnerText = inventoryItem.ItemDesc;
             InventoryItemNode.Attributes["Location"].InnerText = inventoryItem.ItemLoc;
             InventoryItemNode.Attributes["ItemDetail"].InnerText = inventoryItem.ItemDetail;
         }
         xdoc.Save(xmlFileName);
         success = "ok";
     }
     catch (Exception ex) { success = "ERROR: " + ex.Message; }
     return success;
 }
        public static InventoryItem GetInventoryItem(string id, string xmlFileName)
        {
            var item = new InventoryItem();
            XmlDocument xdoc = new XmlDocument();
            xdoc.Load(xmlFileName);
            XmlNode InventoryNode = xdoc.SelectSingleNode("//Inventory/Item[@Id='" + id + "']");
            item.ItemDesc = InventoryNode.Attributes["Desc"].InnerText;
            item.ItemDetail = InventoryNode.Attributes["ItemDetail"].InnerText;
            item.ItemId = InventoryNode.Attributes["Id"].InnerText;
            item.ItemLoc = InventoryNode.Attributes["Location"].InnerText;
            item.ItemType = InventoryNode.Attributes["Type"].InnerText;

            return item;
        }
 public string AddEdit(InventoryItem InventoryViewModel)
 {
     var lodgeFileName = Server.MapPath("\\App_Data\\") + MasonMasterData.GetUserProfile(User.Identity.Name).DatabaseName;
     return InventoryDataXml.AddEditInventoryItem(InventoryViewModel, lodgeFileName);
 }