コード例 #1
0
		private AddOrUpdateLoadtestsResponse AddOrUpdateLoadtests(AddOrUpdateLoadtestsRequest addOrUpdateLoadtestsRequest)
		{
			AddOrUpdateLoadtestsResponse resp = new AddOrUpdateLoadtestsResponse();
			try
			{
				//assign ID if not present, assume to be insertion
				foreach (LoadtestViewModel ltvm in addOrUpdateLoadtestsRequest.Loadtests)
				{
					if (ltvm.Id == null || ltvm.Id == default(Guid))
					{
						ltvm.Id = Guid.NewGuid();
					}
				}
				List<LoadtestViewModel> sortedByDate = addOrUpdateLoadtestsRequest.Loadtests.OrderBy(lt => lt.StartDateUtc).ToList();
				LoadtestViewModel last = sortedByDate.Last();
				IList<Loadtest> loadtests = _timetableRepository.GetLoadtestsForTimePeriod(sortedByDate.First().StartDateUtc, last.StartDateUtc.AddSeconds(last.DurationSec));
				Timetable timetable = new Timetable(loadtests);				
				IList<Loadtest> loadtestsAddedOrUpdated = _timetableViewModelRepository.ConvertToDomain(addOrUpdateLoadtestsRequest.Loadtests);
				AddOrUpdateLoadtestsValidationResult validationResult = timetable.AddOrUpdateLoadtests(loadtestsAddedOrUpdated);
				_timetableRepository.AddOrUpdateLoadtests(validationResult);
				resp.AddOrUpdateLoadtestsValidationResult = validationResult;				
			}
			catch (Exception ex)
			{
				resp.Exception = ex;
			}
			return resp;
		}
コード例 #2
0
		public async Task<AddOrUpdateLoadtestsResponse> AddOrUpdateLoadtestsAsync(AddOrUpdateLoadtestsRequest addOrUpdateLoadtestsRequest)
		{
			AddOrUpdateLoadtestsResponse resp = await _innerTimetableService.AddOrUpdateLoadtestsAsync(addOrUpdateLoadtestsRequest);
			if (resp.Exception == null)
			{
				AddOrUpdateLoadtestsValidationResult addOrUpdateValidationResult = resp.AddOrUpdateLoadtestsValidationResult;
				if ((addOrUpdateValidationResult.ToBeInserted.Any() || addOrUpdateValidationResult.ToBeUpdated.Any())
					&& !addOrUpdateValidationResult.Failed.Any())
				{
					EmailArguments args = new EmailArguments("Load tests added or updated", "Load tests added or updated", "The Boss", "The developer", "123.456.678");
					_emailService.SendEmail(args);
				}
			}
			return resp;
		}
コード例 #3
0
		public async Task<IHttpActionResult> Post(IEnumerable<InsertUpdateLoadtestViewModel> insertUpdateLoadtestViewModels)
		{
			List<LoadtestViewModel> loadtestViewModels = new List<LoadtestViewModel>();
			foreach (InsertUpdateLoadtestViewModel vm in insertUpdateLoadtestViewModels)
			{
				loadtestViewModels.Add(vm.ConvertToViewModel());
			}
			AddOrUpdateLoadtestsRequest request = new AddOrUpdateLoadtestsRequest(loadtestViewModels);
			AddOrUpdateLoadtestsResponse response = await _timetableService.AddOrUpdateLoadtestsAsync(request);
			if (response.Exception == null)
			{
				return Ok<string>(response.AddOrUpdateLoadtestsValidationResult.OperationResultSummary);
			}

			return InternalServerError(response.Exception);
		}
コード例 #4
0
		public async Task<AddOrUpdateLoadtestsResponse> AddOrUpdateLoadtestsAsync(AddOrUpdateLoadtestsRequest addOrUpdateLoadtestsRequest)
		{
			return await Task<AddOrUpdateLoadtestsResponse>.Run(() => AddOrUpdateLoadtests(addOrUpdateLoadtestsRequest));
		}