public AuthTicketDTO GetAuthDTO(string userName) { AuthTicketDTO AuthTicket = SessionServices.GetAuthTicket(userName); if (AuthTicket != null) { return(AuthTicket); } bool IsArabic = CultureInfo.CurrentCulture.IsArabic(); User AuthUser = _users.GetAll(false, "UserRoles").Where(x => x.Username.ToUpper() == userName.ToUpper()).FirstOrDefault(); if (AuthUser != null) { if (!AuthUser.Enabled) { throw new BusinessException(_StringLocalizer.GetString("AccountIsDisabled")); } if (!AuthUser.IsApproved) { throw new BusinessException(_StringLocalizer.GetString("AccountIsNotApproved")); } AuthTicketDTO Result = new AuthTicketDTO() { Email = AuthUser.Email, FullName = AuthUser.FullName, UserName = AuthUser.Username, UserId = AuthUser.UserId, DefaultCulture = AuthUser.DefaultCulture, RoleId = AuthUser.UserRoles.FirstOrDefault()?.RoleId, RoleName = AuthUser.UserRoles.FirstOrDefault()?.Role.RoleName, }; //Using Sessions Cache to Save AuthTicket SessionServices.SetAuthTicket(Result.UserName, Result); return(Result); } return(null); }