Ejemplo n.º 1
0
        public async Task SaveGreenBean(GreenBeansSaveAction action, IDispatcher dispatcher)
        {
            if (action.GreenBeanInfo.Id == 0)
            {
                var result = await _httpClient.PostAsJsonAsync("api/greenbeaninfo", action.GreenBeanInfo);

                if (!result.IsSuccessStatusCode)
                {
                    dispatcher.Dispatch(new GreenBeanCreateFailureAction(result.ReasonPhrase));
                }
                else
                {
                    dispatcher.Dispatch(new GreenBeanCreateSuccessAction());
                }
            }
            else
            {
                var result = await _httpClient.PutAsJsonAsync("api/greenbeaninfo", action.GreenBeanInfo);

                if (!result.IsSuccessStatusCode)
                {
                    dispatcher.Dispatch(new GreenBeanUpdateFailureAction(result.ReasonPhrase));
                }
                else
                {
                    dispatcher.Dispatch(new GreenBeanUpdateSuccessAction());
                }
            }
            dispatcher.Dispatch(new GreenBeansLoadAction());
        }
Ejemplo n.º 2
0
 public static GreenBeansState OnSaveGreenBean(GreenBeansState state, GreenBeansSaveAction action)
 {
     return(state with
     {
         Submitted = false,
         Submitting = true,
         CurrentGreenBean = new CoffeeRoastManagement.Shared.Entities.GreenBeanInfo(),
         GreenBeanButtonText = "Create",
         ShowInputDialog = false,
         GreenBeanEditMode = false
     });
 }