public async Task DeleteGreenBean(GreenBeansDeleteAction action, IDispatcher dispatcher) { var result = await _httpClient.DeleteAsync($"api/greenbeaninfo/{action.GreenBeanInfo.Id}"); if (result.IsSuccessStatusCode) { dispatcher.Dispatch(new GreenBeansDeleteSuccessAction()); } else { dispatcher.Dispatch(new GreenBeansDeleteFailureAction(result.ReasonPhrase)); } dispatcher.Dispatch(new GreenBeansLoadAction()); }
public static GreenBeansState OnCGreenBeanDelete(GreenBeansState state, GreenBeansDeleteAction action) { if (state.CurrentGreenBean.Id == action.GreenBeanInfo.Id) { return(state with { CurrentGreenBean = new CoffeeRoastManagement.Shared.Entities.GreenBeanInfo(), GreenBeanButtonText = "Create" }); } return(state with { }); }