public async Task <IHttpActionResult> GetLinkByIdAsync([FromUri] ActionLink model, bool absolute = true, CancellationToken cancellationToken = default(CancellationToken)) { if (model == null || !ModelState.IsValid) { return(BadRequest()); } var action = await _projectManager.GetActionByIdAsync(model.ActionId, cancellationToken); if (action == null) { return(NotFound()); } await ApiSecurity.AuthorizeAsync(AccessObjectType.Project, action.Project.Id, AccessPermission.CanView, cancellationToken); return(Ok(_actionLinkService.CreateLink(model, absolute))); }
/// <summary> /// Maps an action to a result model object. /// </summary> /// <param name="action">The action to map.</param> /// <returns> /// The mapped action. /// </returns> internal static ActionResultDto Map(IActionLinkService actionLinkService, ActionItem action) { var model = new ActionResultDto { Id = action.Id, Project = action.Project, Type = action.Type, Enabled = action.Enabled, ModifiedDate = action.ModifiedDate, Name = action.Name, Options = action.Options, Children = action.Children.OfType <ActionItem>().Select(a => Map(actionLinkService, a)).ToList() }; if (action.Parent == null) { model.Link = actionLinkService.CreateLink(new ActionLink(action.Id), true); } return(model); }