public static RoastsState OnSaveRoast(RoastsState state, RoastsSaveRoastAction action)
 {
     return(state with
     {
         Submitted = false,
         Submitting = true,
         CurrentRoast = new CoffeeRoastManagement.Shared.Entities.Roast(),
         RoastButtonText = "Create",
         ShowInputDialog = false,
         RoastEditMode = false,
         Name = string.Empty,
         ShortInfo = string.Empty,
         Note = string.Empty,
         GreenBlends = Array.Empty <CoffeeRoastManagement.Shared.Entities.GreenBlend>(),
         Date = null,
         Time = null,
         Equipment = string.Empty,
         ErrorMessage = string.Empty,
         Photo = string.Empty,
         RoastProfile = string.Empty,
     });
 }
        public static RoastsState OnRoastsAdd(RoastsState state)
        {
            // handle all cases, the last return statement handles the default case
            if (state.ShowInputDialog && state.RoastEditMode)
            {
                // we reset everything
                return(state with
                {
                    ShowInputDialog = true,
                    RoastEditMode = false,
                    CurrentRoast = new CoffeeRoastManagement.Shared.Entities.Roast(),
                    Name = "",
                    ShortInfo = "",
                    Note = "",
                    Equipment = "",
                    ErrorMessage = "",
                    GreenBlends = Array.Empty <GreenBlend>(),
                    Date = null,
                    Photo = "",
                    RoastProfile = "",
                    Time = null,
                    RoastButtonText = "Create"
                });
            }
            if (state.ShowInputDialog && !state.RoastEditMode)
            {
                if (!string.IsNullOrEmpty(state.CurrentRoast.Name) || !string.IsNullOrEmpty(state.CurrentRoast.Note) || !string.IsNullOrEmpty(state.CurrentRoast.ShortInfo) || !string.IsNullOrEmpty(state.CurrentRoast.RoastProfile) || !string.IsNullOrEmpty(state.CurrentRoast.Photo))
                {
                    return(state with
                    {
                        CurrentRoast = new CoffeeRoastManagement.Shared.Entities.Roast(),
                        Name = "",
                        ShortInfo = "",
                        Note = "",
                        Equipment = "",
                        ErrorMessage = "",
                        GreenBlends = Array.Empty <GreenBlend>(),
                        Date = null,
                        Photo = "",
                        RoastProfile = "",
                        Time = null,

                        RoastButtonText = "Create",
                    });
                }
                else
                {
                    return(state with
                    {
                        CurrentRoast = new CoffeeRoastManagement.Shared.Entities.Roast(),
                        Name = "",
                        ShortInfo = "",
                        Note = "",
                        Equipment = "",
                        ErrorMessage = "",
                        GreenBlends = Array.Empty <GreenBlend>(),
                        Date = null,
                        Photo = "",
                        RoastProfile = "",
                        Time = null,
                        RoastButtonText = "Create",
                        ShowInputDialog = false,
                    });
                }
            }
            return(state with
            {
                ShowInputDialog = true,
            });
        }