protected ResultMonad.Result <PositionEvaluateSource, string> BuildItem(TargetPart part, ResultItem resultTerm, ResultItem resultWork)
                {
                    ArticleGeneralResult termResult = resultTerm as ArticleGeneralResult;
                    ArticleGeneralResult workResult = resultWork as ArticleGeneralResult;

                    if (MaybeMonadUtils.HaveAnyResultNullValue(termResult, workResult))
                    {
                        return(Result.Fail <PositionEvaluateSource, string>(CONCEPT_RESULT_INVALID_TEXT));
                    }

                    Maybe <PositionFromStopValue> termValues = termResult.ReturnPositionTermFromStopValue();
                    Maybe <MonthFromStopValue>    daysValues = termResult.ReturnMonthFromStopValue();
                    Maybe <MonthScheduleValue>    realValues = workResult.ReturnRealMonthValue();
                    Maybe <MonthScheduleValue>    restValues = workResult.ReturnTermMonthValue();

                    if (MaybeMonadUtils.HaveAnyResultNoValues(termValues, daysValues, realValues, restValues))
                    {
                        return(Result.Fail <PositionEvaluateSource, string>(CONCEPT_RESULT_INVALID_TEXT));
                    }

                    PositionFromStopValue termPosition = termValues.Value;
                    MonthFromStopValue    daysPosition = daysValues.Value;
                    MonthScheduleValue    realSchedule = realValues.Value;
                    MonthScheduleValue    restSchedule = restValues.Value;

                    PositionEvaluateSource buildResult = new PositionEvaluateSource
                    {
                        PositionPart  = part,
                        DateFrom      = termPosition.DateFrom,
                        DayPeriodFrom = daysPosition.PeriodDayFrom,
                        DateStop      = termPosition.DateStop,
                        DayPeriodStop = daysPosition.PeriodDayStop,
                        PositionType  = termPosition.PositionType,
                        ScheduleMonth = realSchedule.HoursMonth,
                        ScheduleLimit = restSchedule.HoursMonth
                    };

                    return(Result.Ok <PositionEvaluateSource, string>(buildResult));
                }
Example #2
0
        private static ResultMonad.Result <PositionScheduleEvalDetail, string> BuildItem(TargetPart partCode, ResultItem termItem, ResultItem dataItem)
        {
            ArticleGeneralResult resultTerm = termItem as ArticleGeneralResult;
            ArticleGeneralResult resultData = dataItem as ArticleGeneralResult;

            if (MaybeMonadUtils.HaveAnyResultNullValue(resultTerm, resultData))
            {
                return(Result.Fail <PositionScheduleEvalDetail, string>(RESULT_DETAILS_INVALID_TEXT));
            }

            Maybe <PositionFromStopValue> termValues = resultTerm.ReturnPositionTermFromStopValue();
            Maybe <MonthFromStopValue>    daysValues = resultTerm.ReturnMonthFromStopValue();
            Maybe <MonthScheduleValue>    workValues = resultData.ReturnTermMonthValue();

            if (MaybeMonadUtils.HaveAnyResultNoValues(termValues, daysValues, workValues))
            {
                return(Result.Fail <PositionScheduleEvalDetail, string>(RESULT_DETAILS_INVALID_TEXT));
            }

            PositionFromStopValue termPosition = termValues.Value;
            MonthFromStopValue    daysPosition = daysValues.Value;
            MonthScheduleValue    workSchedule = workValues.Value;

            PositionScheduleEvalDetail buildResult = new PositionScheduleEvalDetail
            {
                PositionPart  = partCode,
                DateFrom      = termPosition.DateFrom,
                DayPeriodFrom = daysPosition.PeriodDayFrom,
                DateStop      = termPosition.DateStop,
                DayPeriodStop = daysPosition.PeriodDayStop,
                PositionType  = termPosition.PositionType,
                ScheduleWorks = workSchedule.HoursMonth,
            };

            return(Result.Ok <PositionScheduleEvalDetail, string>(buildResult));
        }