예제 #1
0
        /// <summary>
        /// Updates a ticket's status
        /// </summary>
        /// <param name="ticketID">The id of the ticket</param>
        /// <param name="newStatus">The new status that we want it to have</param>
        /// <returns>Whether we successfully changed the status or not</returns>
        public async Task <bool> UpdateTicketStatusAsync(long ticketID, Constants.TicketStatuses newStatus)
        {
            // Make sure the ticket exists first
            bool ticketExists = await ticketDAO.CheckTicketExistenceAsync(ticketID);

            if (!ticketExists)
            {
                throw new ArgumentException(Constants.TicketUpdateNotExists);
            }

            // Update the ticket
            TicketRecord ticketRecord = new TicketRecord(ticketID, null, newStatus.ToString(), null, null);
            await ticketDAO.UpdateAsync(ticketRecord);

            return(true);
        }
예제 #2
0
        /// <summary>
        /// Updates a ticket's status
        /// </summary>
        /// <param name="ticketID">The id of the ticket to update</param>
        /// <param name="newStatus">The new status to replace</param>
        /// <param name="jwtToken">Authorization token</param>
        /// <returns>Success status</returns>
        public async Task <Result <bool> > UpdateTicketStatusAsync(long ticketID, Constants.TicketStatuses newStatus, string jwtToken)
        {
            Result <bool> result;

            try
            {
                AuthorizeUser(Constants.Operations.UpdateTicket, ref jwtToken);

                bool success = await ticketService.UpdateTicketStatusAsync(ticketID, newStatus);

                result = new Result <bool>(Constants.TicketManagerSuccessUpdateStatus);
            }
            catch
            {
                // Save error
                result = new Result <bool>(Constants.TicketManagerFailedUpdateStatus)
                {
                    ExceptionOccurred = true
                };
            }

            return(result);
        }