public async Task <ActionResult> Edit(int id, BrandViewModel brand) { /*if (brand.Id != id) // ako neshto gyrmi iztrij ili promeni if * { * return NotFound(); * } */ brand.Id = id; try { BrandsClient brandsClient = new BrandsClient(); var brandDto = new BrandDto { Id = brand.Id, BrandName = brand.BrandName, ManufacturerCountry = brand.ManufacturerCountry, ProductClass = brand.ProductClass, Rating = brand.Rating }; await brandsClient.UpdateAsync(brandDto); await brandsClient.CloseAsync(); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public async Task <ActionResult> Create(BrandViewModel brand) { try { BrandsClient brandsClient = new BrandsClient(); var brandDto = new BrandDto { Id = brand.Id, BrandName = brand.BrandName, ManufacturerCountry = brand.ManufacturerCountry, ProductClass = brand.ProductClass, Rating = brand.Rating }; await brandsClient.CreateAsync(brandDto); await brandsClient.CloseAsync(); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public LocallyDotComClient(string apiKey) { var connection = new ApiConnection(apiKey); Brands = new BrandsClient(connection); Catalog = new CatalogClient(connection); Categories = new CategoriesClient(connection); }
public ShopyDriver( ProductsClient productsClient, CategoriesClient categoriesClient, SizesClient sizesClient, BrandsClient brandsClient) { _productsClient = productsClient; _categoriesClient = categoriesClient; _sizesClient = sizesClient; _brandsClient = brandsClient; }
async Task <IEnumerable <ProductBrandModel> > SearchBrandsByText(string query) { var brandsFromApi = await BrandsClient.SearchBrandsByText(query); brands = brandsFromApi.Select(b => new ProductBrandModel { BrandId = b.Id, Name = b.Name }).ToArray(); return(brands); }
public static IShopyDriver GetDriver() { // TODO: DI this var httpClient = new ShopyHttpClient(SettingsHelper.ApiBaseAddress); var products = new ProductsClient(httpClient); var categories = new CategoriesClient(httpClient); var brands = new BrandsClient(httpClient); var sizes = new SizesClient(httpClient); return(new ShopyDriver(products, categories, sizes, brands)); }
public async Task <ActionResult> DeleteConfirmed(int id) { try { BrandsClient brandsClient = new BrandsClient(); await brandsClient.DeleteAsync(id); // TODO: Add delete logic here return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public async Task <ActionResult> Index() { BrandsClient brandsClient = new BrandsClient(); var brands = await brandsClient.GetAllAsync(); var result = brands .Select(b => new BrandViewModel { Id = b.Id, BrandName = b.BrandName, ManufacturerCountry = b.ManufacturerCountry, ProductClass = b.ProductClass, Rating = b.Rating }).ToArray(); await brandsClient.CloseAsync(); return(View(result)); }
public async Task <ActionResult> Details(int id) { BrandsClient brandsClient = new BrandsClient(); var brand = await brandsClient.GetByIdAsync(id); if (brand == null) { return(NotFound()); } var result = new BrandViewModel { Id = brand.Id, BrandName = brand.BrandName, ManufacturerCountry = brand.ManufacturerCountry, ProductClass = brand.ProductClass, Rating = brand.Rating }; await brandsClient.CloseAsync(); return(View(result)); }
public BrandsService(BrandsClient <BrandDTO> client, IUnitOfWorkProduccion repository, IMapper mapper) : base(client, repository, mapper) { }