Пример #1
0
        public async Task SetStatusAndResetLastTestCycleIntervalAsync(NcMonitor monitor, MonitorStatus status)
        {
            if (monitor.StatusEnum() != MonitorStatus.InActive)
            {
                monitor.StatusId = (int)status;
            }

            monitor.LastTestCycleInterval = null;
            await monitorRepository.UpdateAsync(monitor);
        }
Пример #2
0
        public async Task <Monitor> UpdateAsync(
            Guid id,
            Guid userId,
            [NotNull] string name,
            [NotNull] string url,
            int interval)
        {
            Check.NotNullOrWhiteSpace(name, nameof(name));
            Check.NotNullOrWhiteSpace(url, nameof(url));

            if (interval < 1)
            {
                throw new UserFriendlyException("Interval value cannot be less than one");
            }

            var monitor = await _monitorRepository.GetAsync(id);

            if (monitor.CreatorId != userId)
            {
                return(null);
            }

            var isExistingMonitorName = _monitorRepository
                                        .Any(x => x.CreatorId == monitor.CreatorId && x.Id != id && x.Name.Equals(name));

            if (isExistingMonitorName)
            {
                throw new UserFriendlyException("This project name is already in use. Please choose a different name.");
            }

            monitor.SetName(name);
            monitor.MonitorStep.SetUrl(url);
            monitor.MonitorStep.Interval = interval;

            return(await _monitorRepository.UpdateAsync(monitor));
        }