Ejemplo n.º 1
0
        public TicketBaseData GetTicketData(TicketRequestModel ticketRequestModel)
        {
            var ticketBaseData = new TicketBaseData();

            if (ticketRequestModel.TicketId != null)
            {
                ticketBaseData.Ticket = ticketRepository.Find((int)ticketRequestModel.TicketId);
            }

            ticketBaseData.TicketTypes = ticketTypeRepository.GetActiveTicketTypes();
            ticketBaseData.Tickets     = ticketRepository.GetTicketsByEmployeeId(ticketRequestModel.EmployeeId);
            ticketBaseData.Employees   = employeeRepository.GetAll();


            if (!ticketRequestModel.ViewTicketsOfAllEmployees)
            {
                var employee = employeeRepository.Find(ticketRequestModel.EmployeeId);

                var emploeeIds = employee.SupervisorOfEmployees.Select(x => x.EmployeeId).ToList();

                var ticketsOfEmployees = ticketRepository.GetTicketsOfEmployeesUnderASupervisor(emploeeIds);

                ticketBaseData.TicketsOfEmployees = ticketsOfEmployees;
            }
            else
            {
                var ticketsOfEmployees = ticketRepository.GetAllExceptEmployeeId(ticketRequestModel.EmployeeId);

                ticketBaseData.TicketsOfEmployees = ticketsOfEmployees;
            }


            return(ticketBaseData);
        }