/// <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));
        }
Beispiel #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),
            });
        }
        public async Task<GetForEditOutput<CategoryCreateOrUpdateDto>> GetForEdit(Guid id)
        {
            var find = await Repository
                .Include(x => x.AppProductCategories)
                .FirstOrDefaultAsync(z => z.Id == id);

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

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

            return new GetForEditOutput<CategoryCreateOrUpdateDto>(
                ObjectMapper.Map<ProductCategory, CategoryCreateOrUpdateDto>(find ?? new ProductCategory()), schema);
        }
Beispiel #4
0
        public async Task <GetForEditOutput <SwiperCreateOrUpdateDto> > GetForEdit(Guid id)
        {
            var find = await Repository
                       .FirstOrDefaultAsync(z => z.Id == id);

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

            var apps = _appDefinitionManager.GetAll();

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

            return(new GetForEditOutput <SwiperCreateOrUpdateDto>(
                       ObjectMapper.Map <Swiper, SwiperCreateOrUpdateDto>(find ?? new Swiper()), schema));
        }
Beispiel #5
0
        public async Task <IReadOnlyList <AppDefinition> > GetPublishList()
        {
            var list = _appDefinitionManager.GetAll();

            return(await Task.FromResult(list));
        }