Пример #1
0
        // GET: Configuration/Edit/5
        public async Task <ActionResult> EditAsync(Guid id)
        {
            if (id == null)
            {
                return(BadRequest());
            }
            Config config = await configRepository.Find(id);

            if (config == null)
            {
                return(NotFound());
            }
            return(View(config));
        }
Пример #2
0
        public override PageResult <MaterialDTO> Search(SearchArgs <Material> searchArgs)
        {
            var result = Mapper.Map <PageResult <MaterialDTO> >(Repository.Search(searchArgs));

            foreach (var item in result.Items)
            {
                item.Configs = Mapper.Map <List <MaterialConfigDTO> >(ConfigRepository.Find(x => x.MaterialId == item.Id));
            }
            return(Mapper.Map <PageResult <MaterialDTO> >(result));
        }
        public override MaterialCategoryDTO GetById(int?id)
        {
            var dto = base.GetById(id);

            if (dto != null)
            {
                dto.Configs = Mapper.Map <List <MaterialCategoryConfigDTO> >(ConfigRepository.Find(x => x.MaterialCategoryId == id).OrderBy(x => x.Sort).ToList());
            }
            dto.HasChildren = MaterialRepository.Count(x => x.CategoryId == id) > 0;
            return(dto);
        }
        public override PageResult <MaterialCategoryDTO> Search(SearchArgs <MaterialCategory> searchArgs)
        {
            var result = base.Search(searchArgs);

            foreach (var item in result.Items)
            {
                item.Configs = Mapper.Map <List <MaterialCategoryConfigDTO> >(
                    ConfigRepository.Find(x => x.MaterialCategoryId == item.Id).OrderBy(x => x.Sort));
                item.HasChildren = MaterialRepository.Count(x => x.CategoryId == item.Id) > 0;
            }
            return(result);
        }
Пример #5
0
        public PageResult <IDictionary <string, object> > SearchDic(SearchArgs <Material> searchArgs)
        {
            var result = Search(searchArgs);
            var list   = new List <IDictionary <string, object> >();

            foreach (var item in result.Items)
            {
                var brand           = BrandRepository.FindById(item.BrandId);
                var typeDTO         = MaterialTypeService.GetById(item.TypeId);
                var materialConfigs = ConfigRepository.Find(x => x.MaterialId == item.Id).ToDictionary(x => x.ConfigKey);
                var configs         = typeDTO.Configs.Select(x => new MaterialConfigDTO()
                {
                    ConfigKey       = x.ConfigKey,
                    ConfigKeyDesc   = x.ConfigKeyDesc,
                    ConfigValueType = x.ConfigValueType,
                    ConfigValue     = materialConfigs.ContainsKey(x.ConfigKey) ? materialConfigs[x.ConfigKey].ConfigValue : x.ConfigDefaultValue,
                    MaterialId      = item.Id,
                    Remark          = x.Remark,
                    Sort            = x.Sort
                }).ToList();
                item.Configs      = configs;
                item.BrandName    = brand.Name;
                item.CategoryId   = typeDTO.CategoryId;
                item.CategoryName = typeDTO.CategoryName;
                item.TypeName     = typeDTO.Name;
                var dic = item.ToDictionary();
                foreach (var c in item.Configs)
                {
                    dic.Add(c.ConfigKey, c.ConfigValue);
                }
                list.Add(dic);
            }
            var p = new PageResult <IDictionary <string, object> >()
            {
                Items     = list,
                PageCount = result.PageCount,
                PageIndex = result.PageIndex,
                PageSize  = result.PageSize,
                TotalRows = result.TotalRows
            };

            return(p);
        }
Пример #6
0
        public override MaterialDTO GetById(int?id)
        {
            var materialDto     = base.GetById(id);
            var typeDTO         = MaterialTypeService.GetById(materialDto.TypeId);
            var materialConfigs = ConfigRepository.Find(x => x.MaterialId == materialDto.Id).OrderBy(x => x.Sort).ToList();
            var configs         = typeDTO.Configs.Select(x => new MaterialConfigDTO()
            {
                ConfigKey       = x.ConfigKey,
                ConfigKeyDesc   = x.ConfigKeyDesc,
                ConfigValueType = x.ConfigValueType,
                ConfigValue     = materialConfigs.FirstOrDefault(y => y.ConfigKey == x.ConfigKey) == null ? x.ConfigDefaultValue :
                                  materialConfigs.FirstOrDefault(y => y.ConfigKey == x.ConfigKey).ConfigValue,
                MaterialId = materialDto.Id,
                Remark     = x.Remark,
                Sort       = x.Sort
            }).OrderBy(x => x.Sort).ToList();

            materialDto.Configs = configs;
            return(materialDto);
        }