Example #1
0
        public virtual UserInfoViewModel GetUserBasicInfo(int userId)
        {
            return(Cache.GetOrAdd($"UserBasicInfo_{userId}", () =>
            {
                var dbUser = _eJContext.Users.Find(userId);

                if (dbUser != null)
                {
                    return new UserInfoViewModel
                    {
                        Email = dbUser.Email,
                        Fio = dbUser.Fio,
                        Id = dbUser.Id,
                        Role = (RolesEnum)dbUser.RoleId
                    };
                }

                return new UserInfoViewModel
                {
                    Code = "",
                    Email = "",
                    Fio = "",
                    Role = RolesEnum.UnAuthorized
                };
                //throw new EntityNotFoundException($"Пользователь с id = <{userId}> не найден!");
            }));
        }