Exemple #1
0
        /// <summary>
        /// 获取用户个人信息
        /// </summary>
        /// <param name="id">用户编号</param>
        /// <param name="context">数据库连接上下文对象</param>
        /// <returns></returns>
        public async Task <ProfileViewModel> GetUserProfileAsync(long id, ApplicationDbContext context)
        {
            var webModel = new ProfileViewModel();

            try
            {
                var model = await BasicRepository.GetProfileAsync(id, context);

                webModel.Id         = model.Id.ToString();
                webModel.Name       = model.Name;
                webModel.Address    = model.Address;
                webModel.Age        = model.Age;
                webModel.CreateTime = model.CreatedOn.ToString();
                webModel.Email      = model.Email;
                webModel.Gender     = model.Gender;
                webModel.Phone      = model.Phone;
                webModel.Account    = model.Account;
            }
            catch (Exception ex)
            {
                _logger.LogError("获取用户个人数据失败:{0},\r\n内部错误信息:{1}", ex.Message, ex.InnerException.Message);
            }
            return(webModel);
        }