| | | 1 | | using Pomodoro.Web.Models; |
| | | 2 | | |
| | | 3 | | namespace Pomodoro.Web.Services; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// Interface for session options generation |
| | | 7 | | /// </summary> |
| | | 8 | | public interface ISessionOptionsService |
| | | 9 | | { |
| | | 10 | | /// <summary> |
| | | 11 | | /// Gets the available options for the completed session type |
| | | 12 | | /// </summary> |
| | | 13 | | List<ConsentOption> GetOptionsForSessionType(SessionType sessionType); |
| | | 14 | | |
| | | 15 | | /// <summary> |
| | | 16 | | /// Gets the default option for the completed session type |
| | | 17 | | /// </summary> |
| | | 18 | | SessionType GetDefaultOption(SessionType completedSessionType); |
| | | 19 | | } |
| | | 20 | | |
| | | 21 | | /// <summary> |
| | | 22 | | /// Service for generating session options based on completed session type |
| | | 23 | | /// Separated from ConsentService for better single responsibility |
| | | 24 | | /// </summary> |
| | | 25 | | public class SessionOptionsService : ISessionOptionsService |
| | | 26 | | { |
| | | 27 | | private readonly AppState _appState; |
| | | 28 | | |
| | 23 | 29 | | public SessionOptionsService(AppState appState) |
| | 23 | 30 | | { |
| | 23 | 31 | | _appState = appState; |
| | 23 | 32 | | } |
| | | 33 | | |
| | | 34 | | public List<ConsentOption> GetOptionsForSessionType(SessionType sessionType) |
| | 19 | 35 | | { |
| | 19 | 36 | | var settings = _appState.Settings; |
| | | 37 | | |
| | 19 | 38 | | return sessionType switch |
| | 19 | 39 | | { |
| | 8 | 40 | | SessionType.Pomodoro => new List<ConsentOption> |
| | 8 | 41 | | { |
| | 8 | 42 | | new() { SessionType = SessionType.ShortBreak, Label = Constants.SessionOptionLabels.ShortBreak, Duration |
| | 8 | 43 | | new() { SessionType = SessionType.LongBreak, Label = Constants.SessionOptionLabels.LongBreak, Duration = |
| | 8 | 44 | | new() { SessionType = SessionType.Pomodoro, Label = Constants.SessionOptionLabels.AnotherPomodoro, Durat |
| | 8 | 45 | | }, |
| | 5 | 46 | | SessionType.ShortBreak => new List<ConsentOption> |
| | 5 | 47 | | { |
| | 5 | 48 | | new() { SessionType = SessionType.Pomodoro, Label = Constants.SessionOptionLabels.StartPomodoro, Duratio |
| | 5 | 49 | | new() { SessionType = SessionType.ShortBreak, Label = Constants.SessionOptionLabels.ShortBreak, Duration |
| | 5 | 50 | | }, |
| | 5 | 51 | | SessionType.LongBreak => new List<ConsentOption> |
| | 5 | 52 | | { |
| | 5 | 53 | | new() { SessionType = SessionType.Pomodoro, Label = Constants.SessionOptionLabels.StartPomodoro, Duratio |
| | 5 | 54 | | new() { SessionType = SessionType.LongBreak, Label = Constants.SessionOptionLabels.LongBreak, Duration = |
| | 5 | 55 | | }, |
| | 1 | 56 | | _ => new List<ConsentOption>() |
| | 19 | 57 | | }; |
| | 19 | 58 | | } |
| | | 59 | | |
| | | 60 | | public SessionType GetDefaultOption(SessionType completedSessionType) |
| | 4 | 61 | | { |
| | 4 | 62 | | return completedSessionType switch |
| | 4 | 63 | | { |
| | 1 | 64 | | SessionType.Pomodoro => SessionType.Pomodoro, // Continue with another pomodoro |
| | 1 | 65 | | SessionType.ShortBreak => SessionType.ShortBreak, // Continue short break |
| | 1 | 66 | | SessionType.LongBreak => SessionType.LongBreak, // Continue long break |
| | 1 | 67 | | _ => SessionType.Pomodoro |
| | 4 | 68 | | }; |
| | 4 | 69 | | } |
| | | 70 | | } |