Exemple #1
0
 public static GreenBeansState OnGreenBeansInitialized(GreenBeansState state)
 {
     return(state with
     {
         Initialized = true
     });
 }
Exemple #2
0
 public static GreenBeansState OnSubmit(GreenBeansState state)
 {
     return(state with
     {
         Submitting = true
     });
 }
Exemple #3
0
 public static GreenBeansState OnGreenBeanLoad(GreenBeansState state)
 {
     return(state with
     {
         Loading = true
     });
 }
Exemple #4
0
 public static GreenBeansState OnUpdateFailure(GreenBeansState state, GreenBeanUpdateFailureAction action)
 {
     return(state with
     {
         Submitting = false,
         ErrorMessage = action.ErrorMessage
     });
 }
Exemple #5
0
 public static GreenBeansState OnUpdateSuccess(GreenBeansState state)
 {
     return(state with
     {
         Submitting = false,
         Submitted = true
     });
 }
Exemple #6
0
 public static GreenBeansState OnStopEditGreenBeanInfo(GreenBeansState state, GreenBeanStopEditAction action)
 {
     return(state with
     {
         CurrentGreenBean = action.GreenBeanInfo,
         GreenBeanButtonText = "Create",
     });
 }
Exemple #7
0
 public static GreenBeansState OnGreenBeanSet(GreenBeansState state, GreenBeansSetAction action)
 {
     return(state with
     {
         GreenBeans = action.GreenBeanInfos,
         Loading = false
     });
 }
Exemple #8
0
 public static GreenBeansState OnEditGreenBean(GreenBeansState state, GreenBeanEditAction action)
 {
     return(state with
     {
         Submitted = false,
         Submitting = false,
         ShowInputDialog = true,
         CurrentGreenBean = action.GreenBeanInfo,
         GreenBeanButtonText = "Update"
     });
 }
Exemple #9
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
     });
 }
Exemple #10
0
 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
     {
     });
 }
Exemple #11
0
 public static GreenBeansState OnAddGreenBean(GreenBeansState state, GreenBeanAddAction action)
 {
     // handle all cases, the last return statement handles the default case
     if (state.ShowInputDialog && state.GreenBeanEditMode)
     {
         // we reset everything
         return(state with
         {
             ShowInputDialog = true,
             GreenBeanEditMode = false,
             CurrentGreenBean = new CoffeeRoastManagement.Shared.Entities.GreenBeanInfo(),
             GreenBeanButtonText = "Create"
         });
     }
     if (state.ShowInputDialog && !state.GreenBeanEditMode)
     {
         if (!string.IsNullOrEmpty(state.CurrentGreenBean.Name) ||
             !string.IsNullOrEmpty(state.CurrentGreenBean.Note) ||
             !string.IsNullOrEmpty(state.CurrentGreenBean.Url) ||
             !string.IsNullOrEmpty(state.CurrentGreenBean.Country) ||
             !string.IsNullOrEmpty(state.CurrentGreenBean.Farmer) ||
             !string.IsNullOrEmpty(state.CurrentGreenBean.Processing) ||
             !string.IsNullOrEmpty(state.CurrentGreenBean.Region) ||
             !string.IsNullOrEmpty(state.CurrentGreenBean.Variety) ||
             state.CurrentGreenBean.Crop != 0 ||
             state.CurrentGreenBean.OverallCuppingScore != 0
             )
         {
             return(state with
             {
                 CurrentGreenBean = new CoffeeRoastManagement.Shared.Entities.GreenBeanInfo(),
                 GreenBeanButtonText = "Create",
             });
         }
         else
         {
             return(state with
             {
                 CurrentGreenBean = new CoffeeRoastManagement.Shared.Entities.GreenBeanInfo(),
                 GreenBeanButtonText = "Create",
                 ShowInputDialog = false,
             });
         }
     }
     return(state with
     {
         ShowInputDialog = true,
     });
 }