/// <summary> /// Submits a ticket to the system /// </summary> /// <param name="category">The category of the ticket</param> /// <param name="description">The description inside the ticket</param> /// <returns>Whether the ticket was saved or not</returns> public async Task <bool> SubmitTicketAsync(Constants.TicketCategories category, string description) { TicketRecord ticketRecord = new TicketRecord(TimeUtilityService.CurrentUnixTime(), category.ToString(), Constants.TicketStatuses.Unresolved.ToString(), Constants.TicketFlagColors.None.ToString(), description); await ticketDAO.CreateAsync(ticketRecord); return(true); }
/// <summary> /// Updates a ticket's category /// </summary> /// <param name="ticketID">The id of the ticket</param> /// <param name="newCategory">The new ticket category to use</param> /// <returns>Whether the ticket category succesfully changed or not</returns> public async Task <bool> UpdateTicketCategoryAsync(long ticketID, Constants.TicketCategories newCategory) { // 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, newCategory.ToString(), null, null, null); await ticketDAO.UpdateAsync(ticketRecord); return(true); }
/// <summary> /// Submits a ticket /// </summary> /// <param name="category">The category of the ticket</param> /// <param name="description">The description contained in the ticket</param> /// <returns>Success status</returns> public async Task <Result <bool> > SubmitTicket(Constants.TicketCategories category, string description) { Result <bool> result; try { await ticketService.SubmitTicketAsync(category, description); result = new Result <bool>(Constants.TicketManagerSuccessSubmitTicket); } catch { // Save error result = new Result <bool>(Constants.TicketManagerFailedSubmitTicket) { ExceptionOccurred = true }; } return(result); }
/// <summary> /// Updates a ticket's category /// </summary> /// <param name="ticketID">The id of the ticket to update</param> /// <param name="newCategory">The new category to replace</param> /// <param name="jwtToken">Authorization token</param> /// <returns>Success status</returns> public async Task <Result <bool> > UpdateTicketCategoryAsync(long ticketID, Constants.TicketCategories newCategory, string jwtToken) { Result <bool> result; try { AuthorizeUser(Constants.Operations.UpdateTicket, ref jwtToken); await ticketService.UpdateTicketCategoryAsync(ticketID, newCategory); result = new Result <bool>(Constants.TicketManagerSuccessUpdateCategory); } catch { // Save error result = new Result <bool>(Constants.TicketManagerFailedFetchingTickets) { ExceptionOccurred = true }; } return(result); }