/// <summary> /// Add new Ticket /// </summary> /// <param name="ticket"></param> /// <returns></returns> public async Task <TicketDTO> Add(TicketDTO ticket) { await Task.Run((Action)(() => { var newTicket = new Grievance.DAL.Ticket() { CreatedDate = ticket.CreatedDate, CreatedBy = ticket.CreatedBy, DepartmentId = ticket.DepartmentId, TicketTypeId = ticket.TicketTypeId, ReferenceNumber = GenerateRefNumber(ticket), TicketPriorityId = ticket.TicketPriorityId, TicketStatusId = 1, TicketOwnerId = ticket.TicketOwnerId, Description = ticket.Description, Name = ticket.Name, UpdatedBy = ticket.UpdatedBy, UpdatedDate = ticket.UpdatedDate, AssignedTo = ticket.AssignedTo, TicketCategoryId = ticket.TicketCategoryId, TicketIssueId = ticket.TicketIssueId }; _ctx.Tickets.Add(newTicket); _ctx.SaveChanges(); ticket.Id = newTicket.Id; ticket.ReferenceNumber = newTicket.ReferenceNumber; })); return(ticket); }
/// <summary> /// Add new Ticket /// </summary> /// <param name="ticket"></param> /// <returns></returns> public async Task <TicketDTO> Add(TicketDTO ticket) { await Task.Run((Action)(() => { //var ticketOwnerID = _ctx.AspNetUsers.FirstOrDefault(x => x.IDNumber == idNumber).Id; var newTicket = new Grievance.DAL.Ticket() { CreatedDate = DateTime.Now, CreatedBy = ticket.CreatedBy, DepartmentId = ticket.DepartmentId, TicketTypeId = ticket.TicketTypeId, ReferenceNumber = GenerateRefNumber(ticket), TicketPriorityId = ticket.TicketPriorityId, TicketStatusId = 1, TicketOwnerId = ticket.TicketOwnerId, Description = ticket.Description, Name = ticket.Name, UpdatedBy = ticket.UpdatedBy, UpdatedDate = DateTime.Now, AssignedTo = ticket.AssignedTo,// "0d64e363-89b0-4de2-8bb5-81994efc53c7", TicketCategoryId = ticket.TicketCategoryId, TicketIssueId = ticket.TicketIssueId }; _ctx.Tickets.Add(newTicket); _ctx.SaveChanges(); ticket.Id = newTicket.Id; ticket.ReferenceNumber = newTicket.ReferenceNumber; })); return(ticket); }