Beispiel #1
0
        public async Task <bool> AddressTicket(AddressTicketViewModel model, DateTime stagedDate, string stagedByUserId)
        {
            int result;

            using (var connection = new MySqlConnection(_mysqlConnectionString))
            {
                var query = $@"Update juniro.ticket
                               Set
                               IsPending = {false},
                               IsAddressed = {true},
                               AddressedMessage = '{model.Message}',
                               AddressedById = '{stagedByUserId}'
                               Where Id = {model.TicketId};";
                result = await connection.ExecuteAsync(query, new { model });
            }

            return(result > 0);
        }
        public async Task <IActionResult> AddressTicket([FromBody] AddressTicketViewModel ticketViewModel)
        {
            var callerId = GetCallerId();

            if (string.IsNullOrEmpty(callerId))
            {
                return(new BadRequestObjectResult(new
                {
                    Message = "You must be logged in to address ticket!"
                }));
            }

            var result = await _ticketsRepository.AddressTicket(ticketViewModel, DateTime.Now, callerId);

            return(new OkObjectResult(new
            {
                Message = "Ticket addressed!",
                result,
                DateTime.Now,
                callerId
            }));
        }