public async Task DeleteStock(StockDeleteAction action, IDispatcher dispatcher) { var result = await _httpClient.DeleteAsync($"api/stock/{action.Stock.Id}"); if (result.IsSuccessStatusCode) { dispatcher.Dispatch(new StockDeleteSuccessAction()); } else { dispatcher.Dispatch(new StockDeleteFailureAction(result.ReasonPhrase)); } dispatcher.Dispatch(new StocksLoadAction()); }
public static StocksState OnStockDelete(StocksState state, StockDeleteAction action) { if (state.CurrentStock.Id == action.Stock.Id) { return(state with { SelectedContact = new CoffeeRoastManagement.Shared.Entities.Contact(), SelectedGreenBeanInfo = new CoffeeRoastManagement.Shared.Entities.GreenBeanInfo(), CurrentStock = new CoffeeRoastManagement.Shared.Entities.Stock(), StockButtonText = "Create" }); } return(state with { }); }