コード例 #1
0
ファイル: Edit.cshtml.cs プロジェクト: rdrrichards/QIQO.Pages
        public async Task OnGetAsync(Guid id)
        {
            Product = await _productRepository.GetByIDAsync(id);

            ProductTypes = _productTypeRepository.GetAllAsync().Result
                           .Select(i => new SelectListItem {
                Value = i.ProductTypeId.ToString(), Text = i.ProductTypeName
            })
                           .ToList();
        }
コード例 #2
0
        public AddModel(IProductRepository productRepository, IProductTypeRepository productTypeRepository)
        {
            _productRepository     = productRepository;
            _productTypeRepository = productTypeRepository;

            ProductTypes = _productTypeRepository.GetAllAsync().Result
                           .Select(i => new SelectListItem {
                Value = i.ProductTypeId.ToString(), Text = i.ProductTypeName
            })
                           .ToList();
        }
コード例 #3
0
        public async Task <ActionResult <IEnumerable <ProductType> > > GetAllTypes()
        {
            try
            {
                var types = await _typeRepository.GetAllAsync();

                if (!types.Any())
                {
                    return(NotFound());
                }

                return(Ok(types));
            }catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
コード例 #4
0
        public override async Task LoadAsync(int productTypeId)
        {
            Id = productTypeId;

            foreach (var wrapper in ProductTypes)
            {
                wrapper.PropertyChanged -= Wrapper_PropertyChanged;
            }

            ProductTypes.Clear();

            var types = await _productTypeRepository.GetAllAsync();

            foreach (var model in types)
            {
                var wrapper = new ProductTypeWrapper(model);
                wrapper.PropertyChanged += Wrapper_PropertyChanged;
                ProductTypes.Add(wrapper);
            }
        }
コード例 #5
0
        public async Task <IEnumerable <ProductTypeDTO> > LoadDataAsync()
        {
            var result = await _productTypeRepository.GetAllAsync();

            return(_mapper.Map <IEnumerable <ProductTypeDTO> >(result));
        }
コード例 #6
0
        public async Task <ActionResult <IReadOnlyList <ProductType> > > GetProductTypes()
        {
            var productTypes = await _productTypeRepository.GetAllAsync(null);

            return(Ok(productTypes));
        }