Пример #1
0
        public async Task <CurrentUserProfileEditDto> GetCurrentUserProfileForEdit()
        {
            var user = await GetCurrentUserAsync();

            var userAccount = await GetCurrentUserAccountCacheAsync();

            var userProfileEditDto = ObjectMapper.Map <CurrentUserProfileEditDto>(user);

            userProfileEditDto.ProfilePictureUrl = await _pictureManager.GetPictureUrlAsync(userAccount.ProfilePictureId);

            userProfileEditDto.NickName    = userAccount.NickName;
            userProfileEditDto.Gender      = userAccount.Gender;
            userProfileEditDto.PhoneNumber = user.PhoneNumber;
            if (Clock.SupportsMultipleTimezone)
            {
                userProfileEditDto.Timezone = await SettingManager.GetSettingValueAsync(TimingSettingNames.TimeZone);

                var defaultTimeZoneId = await _timeZoneService.GetDefaultTimezoneAsync(SettingScopes.User, AbpSession.TenantId);

                if (userProfileEditDto.Timezone == defaultTimeZoneId)
                {
                    userProfileEditDto.Timezone = string.Empty;
                }
            }

            return(userProfileEditDto);
        }
Пример #2
0
        /// <summary>
        /// 获取租户基本信息
        /// </summary>
        /// <returns></returns>
        public async Task <TenantInfoEditDto> GetTenantInfoForEdit()
        {
            if (!AbpSession.TenantId.HasValue)
            {
                throw new UserFriendlyException(L("CanNotFindTenant"));
            }

            var tenant = await TenantManager.GetByIdAsync(AbpSession.TenantId.Value);

            var tenantDto = ObjectMapper.Map <TenantInfoEditDto>(tenant);

            tenantDto.LogoUrl = await _pictureManager.GetPictureUrlAsync(tenant.LogoId);

            tenantDto.BackgroundPictureUrl = await _pictureManager.GetPictureUrlAsync(tenant.BackgroundPictureId);

            return(tenantDto);
        }
Пример #3
0
        public async Task <GetCurrentLoginInformationsOutput> GetCurrentLoginInformations()
        {
            var output = new GetCurrentLoginInformationsOutput
            {
                Application = new ApplicationInfoDto
                {
                    Version     = AppVersionHelper.Version,
                    ReleaseDate = AppVersionHelper.ReleaseDate,
                    Features    = new Dictionary <string, bool>
                    {
                    }
                }
            };

            if (AbpSession.TenantId.HasValue)
            {
                var tenant = _tenantCache.Get(AbpSession.GetTenantId());
                output.Tenant = ObjectMapper.Map <TenantLoginInfoDto>(tenant);

                //output.Tenant = ObjectMapper
                //                    .Map<TenantLoginInfoDto>(await TenantManager
                //                        .Tenants
                //                        .Include(t => t.Edition)
                //                        .FirstAsync(t => t.Id == AbpSession.GetTenantId()));

                //output.Tenant.LogoUrl = await _pictureManager.GetPictureUrlAsync(output.Tenant.LogoId);
            }

            if (AbpSession.UserId.HasValue)
            {
                var userLoginInfo = await GetCurrentUserAsync();

                var account = await GetCurrentUserAccountCacheAsync();

                output.User = ObjectMapper.Map <UserLoginInfoDto>(userLoginInfo);
                output.User.ProfilePictureUrl       = (account != null ? await _pictureManager.GetPictureUrlAsync(account.ProfilePictureId) : string.Empty);
                output.User.UnreadNotificationCount = await _userNotificationManager.GetUserNotificationCountAsync(
                    AbpSession.ToUserIdentifier(), UserNotificationState.Unread);
            }

            if (output.Tenant == null)
            {
                return(output);
            }

            if (output.Tenant.Edition != null)
            {
                // 是否最高版本
                output.Tenant.Edition.IsHighestEdition = await IsEditionHighest(output.Tenant.Edition.Id);
            }

            output.Tenant.SubscriptionDateString = GetTenantSubscriptionDateString(output);
            output.Tenant.CreationTimeString     = output.Tenant.CreationTime.ToString("d");

            return(output);
        }
Пример #4
0
        public async Task <GetStoreForEditOutput> GetStoreForEdit(NullableIdDto <int> input)
        {
            GetStoreForEditOutput storeDto;

            if (input.Id.HasValue) //Editing existing store?
            {
                var store = await _storeManager.GetByIdAsync(input.Id.Value);

                storeDto = ObjectMapper.Map <GetStoreForEditOutput>(store);

                storeDto.PictureUrl = await _pictureManager.GetPictureUrlAsync(store.PictureId);
            }
            else
            {
                storeDto = new GetStoreForEditOutput();
            }

            return(storeDto);
        }
Пример #5
0
        public async Task <GetCategoryForEditOutput> GetCategoryForEdit(NullableIdDto <int> input)
        {
            GetCategoryForEditOutput catalogyDto;

            if (input.Id.HasValue) //Editing existing category?
            {
                var catalogy = await _catalogyManager.GetByIdAsync(input.Id.Value);

                catalogyDto = ObjectMapper.Map <GetCategoryForEditOutput>(catalogy);

                catalogyDto.PictureUrl = await _pictureManager.GetPictureUrlAsync(catalogy.PictureId);
            }
            else
            {
                catalogyDto = new GetCategoryForEditOutput();
            }

            return(catalogyDto);
        }
Пример #6
0
        /// <summary>
        /// 获取产品图片
        /// </summary>
        /// <param name="product">产品</param>
        /// <param name="attributesJson">属性json字符串</param>
        /// <param name="pictureManager"></param>
        /// <param name="productAttributeParser"></param>
        /// <returns>Picture</returns>
        public static async Task <string> GetProductDefaultPictureUrl(this Product product, string attributesJson,
                                                                      IPictureManager pictureManager,
                                                                      IProductAttributeParser productAttributeParser)
        {
            if (product == null)
            {
                throw new AbpException("product");
            }
            if (pictureManager == null)
            {
                throw new AbpException("pictureManager");
            }
            if (productAttributeParser == null)
            {
                throw new AbpException("productAttributeParser");
            }

            long pictureId = 0;

            if (!attributesJson.IsNullOrEmpty())
            {
                var jsonAttributeList = JsonConvert.DeserializeObject <List <JsonProductAttribute> >(attributesJson);

                var pvaValues = await productAttributeParser.ParseProductAttributeValuesAsync(product.Id, jsonAttributeList);

                if (pvaValues != null && pvaValues.Any())
                {
                    pictureId = pvaValues.First().PictureId;
                }
            }

            if (pictureId == 0)
            {
                var pPicture = product.Pictures.FirstOrDefault();

                if (pPicture != null)
                {
                    pictureId = pPicture.PictureId;
                }
            }

            return(await pictureManager.GetPictureUrlAsync(pictureId));;
        }