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(); }
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(); }
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)); } }
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); } }
public async Task <IEnumerable <ProductTypeDTO> > LoadDataAsync() { var result = await _productTypeRepository.GetAllAsync(); return(_mapper.Map <IEnumerable <ProductTypeDTO> >(result)); }
public async Task <ActionResult <IReadOnlyList <ProductType> > > GetProductTypes() { var productTypes = await _productTypeRepository.GetAllAsync(null); return(Ok(productTypes)); }