public async Task <DataActionResult <Profile> > CreateProfile(Profile profile) { StatusMessage profileValidationStatus = _validator.Validate(profile); if (profileValidationStatus.Failure()) { return(DataActionResult <Profile> .Failed(profileValidationStatus)); } StatusMessage nameExistsStatus = await FailIfProfileNameExists(profile.Name); if (nameExistsStatus.Failure()) { return(DataActionResult <Profile> .Failed(nameExistsStatus)); } return(FailOrConvert( await Repo.CreateProfile(_viewToEfConverter.Convert(profile)), p => _efToViewConverter.Convert(p) )); }
public async Task <DataActionResult <NtwkNode> > CreateNodeOnRoot(NtwkNode node) { StatusMessage nodeValidationStatus = _validator.Validate(node); if (nodeValidationStatus.Failure()) { return(DataActionResult <NtwkNode> .Failed(nodeValidationStatus)); } StatusMessage nameExistsStatus = await FailIfNodeNameExists(node.Name); if (nameExistsStatus.Failure()) { return(DataActionResult <NtwkNode> .Failed(nameExistsStatus)); } return(FailOrConvert( await Repo.CreateNodeOnRoot(_viewToEfConverter.Convert(node)), n => _efToViewConverter.Convert(n) )); }
public async Task <DataActionResult <NodeTag> > CreateTag(NodeTag tag) { StatusMessage tagValidationStatus = _validator.Validate(tag); if (tagValidationStatus.Failure()) { return(DataActionResult <NodeTag> .Failed(tagValidationStatus)); } StatusMessage nameExistsStatus = await FailIfTagNameExists(tag.Name); if (nameExistsStatus.Failure()) { return(DataActionResult <NodeTag> .Failed(nameExistsStatus)); } return(FailOrConvert( await Repo.CreateTag(_viewToEfConverter.Convert(tag)), t => _efToViewConverter.Convert(t) )); }
public async Task <DataActionResult <CustomWebService> > CreateCustomWebService( CustomWebService cws ) { StatusMessage validationStatus = _validator.Validate(cws); if (validationStatus.Failure()) { return(DataActionResult <CustomWebService> .Failed(validationStatus)); } StatusMessage nameExistsStatus = await FailIfCwsNameExists(cws.Name); if (nameExistsStatus.Failure()) { return(DataActionResult <CustomWebService> .Failed(nameExistsStatus)); } return(FailOrConvert( await Repo.CreateCustomWebService(_viewToEfConverter.Convert(cws)), created => _efToViewConverter.Convert(created) )); }
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 )); }