示例#1
0
        protected async Task Update(TItem item)
        {
            PreUpdate(item);

            var putResponse = await HttpClient.PutAsJsonAsync($"{ApiUrl}/{GetId(item)}", item);

            putResponse.EnsureSuccessStatusCode();
            //Console.WriteLine("get put response successfully");

            var json = await putResponse.Content.ReadAsStringAsync();

            var updated = JsonConvert.DeserializeObject <TItem>(json);

            //Console.WriteLine("deserialized successfully");

            Data[Data.FindIndex(i => IsEquals(item, i))]   = updated;
            Items[Items.FindIndex(i => IsEquals(item, i))] = updated;

            //Console.WriteLine("updated locally successfully");

            CardEditor.CloseDialog();

            await InvokeAsync(StateHasChanged);

            //Console.WriteLine("updated successfully");
        }
示例#2
0
        protected async Task Insert(TItem item)
        {
            if (Parent != null)
            {
                SetParent(item);
            }

            PreInsert(item);

            var postResponse = await HttpClient.PostAsJsonAsync(ApiUrl, item);

            postResponse.EnsureSuccessStatusCode();
            var json = await postResponse.Content.ReadAsStringAsync();

            CardEditor.CloseDialog();

            Console.WriteLine(json);

            var inserted = JsonConvert.DeserializeObject <TItem>(json);

            //Console.WriteLine("deserialized successfully");

            Data.Add(inserted);
            Items.Add(inserted);
            await InvokeAsync(StateHasChanged);

            //Console.WriteLine("added successfully");
        }
示例#3
0
        protected async Task Delete(TItem item)
        {
            var deleteResponse = await HttpClient.DeleteAsync($"{ApiUrl}/{GetId(item)}");

            deleteResponse.EnsureSuccessStatusCode();
            //Console.WriteLine("get delete response successfully");

            Data.Remove(item);
            Items.Remove(item);

            //Console.WriteLine("deleted locally successfully");

            CardEditor.CloseDialog();

            await InvokeAsync(StateHasChanged);

            //Console.WriteLine("delete successfully");
        }
示例#4
0
 void DeleteButtonClicked(MouseEventArgs mouseEventArgs)
 {
     CardEditor?.ShowDelete(Item);
 }
示例#5
0
 void EditButtonClicked(MouseEventArgs mouseEventArgs)
 {
     CardEditor?.ShowEdit(Item);
 }