public static ContactsState OnContactsDelete(ContactsState state, ContactsDeleteAction action) { if (state.CurrentContact.Id == action.Contact.Id) { return(state with { CurrentContact = new CoffeeRoastManagement.Shared.Entities.Contact(), ContactButtonText = "Create" }); } return(state with { }); }
public async Task DeleteContact(ContactsDeleteAction action, IDispatcher dispatcher) { var result = await _httpClient.DeleteAsync($"api/contact/{action.Contact.Id}"); if (result.IsSuccessStatusCode) { dispatcher.Dispatch(new ContactDeleteSuccessAction()); } else { dispatcher.Dispatch(new ContactDeleteFailureAction(result.ReasonPhrase)); } dispatcher.Dispatch(new ContactsLoadAction()); }