Esempio n. 1
0
        /// <summary>
        /// 获取客户详情
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <Resp> GetDetail()
        {
            using var db = new MyForContext();
            DB.Tables.Client client = await db.Clients.AsNoTracking()
                                      .Include(c => c.Avatar)
                                      .FirstOrDefaultAsync(c => c.Id == Id);

            if (client is null)
            {
                return(Resp.Fault(Resp.NONE, NOT_CLIENT));
            }

            Results.ClientDetail detail = new Results.ClientDetail
            {
                AccountName = client.AccountName,
                Description = client.Description,
                Email       = client.Email,
                Phone       = client.Phone,
                Gender      = new Share.KeyValue
                {
                    Key   = client.Gender,
                    Value = ((User.Gender)client.Gender).GetDescription()
                },
                Avatar     = client.Avatar.Path,
                Thumbnail  = client.Avatar.Thumbnail,
                CreateDate = client.CreateDate.ToStandardString()
            };
            return(Resp.Success(detail, ""));
        }
Esempio n. 2
0
        public async Task <Results.ClientDetail> GetUserInfoAsync()
        {
            using var db = new YGBContext();

            DB.Tables.User user = await db.Users.AsNoTracking()
                                  .Include(u => u.Avatar)
                                  .FirstOrDefaultAsync(u => u.Id == Id);

            if (user is null)
            {
                throw new NullReferenceException(USER_NOT_EXIST);
            }

            Results.ClientDetail detail = new Results.ClientDetail
            {
                UserName   = user.Name,
                Email      = user.Email,
                CreateDate = user.CreateDate.ToStandardDateString(),
                Avatar     = user.Avatar.Path,
                State      = Share.KeyValue <int, string> .Create(user.State, user.State.GetDescription <UserState>())
            };
            return(detail);
        }