コード例 #1
0
 public static RoastsState OnEquipmentChange(RoastsState state, RoastEquipmentChangeAction action)
 {
     return(state with
     {
         Equipment = action.Equipment
     });
 }
コード例 #2
0
 public static RoastsState OnNoteChange(RoastsState state, RoastNoteChangeAction action)
 {
     return(state with
     {
         Note = action.Note
     });
 }
コード例 #3
0
 public static RoastsState OnSetCurrentRoast(RoastsState state, RoastsSetCurrentRoastAction action)
 {
     return(state with
     {
         CurrentRoast = state.Roasts.FirstOrDefault(x => x.Id == action.RoastId)
     });
 }
コード例 #4
0
 public static RoastsState OnNameChange(RoastsState state, RoastNameChangeAction action)
 {
     return(state with
     {
         Name = action.Name,
     });
 }
コード例 #5
0
 public static RoastsState OnRoastPhotoChange(RoastsState state, RoastsPhotoChangeAction action)
 {
     return(state with
     {
         Photo = action.Photo
     });
 }
コード例 #6
0
 public static RoastsState OnRoastProfileChange(RoastsState state, RoastsRoastProfileChangeAction action)
 {
     return(state with
     {
         RoastProfile = action.RoastProfile
     });
 }
コード例 #7
0
 public static RoastsState OnRoastDateChange(RoastsState state, RoastsDateChangeAction action)
 {
     return(state with
     {
         Date = action.Date
     });
 }
コード例 #8
0
 public static RoastsState OnRoastTimeChange(RoastsState state, RoastsTimeChangeAction action)
 {
     return(state with
     {
         Time = action.Time
     });
 }
コード例 #9
0
 public static RoastsState OnRoastsLoad(RoastsState state)
 {
     return(state with
     {
         Loading = true
     });
 }
コード例 #10
0
 public static RoastsState OnGreenBlendChange(RoastsState state, RoastsSetGreenBlendAction action)
 {
     return(state with
     {
         GreenBlends = action.Blends,
     });
 }
コード例 #11
0
 public static RoastsState OnShortInfoChange(RoastsState state, RoastShortInfoChangeAction action)
 {
     return(state with
     {
         ShortInfo = action.ShortInfo,
     });
 }
コード例 #12
0
 public static RoastsState OnRoastGreenBeanInfoSet(RoastsState state, RoastsSetStocksAction action)
 {
     return(state with
     {
         Stocks = action.Stocks,
     });
 }
コード例 #13
0
 public static RoastsState OnRoastsSet(RoastsState state, RoastsSetAction action)
 {
     return(state with
     {
         Roasts = action.Roasts,
     });
 }
コード例 #14
0
 public static RoastsState OnRoastsInitialized(RoastsState state)
 {
     return(state with
     {
         Initialized = true,
         Loading = false
     });
 }
コード例 #15
0
        public static RoastsState OnUpdateFields(RoastsState state, RoastsUpdateFieldsAction action)
        {
            ArtisanFile artisan  = JsonConvert.DeserializeObject <ArtisanFile>(action.RoastProfile);
            var         newstate = state with {
                Equipment = artisan.RoasterType,
                Date      = DateTimeOffset.FromUnixTimeSeconds(artisan.RoastEpoch + artisan.RoastTZOffset).DateTime.Date,
                Time      = DateTimeOffset.FromUnixTimeSeconds(artisan.RoastEpoch + artisan.RoastTZOffset).Date.TimeOfDay
            };

            return(newstate);
        }
コード例 #16
0
 public static RoastsState OnEditRoast(RoastsState state, RoastsRoastEditAction action)
 {
     return(state with
     {
         RoastEditMode = true,
         RoastButtonText = "Update",
         ShowInputDialog = true,
         CurrentRoast = action.Roast,
         Date = action.Roast.Date.Date,
         Time = action.Roast.Date.TimeOfDay,
         Equipment = action.Roast.Equipment,
         GreenBlends = action.Roast.Beans.ToArray(),
         Name = action.Roast.Name,
         ShortInfo = action.Roast.ShortInfo,
         Photo = action.Roast.Photo,
         RoastProfile = action.Roast.RoastProfile,
         Note = action.Roast.Note,
         ErrorMessage = string.Empty
     });
 }
コード例 #17
0
 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,
     });
 }
コード例 #18
0
        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,
            });
        }