Пример #1
0
        /// <summary>
        /// 获取编辑
        /// </summary>
        /// <param name="id"></param>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <GetForEditOutput <SpuCreateOrUpdateDto> > GetForEdit(Guid id)
        {
            var find = await Repository
                       .Include(x => x.Skus)
                       .Include(x => x.AppProductSpus)
                       .FirstOrDefaultAsync(z => z.Id == id);

            var schema = JToken.FromObject(new { });

            var categoryList = await _categoryRepository.GetListAsync();

            schema["categoryId"] = categoryList.GetSelection("string", "categoryId", @"{0}", new[] { "Name" }, "Id");

            var shops = await _mallShopRepository.GetListAsync();

            schema["shopId"] = shops.GetSelection("string", "shopId", @"{0}", new[] { "Name" }, "Id");

            var apps = _appDefinitionManager.GetAll();

            schema["apps"] = apps.GetSelection("string", "appName", @"{0}", new[] { "Name" }, "Name");

            return(new GetForEditOutput <SpuCreateOrUpdateDto>(
                       ObjectMapper.Map <ProductSpu, SpuCreateOrUpdateDto>(find ?? new ProductSpu()
            {
                Skus = new List <ProductSku>()
                {
                    new ProductSku("name")
                }
            }), schema));
        }
Пример #2
0
        public async Task <object> Init(ClientInitRequestDto input)
        {
            var appName = _httpContextAccessor?.HttpContext.Request.Headers["AppName"].FirstOrDefault();

            await _eventBus.PublishAsync(new ClientInitEvent(input));

            var apps  = _appDefinitionManager.GetAll();
            var shops = await _shopRepository.GetListAsync();

            var categories = await _categoryRepository.GetPublicListAsync(new MallRequestDto()
            {
                ShopId = input.ShopId, AppName = appName
            });

            var spus = await _spuRepository.Include(x => x.Skus).ToListAsync();

            return(new
            {
                shops = ObjectMapper.Map <List <MallShop>, List <MallShopDto> >(shops),
                apps,
                appName,
                categories,
                spus = ObjectMapper.Map <List <ProductSpu>, List <ProductSpuDtoBase> >(spus),
            });
        }
Пример #3
0
        public async Task <ListResultDto <MallShopDto> > GetListAsync()
        {
            var shops = await _mallShopRepository.GetListAsync();

            return(new ListResultDto <MallShopDto>(
                       ObjectMapper.Map <List <MallShop>, List <MallShopDto> >(shops)
                       ));
        }
Пример #4
0
        public async Task <object> Init(ClientInitRequestDto input)
        {
            var shops = await _shopRepository.GetListAsync();

            return(new
            {
                shops = ObjectMapper.Map <List <MallShop>, List <MallShopDto> >(shops)
            });
        }
Пример #5
0
        public async Task <object> Init(ClientInitRequestDto input)
        {
            await _eventBus.PublishAsync(new ClientInitEvent(input));

            var apps = await _appProvider.GetAllAsync();

            var shops = await _shopRepository.GetListAsync();

            var appName = _httpContextAccessor?.HttpContext.Request.Headers["AppName"].FirstOrDefault();

            return(new
            {
                shops = ObjectMapper.Map <List <MallShop>, List <MallShopDto> >(shops),
                apps, appName
            });
        }