public async Task <IActionResult> CreateTicket(TicketCreationInput info) { var sys = await _dbHandler.GetSystemAsync(info.System); if (sys == null) { return(BadRequest(new GeneralMessage() { Message = "Invalid system name" })); } var cat = await _dbHandler.GetCategoryAsync(info.CategoryName, sys); if (cat == null) { return(BadRequest(new GeneralMessage() { Message = "Invalid category" })); } TicketCreationTemplate template = new TicketCreationTemplate(); template.Category = cat; template.Details = info.Details; template.Reference = info.Reference; template.Summary = info.Summary; template.Title = info.Title; if (info.Details == null) { template.Details = info.Summary; } // Get user who wants remove user var re = Request; var headers = re.Headers; var tokenString = headers["Authorization"]; var handler = new JwtSecurityTokenHandler(); var token = handler.ReadJwtToken(tokenString[0].Split(' ')[1]); var claims = token.Claims; var usernameClaim = claims.Where(x => x.Type == ClaimTypes.Name).FirstOrDefault(); var user = await _dbHandler.GetUserAsync(usernameClaim.Value); template.CreatorUser = user; var respond = await _dbHandler.CreateTicketAsync(template); if (respond.MessageType == MessageType.NOK) { return(BadRequest(new GeneralMessage() { Message = respond.MessageText })); } return(Ok(new GeneralMessage() { Message = respond.MessageText })); }