public T GetView(ApplicationDbContext db)
        {
            var context = new IdentityDbContext();
            var users   = context.Users.ToList();

            List <HRBrowseSurvey> surveys =
                (from e in db.T_Employees
                 join p in db.T_Positions on e.PositionId equals p.Id
                 into Joinp
                 from jp in Joinp.DefaultIfEmpty()
                 join s in db.T_Survey on e.Id equals s.EmployeeId
                 into Joins
                 from js in Joins.DefaultIfEmpty()
                 join t in db.T_Teams.DefaultIfEmpty() on e.TeamId equals t.Id
                 into Joint
                 from jt in Joint.DefaultIfEmpty()
                 where js.SurveyStatusId >= 3
                 orderby js.SurveyStatusId, jt.Name, e.FirstName, e.LastName
                 select new HRBrowseSurvey
            {
                SurveyId = js.Id,
                EmployeeId = e.Id,
                Employee = e.FirstName + " " + e.LastName,
                Team = jt.Name,
                SurveyName = js.Name,
                SurveyDate = js.SurveyDate,
                SurveyDadline = js.SurveyDadline,
                SurveyStatusId = js.SurveyStatusId
            }).ToList();

            return(surveys as T);
        }
        public T GetView(ApplicationDbContext db)
        {
            var context = new IdentityDbContext();
            var users   = context.Users.ToList();

            List <EmployeeExtended> employeeList =
                (from e in db.T_Employees
                 join p in db.T_Positions on e.PositionId equals p.Id
                 into Joinp
                 from jp in Joinp.DefaultIfEmpty()
                 join t in db.T_Teams.DefaultIfEmpty() on e.TeamId equals t.Id
                 into Joint
                 from jt in Joint.DefaultIfEmpty()
                 select new EmployeeExtended
            {
                Id = e.Id,
                TeamName = jt.Name,
                TeamId = e.TeamId,
                PositionName = jp.Name,
                PositionId = e.PositionId,
                FirstName = e.FirstName,
                LastName = e.LastName,
                UserId = e.UserId
            }).ToList();

            foreach (EmployeeExtended ee in employeeList)
            {
                if (db.T_Teams.Where(t => t.ManagerId == ee.Id).Count() > 0)
                {
                    ee.IsManager = true;
                }
                else
                {
                    ee.IsManager = false;
                }
            }

            List <EmployeeExtended> employeeList2 =
                (from e in employeeList
                 join u in users on new { userId = e.UserId } equals new { userId = u.Id }
                 where e.IsManager == true
                 orderby e.FirstName + e.LastName
                 select new EmployeeExtended
            {
                Id = e.Id,
                TeamName = e.TeamName,
                TeamId = e.TeamId,
                PositionName = e.PositionName,
                PositionId = e.PositionId,
                FirstName = e.FirstName,
                LastName = e.LastName,
                UserId = e.UserId,
                EMail = u.Email
            }).ToList();

            return(employeeList2 as T);
        }
예제 #3
0
        public T1 GetView(ApplicationDbContext db)
        {
            int?id = Parameters as int?;

            if (id == null)
            {
                return(null);
            }
            Team team = db.T_Teams.Find(id);

            if (team == null)
            {
                return(null);
            }

            Employee manager     = null;
            string   managerName = "";

            manager = db.T_Employees.Find(team.ManagerId);
            if (manager != null)
            {
                managerName = manager.FirstName + " " + manager.LastName;
            }


            TeamStructure teamStructure = new TeamStructure();
            TeamExtended  teamExtended  = new TeamExtended()
            {
                ManagerName = managerName,
                Name        = team.Name
            };

            List <EmployeeExtended> TeamMembers = new List <EmployeeExtended>();

            teamStructure.TeamMembers =
                (from e in db.T_Employees
                 join p in db.T_Positions on e.PositionId equals p.Id
                 into Joinp
                 from jp in Joinp.DefaultIfEmpty()
                 where e.TeamId == id
                 orderby e.FirstName + e.LastName
                 select new EmployeeExtended
            {
                FirstName = e.FirstName,
                LastName = e.LastName,
                PositionName = jp.Name
            }).ToList();

            teamStructure.TeamExtended = teamExtended;

            return(teamStructure as T1);
        }
예제 #4
0
        public T GetView(ApplicationDbContext db)
        {
            var context = new IdentityDbContext();
            var users   = context.Users.ToList();

            List <EmployeeExtended> employeeList =
                (from e in db.T_Employees
                 join p in db.T_Positions on e.PositionId equals p.Id
                 into Joinp from jp in Joinp.DefaultIfEmpty()
                 join t in db.T_Teams.DefaultIfEmpty() on e.TeamId equals t.Id
                 into Joint from jt in Joint.DefaultIfEmpty()
                 join m in db.T_Employees.DefaultIfEmpty() on jt.ManagerId equals m.Id
                 into Joinm from mg in Joinm.DefaultIfEmpty()

                 select new EmployeeExtended
            {
                Id = e.Id,
                TeamName = jt.Name,
                TeamId = e.TeamId,
                PositionName = jp.Name,
                PositionId = e.PositionId,
                FirstName = e.FirstName,
                LastName = e.LastName,
                UserId = e.UserId,
                Manager = mg.FirstName + " " + mg.LastName,
                HireDate = e.HireDate
            }).ToList();


            List <EmployeeExtended> employeeList2 =
                (from e in employeeList
                 join u in users on new { userId = e.UserId } equals new { userId = u.Id }
                 orderby e.FirstName + e.LastName
                 select new EmployeeExtended
            {
                Id = e.Id,
                TeamName = e.TeamName,
                TeamId = e.TeamId,
                PositionName = e.PositionName,
                PositionId = e.PositionId,
                FirstName = e.FirstName,
                LastName = e.LastName,
                UserId = e.UserId,
                EMail = u.Email,
                Manager = e.Manager,
                HireDate = e.HireDate
            }).ToList();

            return(employeeList2 as T);
        }