Пример #1
0
        public async Task <IActionResult> AssignTicket(int ticketid = -1, string username = null)
        {
            if (ticketid == -1 || username == null)
            {
                return(BadRequest(new GeneralMessage()
                {
                    Message = "Missing input: ticket ID and username are mandatory"
                }));
            }

            var ticket = await _dbHandler.GetTicketAsync(ticketid);

            var user = await _dbHandler.GetUserAsync(username);

            var response = await _dbHandler.AssignUserToTicketAsync(user, ticket);

            if (response.MessageType == MessageType.NOK)
            {
                return(BadRequest(new GeneralMessage()
                {
                    Message = response.MessageText
                }));
            }

            return(Ok(new GeneralMessage()
            {
                Message = response.MessageText
            }));
        }