public async Task <ViewModels.Session> StartAsync(Guid id, CancellationToken ct) { if (!(await _authorizationService.AuthorizeAsync(_user, null, new ContentDeveloperRequirement())).Succeeded) { throw new ForbiddenException(); } var session = await _context.Sessions .SingleAsync(o => o.Id == id, ct); var dateTimeStart = DateTime.UtcNow; session.DateModified = dateTimeStart; session.ModifiedBy = _user.GetId(); session.StartDate = dateTimeStart; session.Status = SessionStatus.active; _context.Sessions.Update(session); await _context.SaveChangesAsync(ct); var dispatchTasks = await _dispatchTaskService.GetBySessionIdAsync(session.Id, ct); foreach (var dispatchTask in dispatchTasks) { if (dispatchTask.TriggerTaskId is null && dispatchTask.TriggerCondition != TaskTrigger.Manual) { await _dispatchTaskService.ExecuteAsync(dispatchTask.Id, ct); } } return(_mapper.Map <Session>(session)); }
public async Task <IActionResult> Execute(Guid id, CancellationToken ct) { var resultList = await _DispatchTaskService.ExecuteAsync(id, ct); return(Ok(resultList)); }