Esempio n. 1
0
 public ProductionLineHto(Domain.Production.ProductionLine productionLine)
 {
     Id    = productionLine.Id.Value;
     Name  = productionLine.HumanReadableName;
     State = productionLine.State;
     ShutDownForMaintenance = new ShutDownForMaintenance(() => productionLine.ShutDownForMaintenance.HasValue, () => {}); // we dont need the execute
     CompleteMaintenance    = new CompleteMaintenance(() => productionLine.CompleteMaintenance.HasValue, () => {});       // we dont need the execute
 }
Esempio n. 2
0
        private async Task <CompleteMaintenanceResult> ExecuteCompleteMaintenance(Domain.Production.ProductionLine productionLine)
        {
            var result = await productionLine.CompleteMaintenance.Match <Task <CompleteMaintenanceResult> >(
                async action => await InvokeCompleteMaintenance(action, productionLine),
                async() => await Task.FromResult(new CompleteMaintenanceResult.NotAvailable()));

            return(result);
        }
        private async Task <ShutDownForMaintenanceResult> ExecuteShutDown(Domain.Production.ProductionLine productionLine)
        {
            var result = await productionLine.ShutDownForMaintenance.Match <Task <ShutDownForMaintenanceResult> >(
                async action => await InvokeShutDown(action, productionLine),
                async() => await Task.FromResult(new ShutDownForMaintenanceResult.NotAvailable()));

            return(result);
        }
Esempio n. 4
0
 private async Task <CompleteMaintenanceResult> InvokeCompleteMaintenance(Func <Result <Exception> > action, Domain.Production.ProductionLine productionLine)
 {
     return(await action().Match(
                success: async _ =>
     {
         var addResult = await productionLineRepository.Add(productionLine);
         var shutDownProductionLineResult = addResult.Match <CompleteMaintenanceResult>(
             success => new CompleteMaintenanceResult.Success(),
             notReachable => new CompleteMaintenanceResult.NotReachable(),
             error => new CompleteMaintenanceResult.Error(error.Exception)
             );
         return shutDownProductionLineResult;
     },
                failure: failure => Task.FromResult <CompleteMaintenanceResult>(new CompleteMaintenanceResult.Error(failure.Error))
                ));
 }