Esempio n. 1
0
        public async Task GetProfileDataAsync(ProfileDataRequestContext context)
        {
            var   messageError    = String.Empty;
            Claim companyClaim    = context.Subject.Claims.Where <Claim>(claim => claim.Type.Equals("companyId")).FirstOrDefault();
            Claim officeClaim     = context.Subject.Claims.Where <Claim>(claim => claim.Type.Equals("officeId")).FirstOrDefault();
            Claim departmentclaim = context.Subject.Claims.Where <Claim>(claim => claim.Type.Equals("departmentId")).FirstOrDefault();
            Claim groupClaim      = context.Subject.Claims.Where <Claim>(claim => claim.Type.Equals("groupId")).FirstOrDefault();


            var subjectId = context.Subject.GetSubjectId();
            var user      = authenUserService.GetUserById(subjectId);
            var employee  = employeeService.First(x => x.Id == user.EmployeeId);


            var claims = new List <Claim>
            {
                new Claim(JwtClaimTypes.Id, user.Id),
                new Claim(JwtClaimTypes.Email, user.Email),
                new Claim(JwtClaimTypes.PreferredUserName, user.Username),
                new Claim(JwtClaimTypes.PhoneNumber, user.Tel ?? ""),
                //new Claim("workplaceId",user.WorkPlaceId?.ToString()),
                new Claim("userName", user.Username),
                new Claim("employeeId", employee.Id),
                companyClaim,
                officeClaim,
                departmentclaim,
                groupClaim
            };

            context.IssuedClaims = claims;
        }
Esempio n. 2
0
        public IActionResult GetByEmployeeId(string employeeid)
        {
            var result = sysEmployeeService.First(x => x.Id == employeeid);

            if (result == null)
            {
                return(BadRequest(new ResultHandle {
                    Status = false, Message = "Không tìm thấy Employee", Data = result
                }));
            }
            else
            {
                return(Ok(new ResultHandle {
                    Status = true, Message = "Success", Data = result
                }));
            }
        }
Esempio n. 3
0
        public IActionResult GetBy(string id)
        {
            var result       = sysUserService.Get(x => x.Id == id).FirstOrDefault();
            var userCreate   = sysUserService.Get(x => x.Id == result.UserCreated).FirstOrDefault();
            var userModified = sysUserService.Get(x => x.Id == result.UserModified).FirstOrDefault();

            result.UserCreated      = userCreate?.Username;
            result.UserModified     = userModified?.Username;
            result.SysEmployeeModel = sysEmployeeService.First(x => x.Id == result.EmployeeId);
            if (result == null)
            {
                return(BadRequest(new ResultHandle {
                    Status = false, Message = "Error", Data = result
                }));
            }
            else
            {
                return(Ok(new ResultHandle {
                    Status = true, Message = "Success", Data = result
                }));
            }
        }