Esempio n. 1
0
        private async Task <ProfileViewModel> getProfileViewModel(string slugUrl)
        {
            var user = await _userEngine.CurrentUser(_userManager.GetUserId(User));

            return(new ProfileViewModel()
            {
                ProfileImageUrl = user.ProfileImageUrl,
                AvatarUrl = user.AvatarUrl,
                FullName = user.FullName,
                Title = user.Title,
                Email = user.Email,
                CellPhone = user.PhoneNumber,
                Phone = user.PhoneNumber2,
                SlugUrl = slugUrl,
                Description = user.Description,
                Provinces = _projectEngine.GetProvincesSelectList(),
                ProvinceId = user.ProvinceId.HasValue ? user.ProvinceId.Value : 0,
                Districts = _projectEngine.GetDistrictsSelectList(user.ProvinceId),
                DistrictId = user.DistrictId.HasValue ? user.DistrictId.Value : 0,
                Address = user.Address,
                UserCategories = _projectEngine.GetUserCategories(),
                SelectedUserCategories = user.UserCategoryRelation.Select(i => i.Category.SlugUrl),
                UserExperienceImages = _userEngine.GetGallery(_userManager.GetUserId(User)),
                SMSNotAllowed = user.SmsNotAllowed
            });
        }
        async public Task <IActionResult> Search(
            string keyword,
            string zone,
            Guid?categoryId = null,
            int?provinceId  = null,
            int?districtId  = null)
        {
            SetPageContent("search");

            var result = _projectEngine.SearchItems(keyword, zone, categoryId: categoryId, provinceId: provinceId, districtId: districtId);

            var user = await _userEngine.CurrentUser(_userManager.GetUserId(User));

            var model = new SearchViewModel()
            {
                PageNumber       = 0,
                Result           = result,
                SearchSortTypes  = _projectEngine.GetSearchSortTypes(),
                SearchSortTypeId = (int)SearchSortTypes.Newest,
                Provinces        = _projectEngine.GetProvincesSelectList(),
                Categories       = _projectEngine.GetUserCategories()
            };

            if (provinceId.HasValue)
            {
                model.Districts = _projectEngine.GetDistrictsSelectList(provinceId);
            }
            else
            {
                model.Districts = _projectEngine.GetDistrictsSelectList(null);
            }

            return(View(model));
        }