/// <summary>
        /// Return all the issues, get information from the issue table and issue history table
        /// (get assigned to and status from the latest issue history entry of the corresponding issue),
        /// which are active and are posted by the given EmployeeId
        /// </summary>
        /// <param name="employeeId"></param>
        /// <returns></returns>
        public IList <IComplexIssueDTO> GetAllIssuesByEmployeeId(int employeeId)
        {
            IList <IComplexIssueDTO> issueDTOList = null;
            IComplexIssueDTO         issueDTO     = null;

            try
            {
                using (EmployeePortal2017Entities portal = new EmployeePortal2017Entities())
                {
                    var issueList = portal.GetAllIssuesByEmployeeId(employeeId).ToList();
                    if (issueList.Count > 0)
                    {
                        issueDTOList = new List <IComplexIssueDTO>();
                        foreach (var issue in issueList)
                        {
                            issueDTO = (IComplexIssueDTO)DTOFactory.Instance.Create(DTOType.ComplexIssueDTO);
                            EntityConverter.FillDTOFromComplexObject(issue, issueDTO);
                            issueDTOList.Add(issueDTO);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex);
                throw new DACException(ex.Message);
            }

            return(issueDTOList);
        }
        /// <summary>
        /// Return IssueDTO corresponding to the passed issue id.
        /// The IssueDTO should also contain nested inside it list of IIssueHistoryDTOs
        /// </summary>
        /// <param name="issueId"></param>
        /// <returns></returns>
        public IIssueDTO GetIssue(int issueId)
        {
            IIssueDTO issueDTO = null;

            try
            {
                using (EmployeePortal2017Entities portal = new EmployeePortal2017Entities())
                {
                    var issue = portal.Issues.Include("Employee")
                                .Where(i => i.IssueId == issueId && i.IsActive)
                                .SingleOrDefault();
                    if (issue != null)
                    {
                        issueDTO = (IIssueDTO)DTOFactory.Instance.Create(DTOType.IssueDTO);
                        EntityConverter.FillDTOFromEntity(issue, issueDTO);

                        issueDTO.EmployeeDTO = (IEmployeeDTO)DTOFactory.Instance.Create(DTOType.EmployeeDTO);
                        EntityConverter.FillDTOFromEntity(issue.Employee, issueDTO.EmployeeDTO);

                        var issueHistoryList = portal.GetIssueHistoryByIssueId(issueId).ToList();
                        if (issueHistoryList.Count > 0)
                        {
                            issueDTO.IssueHistories = new List <IComplexIssueHistoryDTO>();
                            IComplexIssueHistoryDTO issueHistoryDTO = null;
                            foreach (var issueHistory in issueHistoryList)
                            {
                                issueHistoryDTO = (IComplexIssueHistoryDTO)DTOFactory.Instance.Create(DTOType.ComplexIssueHistoryDTO);
                                EntityConverter.FillDTOFromComplexObject(issueHistory, issueHistoryDTO);
                                issueDTO.IssueHistories.Add(issueHistoryDTO);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex);
                throw new DACException(ex.Message);
            }
            return(issueDTO);
        }