public AdminCategoryViewModel() { if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(new DependencyObject())) { CategoryList = new ObservableCollection <CategoryData>(CategoriesClient.GetCategoryList()); } }
/// <seealso href="https://developer.foursquare.com/overview/auth#userless" /> public FoursquareUserlessContext(HttpMessageHandler handler, UserlessAccessSettings settings) { if (handler == null) { throw new ArgumentNullException(nameof(handler)); } if (settings == null) { throw new ArgumentNullException(nameof(settings)); } var userlessHandler = HttpClientFactory.CreatePipeline(handler, new DelegatingHandler[] { new QueryAppenderHandler("client_id", settings.ClientId), new QueryAppenderHandler("client_secret", settings.ClientSecret) }); _httpClient = new HttpClient(userlessHandler, false) { BaseAddress = new Uri(Constants.FoursquareApiBaseUrl) }; Categories = new CategoriesClient(_httpClient); Venues = new VenuesClient(_httpClient); Photos = new PhotosClient(_httpClient); }
public void Categories() { Utils.UseApiEnvironment((_, api, token) => { using (var baseClient = api.CreateClient()) { ICategoriesClient client = new CategoriesClient(baseClient); Assert.IsFalse(client.GetAll(token).Result.Any()); Assert.IsNull(client.Get(token, 0).Result); client.Clear(token).Wait(); { Category tag = new Category { Name = "tag", Color = "black" }; int id = client.Create(token, tag).Result.Value; Assert.AreEqual(tag.Name, client.Query(token, id).Result.First().Name); Assert.AreEqual(tag.Color, client.Get(token, id).Result.Color); tag.Color = "white"; Assert.IsTrue(client.Update(token, id, tag).Result.HasValue); Assert.IsTrue(client.Delete(token, id).Result.HasValue); } } }); }
public async Task <ActionResult> Create(CategoryViewModel category) { try { CategoriesClient categoriesClient = new CategoriesClient(); var categoryDto = new CategoryDto { Id = category.Id, NameCategory = category.NameCategory, Stars = category.Stars, Subcategory = category.Subcategory, Delivery = category.Delivery }; await categoriesClient.CreateAsync(categoryDto); await categoriesClient.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 ApiClient(string apiKey, HttpClient http) { Datasets = new DatasetsClient(apiKey, http); Categories = new CategoriesClient(http); Departments = new DepartmentsClient(http); Features = new FeaturesClient(http); Rows = new RowsClient(http); Structure = new StructureClient(http); Versions = new VersionsClient(http); }
public ShopyDriver( ProductsClient productsClient, CategoriesClient categoriesClient, SizesClient sizesClient, BrandsClient brandsClient) { _productsClient = productsClient; _categoriesClient = categoriesClient; _sizesClient = sizesClient; _brandsClient = brandsClient; }
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 void EditCategory(object item) { if (CanEditCategory(null)) { if (SelectedCategory != null) { CategoryData categoryItem = new CategoryData() { ProductCategoryID = SelectedCategory.ProductCategoryID, Name = CategoryName, IsActive = CategoryIsActive }; ProductCategory updatedProductCategory = CategoriesClient.UpdateCategory(categoryItem); CategoryData categoryInList = CategoryList.FirstOrDefault(cat => cat.ProductCategoryID == updatedProductCategory.ProductCategoryID); categoryInList.Name = updatedProductCategory.Name; categoryInList.IsActive = updatedProductCategory.IsActive; } else { try { CategoryData categoryItem = new CategoryData() { ProductCategoryID = 0, Name = CategoryName, IsActive = CategoryIsActive }; ProductCategory updatedProductCategory = CategoriesClient.UpdateCategory(categoryItem); if (updatedProductCategory != null) { CategoryList.Add(new CategoryData() { ProductCategoryID = updatedProductCategory.ProductCategoryID, Name = updatedProductCategory.Name, IsActive = updatedProductCategory.IsActive, ProductCount = updatedProductCategory.ProductCount }); } else { MessageBox.Show("Save failed."); } } catch (Exception ex) { Debug.WriteLine(ex.Message); } } } }
public ActionResult LoadCategories() { CategoriesClient CC = new CategoriesClient(); ViewBag.Cate = CC.findAll(); UpdateList_inline("All course", null); ViewBag.SubCate = CC.getAllSubcate(); return(PartialView()); }
public async Task <ActionResult> DeleteConfirmed(int id) { try { CategoriesClient categoriesClient = new CategoriesClient(); await categoriesClient.DeleteAsync(id); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public ViagogoClient( ProductHeaderValue product, IGogoKitConfiguration configuration, IOAuth2TokenStore tokenStore, IJsonSerializer serializer, IHttpConnection oauthConnection, IHttpConnection apiConnection) { Requires.ArgumentNotNull(product, nameof(product)); Requires.ArgumentNotNull(configuration, nameof(configuration)); Requires.ArgumentNotNull(tokenStore, nameof(tokenStore)); Requires.ArgumentNotNull(serializer, nameof(serializer)); Requires.ArgumentNotNull(oauthConnection, nameof(oauthConnection)); Requires.ArgumentNotNull(apiConnection, nameof(apiConnection)); var halKitConfiguration = new HalKitConfiguration(configuration.ViagogoApiRootEndpoint) { CaptureSynchronizationContext = configuration.CaptureSynchronizationContext }; Configuration = configuration; TokenStore = tokenStore; Hypermedia = new HalClient(halKitConfiguration, apiConnection); var linkFactory = new LinkFactory(configuration); OAuth2 = new OAuth2Client(oauthConnection, configuration); User = new UserClient(Hypermedia); Search = new SearchClient(Hypermedia); Addresses = new AddressesClient(User, Hypermedia, linkFactory); Purchases = new PurchasesClient(User, Hypermedia, linkFactory); Sales = new SalesClient(Hypermedia, linkFactory); Shipments = new ShipmentsClient(Hypermedia, linkFactory); PaymentMethods = new PaymentMethodsClient(User, Hypermedia, linkFactory); Countries = new CountriesClient(Hypermedia, linkFactory); Currencies = new CurrenciesClient(Hypermedia, linkFactory); Categories = new CategoriesClient(Hypermedia, linkFactory); Events = new EventsClient(Hypermedia); Listings = new ListingsClient(Hypermedia); Venues = new VenuesClient(Hypermedia); SellerListings = new SellerListingsClient(Hypermedia, linkFactory); Webhooks = new WebhooksClient(Hypermedia, linkFactory); BatchClient = new BatchClient(apiConnection, new ApiResponseFactory(serializer, halKitConfiguration), serializer, new LinkResolver()); }
public ShoppingCartFormViewModel() { if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(new DependencyObject())) { RefreshProducts(null); ShoppingCart = ShoppingCartClient.GetShoppingCartList(); List <CategoryData> list = new List <CategoryData>(); list.Add(new CategoryData() { ProductCategoryID = 0, Name = "All Categories" }); list.AddRange(CategoriesClient.GetCategoryList().Where(c => c.IsActive == true).OrderBy(c => c.Name).ToList()); CategoryList = list; SelectedCategory = CategoryList.FirstOrDefault(c => c.ProductCategoryID == 0); } }
public void DeleteCategory(object item) { if (CanDeleteCategory(null)) { bool result = false; result = CategoriesClient.DeleteCategory(SelectedCategory.ProductCategoryID); if (result) { CategoryData categoryJustDeleted = CategoryList.First(c => c.ProductCategoryID == SelectedCategory.ProductCategoryID); CategoryList.Remove(categoryJustDeleted); MessageBox.Show("Delete successful"); } else { MessageBox.Show("Delete failed"); } } }
public async Task <ActionResult> Index() { CategoriesClient categoriesClient = new CategoriesClient(); var categories = await categoriesClient.GetAllAsync(); var result = categories .Select(c => new CategoryViewModel { Id = c.Id, NameCategory = c.NameCategory, Stars = c.Stars, Subcategory = c.Subcategory, Delivery = c.Delivery }).ToArray(); await categoriesClient.CloseAsync(); return(View(result)); }
private async static Task RunAsync() { var categoryClient = new CategoriesClient(basePath); var productsClient = new ProductsClient(basePath); var products = await productsClient.GetAllAsync(); var categories = await categoryClient.GetAllAsync(); Console.WriteLine("-----Products-------"); foreach (var product in products) { Console.WriteLine(product.ToString()); } Console.WriteLine("-----Categories-------"); foreach (var category in categories) { Console.WriteLine(category.ToString()); } }
public async Task <ActionResult> Details(int id) { CategoriesClient categoriesClient = new CategoriesClient(); var category = await categoriesClient.GetByIdAsync(id); if (category == null) { return(NotFound()); } var result = new CategoryViewModel { Id = category.Id, NameCategory = category.NameCategory, Stars = category.Stars, Subcategory = category.Subcategory, Delivery = category.Delivery }; await categoriesClient.CloseAsync(); return(View(result)); }
public CustomCategoriesClient(HttpClient http) { innerClient = new CategoriesClient(http); base.Configurate(); }