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"); }
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"); }
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"); }
void DeleteButtonClicked(MouseEventArgs mouseEventArgs) { CardEditor?.ShowDelete(Item); }
void EditButtonClicked(MouseEventArgs mouseEventArgs) { CardEditor?.ShowEdit(Item); }