private static SalariesState InitializeSearchRequest(SalariesState state, SalarySearchContext context, string?value)
        {
            var searchRequest = context switch
            {
                SalarySearchContext.Name => new EmployeeSalarySearchRequestDto(name: value),
                SalarySearchContext.JobTitle => new EmployeeSalarySearchRequestDto(jobTitle: value),
                SalarySearchContext.Agency => new EmployeeSalarySearchRequestDto(agency: value),
                SalarySearchContext.Status => new EmployeeSalarySearchRequestDto(status: value),
                SalarySearchContext.Year => new EmployeeSalarySearchRequestDto(year: int.TryParse(value, out var parsedValue) ? parsedValue : (int)EmploymentYear.AllYears),
                SalarySearchContext.BasePayRange => new EmployeeSalarySearchRequestDto(basePayRange: int.TryParse(value, out var parsedValue) ? parsedValue : (int)SalarySearchRange.AllSalaries),
                SalarySearchContext.TotalPayRange => new EmployeeSalarySearchRequestDto(totalPayRange: int.TryParse(value, out var parsedValue) ? parsedValue : (int)SalarySearchRange.AllSalaries),
                SalarySearchContext.SortField => new EmployeeSalarySearchRequestDto(sortField: value),
                SalarySearchContext.SortBy => new EmployeeSalarySearchRequestDto(sortBy: value),
                _ => new EmployeeSalarySearchRequestDto()
            };

            return(new SalariesState(false, null, true, state.SalaryResults, state.SalaryDetail, searchRequest));
        }
    }
        public static SalariesState ReduceLoadEmployeeSalariesOnSearchClickedAction(SalariesState state, LoadEmployeesOnSearchClickedAction action)
        {
            if (state.SearchRequest is null)
            {
                return(new SalariesState(false, null, true, state.SalaryResults, state.SalaryDetail, new EmployeeSalarySearchRequestDto(name: action.Name, jobTitle: action.JobTitle)));
            }

            var updatedSearchRequest = new EmployeeSalarySearchRequestDto(
                name: action.Name,
                jobTitle: action.JobTitle,
                agency: state.SearchRequest.Agency,
                status: state.SearchRequest.Status,
                sortBy: state.SearchRequest.SortBy,
                year: state.SearchRequest.Year,
                sortField: state.SearchRequest.SortField,
                basePayRange: state.SearchRequest.BasePayRange,
                totalPayRange: state.SearchRequest.TotalPayRange);

            return(new SalariesState(false, null, true, state.SalaryResults, state.SalaryDetail, updatedSearchRequest));
        }
        public static SalariesState SetEmployeeStatusActionReducer(SalariesState state, SetEmployeeStatusAction action)
        {
            if (state.SearchRequest is null)
            {
                return(InitializeSearchRequest(state, SalarySearchContext.Status, action.Status.ToString()));
            }

            var updatedSearchRequest = new EmployeeSalarySearchRequestDto(
                name: state.SearchRequest.Name,
                jobTitle: state.SearchRequest.JobTitle,
                agency: state.SearchRequest.Agency,
                status: action.Status.ToString(),
                sortBy: state.SearchRequest.SortBy,
                year: state.SearchRequest.Year,
                sortField: state.SearchRequest.SortField,
                basePayRange: state.SearchRequest.BasePayRange,
                totalPayRange: state.SearchRequest.TotalPayRange);

            return(new SalariesState(false, null, true, state.SalaryResults, state.SalaryDetail, updatedSearchRequest));
        }
 public static SalariesState ReduceLoadEmployeeSalariesFailureAction(SalariesState state, LoadEmployeeSalariesFailureAction action) =>
 new SalariesState(false, action.ErrorMessage, false, null, state.SalaryDetail, state.SearchRequest);
 public static SalariesState ReduceLoadEmployeeSalariesSuccessAction(SalariesState state, LoadEmployeeSalariesSuccessAction action) =>
 new SalariesState(false, null, false, action.Response, state.SalaryDetail, state.SearchRequest);
 public static SalariesState ReduceLoadEmployeeSalariesFromLinkAction(SalariesState state, LoadEmployeeSalariesFromLinkAction action) =>
 new SalariesState(false, null, true, state.SalaryResults, state.SalaryDetail, state.SearchRequest);
 public static SalariesState ReduceLoadEmployeeSalariesAction(SalariesState state, LoadEmployeeSalariesAction action) =>
 new SalariesState(!action.IsTableRefresh, null, action.IsTableRefresh, state.SalaryResults, state.SalaryDetail, action.SearchRequest);
 public static SalariesState SetCurrentSearchRequestActionReducer(SalariesState state, SetCurrentSearchRequestAction action) =>
 new SalariesState(state.IsLoading, null, action.IsRefreshTable, state.SalaryResults, state.SalaryDetail, action.SearchRequest);
Exemple #9
0
 public static SalariesState ReduceNaviationAction(SalariesState state, GoAction action) =>
 new SalariesState(state.IsLoading, null, state.IsTableRefresh, state.SalaryResults, state.SalaryDetail, state.SearchRequest);
Exemple #10
0
 public static SalariesState ReduceDownloadSalaryCsvFailureAction(SalariesState state, DownloadSalaryCsvFailureAction action) =>
 new SalariesState(state.IsLoading, action.ErrorMessage, state.IsTableRefresh, state.SalaryResults, state.SalaryDetail, state.SearchRequest);
Exemple #11
0
 public static SalariesState ReduceDownloadSalaryCsvSuccessAction(SalariesState state, DownloadSalaryCsvSuccessAction action) =>
 new SalariesState(state.IsLoading, null, state.IsTableRefresh, state.SalaryResults, state.SalaryDetail, state.SearchRequest);
Exemple #12
0
 public static SalariesState ReducerLoadEmployeeSalaryDetailFromLinkSuccessAction(SalariesState state, LoadEmployeeSalaryDetailSuccessAction action) =>
 new SalariesState(false, null, false, state.SalaryResults, action.SalaryDetail, state.SearchRequest);