Exemple #1
0
 public MonitoringPulseResult Convert(EFDbModel.MonitoringPulseResult pulse)
 {
     return(new MonitoringPulseResult()
     {
         CreationTime = pulse.CreationTime,
         Responded = pulse.Responded,
         Silent = pulse.Silent,
         Skipped = pulse.Skipped
     });
 }
Exemple #2
0
        private MonitoringPulseResult ConvertPulseResult(
            EFDbModel.MonitoringPulseResult pulseResult
            )
        {
            IEnumerable <MonitoringMessage> messages = pulseResult.Messages
                                                       .Select(m => _efToViewConverter.Convert(m));
            MonitoringPulseResult pulse = _efToViewConverter.Convert(pulseResult);

            pulse.Messages = messages;
            return(pulse);
        }
Exemple #3
0
        public async Task <DataActionResult <MonitoringPulseResult> > SavePulseResult(
            int sessionId,
            MonitoringPulseResult pulseResult,
            IEnumerable <MonitoringMessage> messages
            )
        {
            StatusMessage sessionIdValidationStatus =
                await ValidateSessionId(sessionId);

            if (sessionIdValidationStatus.Failure())
            {
                return(DataActionResult <MonitoringPulseResult> .Failed(sessionIdValidationStatus));
            }

            IEnumerable <MonitoringMessage> monitoringMessages = messages as MonitoringMessage[] ?? messages.ToArray();

            foreach (MonitoringMessage message in monitoringMessages)
            {
                StatusMessage messageValidationStatus = _validator.Validate(message);
                if (messageValidationStatus.Failure())
                {
                    return(DataActionResult <MonitoringPulseResult> .Failed(
                               messageValidationStatus
                               ));
                }
            }

            EFDbModel.MonitoringPulseResult convertedPulseResult =
                _viewToEfConverter.Convert(pulseResult);
            IEnumerable <EFDbModel.MonitoringMessage> convertedMessages = monitoringMessages
                                                                          .Select(m => _viewToEfConverter.Convert(m));

            return(FailOrConvert(
                       await Repo.SavePulseResult(sessionId, convertedPulseResult, convertedMessages),
                       ConvertPulseResult
                       ));
        }