public int EditTicket(int id, HelpDesk_Tickets ticket) { try { HelpDesk_Tickets oldTicket = _context.HelpDesk_Tickets.FirstOrDefault(x => x.TicketNumber == id); if (oldTicket != null) { oldTicket.Title = ticket.Title; oldTicket.Description = ticket.Description; oldTicket.Requestor = ticket.Requestor; oldTicket.DepartmentID = ticket.DepartmentID; oldTicket.LocationID = ticket.LocationID; oldTicket.RequestedDueDate = ticket.RequestedDueDate; oldTicket.TicketCategoryID = ticket.TicketCategoryID; oldTicket.PriorityCode = ticket.PriorityCode; oldTicket.StatusID = ticket.StatusID; oldTicket.AssignedTo = ticket.AssignedTo; oldTicket.VendorID = ticket.VendorID; oldTicket.VendorTicket = ticket.VendorTicket; oldTicket.TicketTypeID = ticket.TicketTypeID; oldTicket.NeedsApproval = ticket.NeedsApproval; oldTicket.ApprovedBy = ticket.ApprovedBy; oldTicket.ApprovedOn = ticket.ApprovedOn; } _context.SaveChanges(); } catch (Exception ex) { _logger.Error(ex); } return(ticket.Id); }
public List <HelpDesk_Tasks> GetTasksByTicketId(int ticketId) { HelpDesk_Tickets ticket = _context.HelpDesk_Tickets.First(x => x.TicketNumber == ticketId); List <HelpDesk_Tasks> allTasksByTicket = _context.HelpDesk_Tasks.Where(x => x.TicketID == ticket.Id).ToList(); return(allTasksByTicket); }
public int CreateTicket(HelpDesk_Tickets ticket) { ticket.TicketNumber = GetNextTicketNumber(); _context.HelpDesk_Tickets.Add(ticket); _context.SaveChanges(); return(ticket.Id); }
private HelpDesk_Tickets mapViewModelToEntityTicket(HelpDesk_Tickets_vm VMTicket) { ServiceDesk_Users approvedBy = _nsUserRepository.GetUserByUserName(VMTicket.ApprovedByUserName); ServiceDesk_Users assignedTo = _nsUserRepository.GetUserByUserName(VMTicket.AssignedToUserName); ServiceDesk_Users requestor = _nsUserRepository.GetUserByUserName(VMTicket.RequestorUserName); var vmT = new HelpDesk_Tickets { TicketNumber = VMTicket.TicketNumber, Title = VMTicket.Title, Description = VMTicket.Description, Requestor = requestor.Id, DepartmentID = requestor.DepartmentId, LocationID = requestor.LocationId, RequestDateTime = VMTicket.RequestDateTime, RequestedDueDate = VMTicket.RequestedDueDate, TicketCategoryID = VMTicket.TicketCategoryID, PriorityCode = VMTicket.PriorityCode, StatusID = VMTicket.StatusID, AssignedTo = assignedTo.Id, VendorID = VMTicket.VendorID, VendorTicket = VMTicket.VendorTicket, TicketTypeID = VMTicket.TicketTypeID, NeedsApproval = VMTicket.NeedsApproval, ApprovedBy = approvedBy == null ? (int?)null : approvedBy.Id, ApprovedOn = VMTicket.ApprovedOn }; return(vmT); }
private HelpDesk_Tickets_View_vm mapEntityToViewModelTicket(HelpDesk_Tickets EFTicket) { var vmT = new HelpDesk_Tickets_View_vm { Id = EFTicket.Id, TicketNumber = EFTicket.TicketNumber, Title = EFTicket.Title, Description = EFTicket.Description, Requestor = EFTicket.ServiceDesk_Users2 == null ? "" : (EFTicket.ServiceDesk_Users2.FirstName + " " + EFTicket.ServiceDesk_Users2.LastName), Department = EFTicket.Department.DepartmentName, Location = EFTicket.NSLocation.LocationCity, RequestDateTime = EFTicket.RequestDateTime, RequestedDueDate = EFTicket.RequestedDueDate, TicketCategory = EFTicket.HelpDesk_TicketCategory.Category, Priority = GetEnumDescription((TicketPriorityEnum)Convert.ToInt32(EFTicket.PriorityCode)), Status = EFTicket.HelpDesk_TicketStatus.Status, AssignedTo = EFTicket.ServiceDesk_Users1 == null ? "" : (EFTicket.ServiceDesk_Users1.FirstName + " " + EFTicket.ServiceDesk_Users1.LastName), Vendor = EFTicket.VendorTicket, VendorTicket = EFTicket.VendorTicket, TicketType = EFTicket.HelpDesk_TicketType.TicketType, NeedsApproval = EFTicket.NeedsApproval, ApprovedBy = EFTicket.ServiceDesk_Users == null ? "" : (EFTicket.ServiceDesk_Users.FirstName + " " + EFTicket.ServiceDesk_Users.LastName), ApprovedOn = EFTicket.ApprovedOn }; return(vmT); }
public int CreateTask(HelpDesk_Tasks task) { HelpDesk_Tickets ticket = _context.HelpDesk_Tickets.First(x => x.TicketNumber == task.TicketID); task.TicketID = ticket.Id; _context.HelpDesk_Tasks.Add(task); _context.SaveChanges(); return(task.Id); }
private HelpDesk_Tickets_vm mapEntityToViewModelSingleTicket(HelpDesk_Tickets EFTicket) { var vmT = new HelpDesk_Tickets_vm { TicketNumber = EFTicket.TicketNumber, Title = EFTicket.Title, Description = EFTicket.Description, RequestorUserName = EFTicket.ServiceDesk_Users2 == null ? null : EFTicket.ServiceDesk_Users2.UserName, DepartmentID = EFTicket.DepartmentID, LocationID = EFTicket.LocationID, RequestDateTime = EFTicket.RequestDateTime, RequestedDueDate = EFTicket.RequestedDueDate, TicketCategoryID = EFTicket.TicketCategoryID, PriorityCode = EFTicket.PriorityCode, StatusID = EFTicket.StatusID, AssignedToUserName = EFTicket.ServiceDesk_Users1 == null ? null : EFTicket.ServiceDesk_Users1.UserName, VendorID = EFTicket.VendorID, VendorTicket = EFTicket.VendorTicket, TicketTypeID = EFTicket.TicketTypeID, NeedsApproval = EFTicket.NeedsApproval, ApprovedByUserName = EFTicket.ServiceDesk_Users == null ? null : EFTicket.ServiceDesk_Users.UserName, ApprovedOn = EFTicket.ApprovedOn, ApprovedByUser = EFTicket.ServiceDesk_Users == null ? null: new Ticket_User() { SID = EFTicket.ServiceDesk_Users.SID, UserName = EFTicket.ServiceDesk_Users.UserName, DisplayName = EFTicket.ServiceDesk_Users.FirstName + " " + EFTicket.ServiceDesk_Users.LastName, UserDepartment = EFTicket.ServiceDesk_Users.Department.DepartmentName, UserLocation = EFTicket.ServiceDesk_Users.NSLocation.LocationCity }, AssignedToUser = EFTicket.ServiceDesk_Users1 == null ? null : new Ticket_User() { SID = EFTicket.ServiceDesk_Users1.SID, UserName = EFTicket.ServiceDesk_Users1.UserName, DisplayName = EFTicket.ServiceDesk_Users1.FirstName + " " + EFTicket.ServiceDesk_Users1.LastName, UserDepartment = EFTicket.ServiceDesk_Users1.Department.DepartmentName, UserLocation = EFTicket.ServiceDesk_Users1.NSLocation.LocationCity }, RequestorUser = EFTicket.ServiceDesk_Users2 == null ? null : new Ticket_User() { SID = EFTicket.ServiceDesk_Users2.SID, UserName = EFTicket.ServiceDesk_Users2.UserName, DisplayName = EFTicket.ServiceDesk_Users2.FirstName + " " + EFTicket.ServiceDesk_Users2.LastName, UserDepartment = EFTicket.ServiceDesk_Users2.Department.DepartmentName, UserLocation = EFTicket.ServiceDesk_Users2.NSLocation.LocationCity } }; return(vmT); }
private HelpDesk_TicketComments mapViewModelToEntityTicketComments(HelpDesk_TicketComments_vm VMTicketComment) { ServiceDesk_Users assignedTo = _nsUserRepository.GetUserByUserName(VMTicketComment.AuthorUserName); HelpDesk_Tickets relatedTicket = _helpDeskTicketRepository.GetTicketByID(VMTicketComment.TicketID); return(new HelpDesk_TicketComments { Id = VMTicketComment.Id, Author = assignedTo.Id, Comment = VMTicketComment.Comment, CommentDateTime = DateTime.UtcNow, CommentTypeID = VMTicketComment.CommentTypeID, TicketID = relatedTicket.Id }); }
public List <HelpDesk_TicketComments_vm> GetAllTicketComments(int ticketNumber) { if (ticketNumber == 0) { throw new ArgumentOutOfRangeException("TicketId cannot be 0."); } HelpDesk_Tickets relatedTicket = _helpDeskTicketRepository.GetTicketByID(ticketNumber); var allComments = _helpDeskTicketCommentRepository.GetAllTicketComments(relatedTicket.Id); if (allComments == null) { _logger.Warn("There are no comments for the ticket."); } return(allComments.Select(mapEntityToViewModelTicketComments).ToList()); }
public HelpDesk_Tickets GetTicketByID(int id) { HelpDesk_Tickets ticket = _context.HelpDesk_Tickets.FirstOrDefault(x => x.TicketNumber == id); return(ticket); }