public IResult <IEnumerable <IProductionScheduleReportReturn> > GetProductionScheduleReport(DateTime productionDate, string productionLocationKey) { ILocationKey locationKey = null; if (!string.IsNullOrWhiteSpace(productionLocationKey)) { var keyResult = KeyParserHelper.ParseResult <ILocationKey>(productionLocationKey); if (!keyResult.Success) { return(keyResult.ConvertTo <IEnumerable <IProductionScheduleReportReturn> >()); } locationKey = keyResult.ResultingObject; } var predicate = ProductionSchedulePredicates.ByProductionDate(productionDate); if (locationKey != null) { predicate = predicate.AndExpanded(ProductionSchedulePredicates.ByProductionLineLocationKey(locationKey)); } var result = _productionUnitOfWork.ProductionScheduleRepository .Filter(predicate) .SplitSelect(ProductionScheduleProjectors.SelectReport()) .ToList(); return(new SuccessResult <IEnumerable <IProductionScheduleReportReturn> >(result)); }
public IResult <IProductionScheduleDetailReturn> GetProductionSchedule(string productionScheduleKey) { var keyResult = KeyParserHelper.ParseResult <IProductionScheduleKey>(productionScheduleKey); if (!keyResult.Success) { return(keyResult.ConvertTo <IProductionScheduleDetailReturn>()); } var result = _productionUnitOfWork.ProductionScheduleRepository .FilterByKey(keyResult.ResultingObject.ToProductionScheduleKey()) .SplitSelect(ProductionScheduleProjectors.SelectDetail()) .FirstOrDefault(); if (result == null) { return(new InvalidResult <IProductionScheduleDetailReturn>(null, string.Format(UserMessages.ProductionScheduleNotFound, productionScheduleKey))); } return(new SuccessResult <IProductionScheduleDetailReturn>(result)); }
public IResult <IQueryable <IProductionScheduleSummaryReturn> > GetProductionSchedules(FilterProductionScheduleParameters parameters) { var parsedParameters = parameters.ToParsedParameters(); if (!parsedParameters.Success) { return(parsedParameters.ConvertTo <IQueryable <IProductionScheduleSummaryReturn> >()); } var predicateResult = ProductionSchedulePredicateBuilder.BuildPredicate(parsedParameters.ResultingObject); if (!predicateResult.Success) { return(predicateResult.ConvertTo <IQueryable <IProductionScheduleSummaryReturn> >()); } var results = _productionUnitOfWork.ProductionScheduleRepository .Filter(predicateResult.ResultingObject).Select(ProductionScheduleProjectors.SelectSummary()); return(new SuccessResult <IQueryable <IProductionScheduleSummaryReturn> >(results)); }