public void CreateTokenRequest(string descriptionbool = "API Token 1", bool canRead = true, bool canWrite = true) { _apiTokenViewModelCreateRequest = new APITokenViewModelCreate { Description = descriptionbool, Can_read = canRead, Can_write = canWrite }; }
public ActionResult <APITokenViewModelGet> Post(string accountid, string channelid, [FromBody] APITokenViewModelCreate data) { logger.LogInformation($"Generate API Token for accountid: {accountid} and channel: {channelid}."); if (!long.TryParse(accountid, out long aid)) { var error = SPVChannelsHTTPError.NotFound; return(NotFound(ProblemDetailsFactory.CreateProblemDetails(HttpContext, error.Code, error.Description))); } var channel = channelRepository.GetChannelByExternalId(channelid); if (channel == null) { var error = SPVChannelsHTTPError.NotFound; return(NotFound(ProblemDetailsFactory.CreateProblemDetails(HttpContext, error.Code, error.Description))); } var newAPIToken = apiTokenRepository.CreateAPIToken(data.ToDomainObject(aid, channel.Id)); var returnResult = new APITokenViewModelGet(newAPIToken); logger.LogInformation($"API Token(id) {returnResult.Id} was generated."); return(Ok(returnResult)); }