Exemplo n.º 1
0
 /// <summary>
 /// Read item from server
 /// </summary>
 /// <returns></returns>
 public async Task ReadItem()
 {
     CoreItemJson = (await ItemService.ReadJsonAsync(new List <Guid>()
     {
         _itemId
     }))?.FirstOrDefault();
     VMVisible.SetVisibility(CoreItemJson.JSON);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="container">Dependency injection controller</param>
 /// <param name="itemId">When provided automatically load this item for editing</param>
 public VMJsonEditorPage(IContainer container, Guid?ItemId = null) : base(container)
 {
     ItemService = Container.Resolve <IItemService>();
     if (ItemId != null)
     {
         _itemId = ItemId.Value;
     }
     VMVisible = new VMVisible();
 }
Exemplo n.º 3
0
        /// <summary>
        /// Create items from json
        /// </summary>
        /// <returns></returns>
        public async Task CreateItem()
        {
            Working = true;
            try
            {
                var coreItemJsons = await ItemService.CreateJsonAsync(ItemJson);

                CoreItemJson = coreItemJsons.First();
                VMVisible.SetVisibility(CoreItemJson.JSON);
            }
            finally
            {
                Working = false;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Update multiple items on server
        /// </summary>
        /// <returns></returns>
        public async Task UpdateItem()
        {
            Working = true;
            try
            {
                var item         = JsonConvert.DeserializeObject <Item>(_itemJson);
                var coreItemJson = new CoreItemJson()
                {
                    Id = ItemId,
                    IncludeChildren = true,
                    JSON            = ItemJson
                };
                await ItemService.UpdateJsonAsync(new List <CoreItemJson>() { coreItemJson });

                VMVisible.SetVisibility(coreItemJson.JSON);
            }
            finally
            {
                Working = false;
            }
        }