Exemplo n.º 1
0
        public List <ProjectMasterViewModel> GetAssignedProjects(int userId)
        {
            var _context    = new DatabaseContext();
            var queryResult = (from registration in _context.Registration
                               join A in _context.AssignedRoles on registration.RegistrationID equals A.RegistrationID into A_join
                               from A in A_join.DefaultIfEmpty()
                               join AA in _context.Registration on A.AssignToAdmin equals AA.RegistrationID into AA_join
                               from AA in AA_join.DefaultIfEmpty()
                               join _assignedProjects in _context.AssignedProjects on registration.RegistrationID equals _assignedProjects.ManagerId into RL_join
                               from _assignedProjects in RL_join.DefaultIfEmpty()
                               join projectmaster in _context.ProjectMaster on _assignedProjects.ProjectId equals projectmaster.ProjectID into D_join
                               from Proj in D_join.DefaultIfEmpty()
                               where registration.RegistrationID == userId
                               select new ProjectMasterViewModel()
            {
                ProjectID = Proj.ProjectID,
                ProjectCode = Proj.ProjectCode,
                ProjectName = Proj.ProjectName,
                FirstName = AA.FirstName,
                LastName = AA.LastName,
                MiddleName = AA.MiddleName,
                IsActive = Proj.IsActive
            }).ToList();

            return(queryResult);
        }
Exemplo n.º 2
0
 public RegistrationViewDetailsModel GetUserDetailsByRegistrationID(int?RegistrationID)
 {
     try
     {
         using (var _context = new DatabaseContext())
         {
             //string[] RoleCodes = new string[] { "SuperAdmin", "Manager" };
             var queryResult = (from registration in _context.Registration
                                join A in _context.AssignedRoles on registration.RegistrationID equals A.RegistrationID into A_join
                                from A in A_join.DefaultIfEmpty()
                                join AA in _context.Registration on A.AssignToAdmin equals AA.RegistrationID into AA_join
                                from AA in AA_join.DefaultIfEmpty()
                                join role in _context.Role on registration.RoleID equals role.RoleID into RL_join
                                from role in RL_join.DefaultIfEmpty()
                                join department in _context.Departments on registration.DeptId equals department.DeptId into D_join
                                from department in D_join.DefaultIfEmpty()
                                join job in _context.Jobs on registration.JobId equals job.JobId into J_join
                                from job in J_join.DefaultIfEmpty()
                                where registration.RegistrationID == RegistrationID
                                select new RegistrationViewModel()
             {
                 registration = registration,
                 roles = role,
                 departments = department,
                 jobs = job,
                 ManagerFirstName = AA.FirstName,
                 ManagerLastName = AA.LastName,
                 ManagerMiddleName = AA.MiddleName
             }).FirstOrDefault();
             if (queryResult != null)
             {
                 var objRegistrationViewDetailsModel = new RegistrationViewDetailsModel()
                 {
                     Birthdate              = string.IsNullOrEmpty(queryResult.registration.Birthdate.ToString()) ? "" : Convert.ToDateTime(queryResult.registration.Birthdate, new CultureInfo("es-US", true)).ToString("MM/dd/yyyy"),
                     DateofJoining          = string.IsNullOrEmpty(queryResult.registration.DateofJoining.ToString()) ? "" : Convert.ToDateTime(queryResult.registration.DateofJoining, new CultureInfo("es-US", true)).ToString("MM/dd/yyyy"),
                     DateofLeaving          = string.IsNullOrEmpty(queryResult.registration.DateofLeaving.ToString()) ? "" : Convert.ToDateTime(queryResult.registration.DateofLeaving, new CultureInfo("es-US", true)).ToString("MM/dd/yyyy"),
                     EmailID                = queryResult.registration.EmailID,
                     EmployeeID             = queryResult.registration.EmployeeID,
                     Gender                 = queryResult.registration.Gender,
                     IsActive               = Convert.ToBoolean(queryResult.registration.IsActive),
                     Mobileno               = queryResult.registration.Mobileno,
                     FirstName              = queryResult.registration.FirstName,
                     MiddleName             = queryResult.registration.MiddleName,
                     LastName               = queryResult.registration.LastName,
                     RegistrationID         = queryResult.registration.RegistrationID,
                     RoleID                 = Convert.ToInt32(queryResult.registration.RoleID),
                     Username               = queryResult.registration.Username,
                     WorkEmail              = queryResult.registration.WorkEmail,
                     EmergencyContact       = queryResult.registration.EmergencyContact,
                     EmergencyContactNumber = queryResult.registration.EmergencyContactNumber,
                     DeptId                 = Convert.ToInt32(queryResult.registration.DeptId),
                     ManagerId              = Convert.ToInt32(queryResult.registration.ManagerId),
                     JobId             = Convert.ToInt32(queryResult.registration.JobId),
                     JobTitle          = queryResult.jobs == null ? "" : queryResult.jobs.JobTitle,
                     RoleName          = queryResult.roles == null ? "" : queryResult.roles.Rolename,
                     DepartmentName    = queryResult.departments == null ? "" : queryResult.departments.DepartmentName,
                     ManagerFirstName  = queryResult.ManagerFirstName == null ? "" : queryResult.ManagerFirstName,
                     ManagerMiddleName = queryResult.ManagerMiddleName == null ? "" : queryResult.ManagerMiddleName,
                     ManagerLastName   = queryResult.ManagerLastName == null ? "" : queryResult.ManagerLastName
                 };
                 return(objRegistrationViewDetailsModel);
             }
             return(new RegistrationViewDetailsModel());
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }