コード例 #1
0
        public async Task <IActionResult> GetLawyerDetails()
        {
            var vm = new UserProfileViewModel {
            };

            try
            {
                var userId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
                var user   = await UserManager.FindByIdAsync(userId);

                if (user == null)
                {
                    return(Unauthorized());
                }


                vm = new UserProfileViewModel
                {
                    Id          = userId,
                    Age         = user.DateOfBirth.HasValue ? user.DateOfBirth.Value.CalculateAge() : 0,
                    Email       = user.Email,
                    Name        = user.Name,
                    NameEn      = user.NameEn,
                    UserName    = user.UserName,
                    LawyerId    = user.LawyerId,
                    DateOfBirth = user.DateOfBirth.HasValue ? user.DateOfBirth.Value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture) : "",
                    Gender      = user.Gender,
                    PhoneNumber = user.PhoneNumber,
                    ProvinceId  = user.ProvinceId,
                    ProfileImg  = string.IsNullOrEmpty(user.ProfileImg) ? "/images/personal-img.jpg" : user.ProfileImg,
                };
                vm.Provinces = CountryService.GetProvinces();
                if (user.LawyerId.HasValue)
                {
                    var lawyer = lawyerService.GetLawyer(user.LawyerId.Value);
                    vm.Spetializations  = lawyerService.GetSpetializations();
                    vm.SpetializationId = lawyer.SpecializationId;
                    vm.Sessions         = SesstionService.GetLawyerSesstions(user.LawyerId.Value);
                    vm.Description      = lawyer.Description;
                    vm.DescriptionEn    = lawyer.DescriptionEn;
                    vm.Certificates     = lawyer.Certificates;
                    vm.CertificatesEn   = lawyer.CertificatesEn;
                    vm.Price            = lawyer.Fees;
                    vm.Rating           = lawyerService.GetRating(user.LawyerId.Value);
                    vm.ExperienceId     = lawyer.ExperienceId;

                    vm.Experiences       = lawyerService.GetLawyerExperiences();
                    vm.Services          = ServiceService.Get(user.LawyerId.Value);
                    vm.ServiceCategories = ServiceService.GetCategories(user.LawyerId.Value);
                    vm.VideoURL          = lawyer.VideoURL;


                    lawyer.ModifiedDate = DateTime.Now;
                    lawyerService.UpdateLawyer(lawyer);
                }
            }
            catch (Exception ex)
            {
                throw;
            }

            return(Ok(vm));
        }