Exemplo n.º 1
0
        public static SessionUserLogin GetSessionUser(this HttpContext context)
        {
            SessionUserLogin session = null;

            if (context.Session.IsExists("E_SESSION_USER"))
            {
                session = context.Session.Get <SessionUserLogin>("E_SESSION_USER");
            }
            return(session);
        }
Exemplo n.º 2
0
        public SessionUserLogin GetSessionUser(string userId)
        {
            var session = new SessionUserLogin();
            var user    = _context.Users.FirstOrDefault(x => x.Id == userId && x.Active == true);

            if (user != null)
            {
                session.UserId         = user.Id;
                session.UserName       = user.UserName;
                session.FullName       = user.GivenName;
                session.Email          = user.Email;
                session.EmployeeCode   = user.EmployeeCode;
                session.CompanyCode    = "TAMLONG";
                session.SessionTimeOut = _parameterService.GetSessionTimeout();
                session.ExpireTimeSpan = DateTime.Now.AddMinutes(session.SessionTimeOut);
                session.Picture        = user.Picture;

                //session.CompanyCode = user.Company_Code;
                //session.CompanyCode = "CO-3I";
                var permissions = _context.AdPermissions
                                  .Where(x => x.UserId == userId)
                                  .Select(x => new PermissionObject
                {
                    //FunctionId = x.FunctionId,
                    FunctionCode  = x.Function.FunctionCode,
                    FunctionTitle = x.Function.Title,
                    //ResourceId = x.ResourceId,
                    ResourceCode   = x.Resource.ResourceCode,
                    ResourceTitle  = x.Resource.Title,
                    ResourceApi    = x.Resource.Api,
                    GroupUserCode  = x.GroupUserCode,
                    GroupUserTitle = x.GroupUser.Title,
                    RoleId         = x.RoleId,
                    RoleTitle      = x.Role.Title,
                });
                session.Permissions = permissions.ToList();
            }

            return(session);
        }
Exemplo n.º 3
0
 public static void SetSessionUser(this HttpContext context, SessionUserLogin session)
 {
     context.Session.Set("E_SESSION_USER", session);
 }