コード例 #1
0
        public async Task <ActionResult <UserViewModel> > Get(
            [FromQuery(Name = "id")] string id
            )
        {
            var user = (await _userService.GetAsync(id)).Adapt <UserViewModel>();

            user.ImgUrl = user.ImgUrl;
            if (user.ProvinceId != null && user.ProvinceId != "" && user.IsAdmin == false)
            {
                user.ProvinceName = (await _provinceService.GetByIdAsync(user.ProvinceId)).Name;
                user.DistrictName = (await _districtService.GetByIdAsync(user.DistrictId)).Name;
                user.WardName     = (await _wardService.GetByIdAsync(user.WardId)).Name;
            }
            if (user.IsAdmin == false)
            {
                user.BirthDay = Convert.ToDateTime(user.BirthDay).ToLocalTime().ToString("yyyy-MM-dd");
            }
            if (user == null)
            {
                return(BadRequest("user not found"));
            }
            return(Ok(user));
        }