public async Task <ObservableCollection <Product> > GetOfferProducts(string OfferCode, int pageNo) { var app = App.Current as App; Dictionary <string, object> payload = new Dictionary <string, object>(); payload.Add("merchant_id", app.Merchantid); payload.Add("offer_code", OfferCode); payload.Add("page_size", 10); payload.Add("page_number", pageNo); payload.Add("phone_number", app.UserPhoneNumber); payload.Add("access_key", app.SecurityAccessKey); Analytics.TrackEvent("Offer_Clicked", new Dictionary <string, string> { { "MerchantBranchId", app.Merchantid }, { "UserPhoneNumber", app.UserPhoneNumber }, { "OfferCode", OfferCode } }); ProductListResponse <Product> robject = await this.Post <ProductListResponse <Product> >(this.getAuthUrl("getOfferProducts"), payload, null); if (robject != null) { if (robject.Status.ToUpper() == "SUCCESS") { return(robject.Data); } } return(null); }
public async Task <ObservableCollection <SearchProduct> > SearchItems(int pageno, string searchText) { try { var app = Application.Current as App; Dictionary <string, object> payload = new Dictionary <string, object>(); payload.Add("access_key", app.SecurityAccessKey); payload.Add("phone_number", app.UserPhoneNumber); payload.Add("merchant_id", app.Merchantid); payload.Add("page_size", 10); payload.Add("page_number", pageno); payload.Add("product_name", searchText); ProductListResponse <SearchProduct> robject = await this.Post <ProductListResponse <SearchProduct> >(this.getProductUrl("getProductBySearch"), payload, null); if (robject != null) { if (robject.Status.ToUpper() == "SUCCESS") { return(robject.Data); } } return(null); } catch (Exception e) { try { DependencyService.Get <IToastMessage>().LongTime("Error CSD01:Something went wrong. Plese try again. "); } catch { } return(null); } }
/// <summary> /// Populates the data for view model from json file. /// </summary> /// <typeparam name="T">Type of view model.</typeparam> /// <param name="fileName">Json file to fetch data.</param> /// <returns>Returns the view model object.</returns> /* public async Task<ObservableCollection<Category>> PopulateData() * { * * Dictionary<string, string> payload = new Dictionary<string, string>(); * //hardcodeMerchantID * payload.Add("merchant_id", "180"); * ProductListResponse<Dictionary<string, string>> robject = await this.Get<ProductListResponse<Dictionary<string, string>>>(this.getAuthUrl("categoriesPicURL"), payload, null); * ObservableCollection<Category> categories = new ObservableCollection<Category>(); * var c = 0; * foreach (var item in robject.Data) * { * categories.Add(new Category() * { * Icon = item["PicURL"], * Name = item["CategoryName"] * }); * c++; * } * Log.Debug("[CategoryDataService]", "Retrieved categories " + robject.Data.Count); * return categories; * }*/ public async Task <ObservableCollection <SubCategory> > PopulateData() { try { var app = Application.Current as App; Dictionary <string, object> payload = new Dictionary <string, object>(); payload.Add("merchant_id", app.Merchantid); payload.Add("category_id", "NULL"); payload.Add("phone_number", app.UserPhoneNumber); //payload.Add("access_key", "xxttrree"); payload.Add("access_key", app.SecurityAccessKey); ProductListResponse <Dictionary <string, string> > robject = await this.Post <ProductListResponse <Dictionary <string, string> > >(this.getAuthUrl("SubCategory"), payload, null); ObservableCollection <SubCategory> subCategories = new ObservableCollection <SubCategory>(); var c = 0; foreach (var item in robject.Data) { subCategories.Add(new SubCategory() { SubCategoryId = int.Parse(item["SubCategoryId"]), Name = item["Name"], Icon = item["PicURL"], ImageLinkFlag = item["ImageLinkFlag"], IsDelete = item["IsDelete"] }); c++; } Log.Debug("[CategoryDataService]", "Retrieved categories " + robject.Data.Count); return(subCategories); } catch (Exception e) { return(null); } }
public async Task <ObservableCollection <SearchProduct> > SearchItems(int pageno, string searchText) { try { var app = App.Current as App; Dictionary <string, object> payload = new Dictionary <string, object>(); payload.Add("access_key", app.SecurityAccessKey); payload.Add("phone_number", app.UserPhoneNumber); payload.Add("merchant_id", app.Merchantid); payload.Add("page_size", 10); payload.Add("page_number", pageno); payload.Add("product_name", searchText); ProductListResponse <SearchProduct> robject = await this.Post <ProductListResponse <SearchProduct> >(this.getProductUrl("getProductBySearch"), payload, null); if (robject.Status == "SUCCESS") { return(robject.Data); } else { return(null); } } catch (Exception e) { await Application.Current.MainPage.DisplayAlert("Error", e.Message, "ok"); return(null); } }
//public async Task<ObservableCollection<Product>> GetItems(Category category) public async Task <ObservableCollection <Product> > GetItems(SubCategory category, int pageno) { try { var app = App.Current as App; Dictionary <string, object> payload = new Dictionary <string, object>(); payload.Add("access_key", app.SecurityAccessKey); payload.Add("phone_number", app.UserPhoneNumber); payload.Add("merchant_id", app.Merchantid); payload.Add("page_size", 7); payload.Add("page_number", pageno); payload.Add("lastSyncDate", null); payload.Add("category_name", category.Name); ProductListResponse <Product> robject = await this.Post <ProductListResponse <Product> >(this.getProductUrl("getProductDetails"), payload, null); if (robject != null) { if (robject.Status.ToUpper() == "SUCCESS") { return(robject.Data); } } return(null); } catch (Exception ex) { try { DependencyService.Get <IToastMessage>().LongTime("Error CSD02:Something went wrong. Plese try again. "); } catch { } return(null); } }
public async Task <ObservableCollection <SubCategory> > GetSubCategoriesForAddProductForm(double categoryID) { var app = App.Current as App; Dictionary <string, object> payload = new Dictionary <string, object>(); payload.Add("merchant_id", app.Merchantid); payload.Add("category_id", categoryID); payload.Add("phone_number", app.UserPhoneNumber); payload.Add("access_key", app.SecurityAccessKey); ProductListResponse <Dictionary <string, string> > robject = await this.Post <ProductListResponse <Dictionary <string, string> > >(this.getAuthUrl("SubCategory_digicat"), payload, null); ObservableCollection <SubCategory> subCategories = new ObservableCollection <SubCategory>(); var c = 0; if (robject.Data != null) { foreach (var item in robject.Data) { subCategories.Add(new SubCategory() { SubCategoryId = int.Parse(item["SubCategoryId"]), CategoryId = int.Parse(item["CategoryId"]), Name = item["Name"], IsDelete = item["IsDelete"] }); c++; } Log.Debug("[CategoryDataService]", "Retrieved subcategories " + robject.Data.Count); return(subCategories); } else { return(null); } }
public async Task <ObservableCollection <SubCategory> > FetchCatagoryListForAddProductPage() { try { var app = App.Current as App; Dictionary <string, object> payload = new Dictionary <string, object>(); payload.Add("merchant_id", app.Merchantid); payload.Add("category_id", "NULL"); payload.Add("phone_number", app.UserPhoneNumber); payload.Add("access_key", app.SecurityAccessKey); ProductListResponse <Dictionary <string, string> > robject = await this.Post <ProductListResponse <Dictionary <string, string> > >(this.getAuthUrl("SubCategory_digicat"), payload, null); ObservableCollection <SubCategory> subCategories = new ObservableCollection <SubCategory>(); var c = 0; foreach (var item in robject.Data) { subCategories.Add(new SubCategory() { SubCategoryId = int.Parse(item["SubCategoryId"]), Name = item["Name"], IsDelete = item["IsDelete"] }); c++; } Log.Debug("[CategoryDataService]", "Retrieved categories " + robject.Data.Count); return(subCategories); } catch (Exception e) { DependencyService.Get <IToastMessage>().LongTime("Server Error CSD05:Something went wrong. Plese try again. "); return(null); } }
//public async Task<ObservableCollection<Product>> GetItems(Category category) public async Task <ObservableCollection <Product> > GetItems(SubCategory category, int pageno) { try { var app = App.Current as App; Dictionary <string, object> payload = new Dictionary <string, object>(); payload.Add("access_key", app.SecurityAccessKey); payload.Add("phone_number", app.UserPhoneNumber); payload.Add("merchant_id", app.Merchantid); payload.Add("page_size", 5); payload.Add("page_number", pageno); payload.Add("lastSyncDate", null); payload.Add("category_name", category.Name); ProductListResponse <Product> robject = await this.Post <ProductListResponse <Product> >(this.getProductUrl("getProductDetails"), payload, null); /*ProductListResponse<Dictionary<string, string>> robject = await this.Post<ProductListResponse<Dictionary<string, string>>>(this.getProductUrl("getProductDetails"), payload, null); * ObservableCollection<Product> products = new ObservableCollection<Product>(); * foreach (var item in robject.Data) * { * products.Add(new Product() * { * PreviewImage = item["productPicUrl"], * TotalQuantity = Convert.ToInt32(item["QuantityList"]), * discount = Convert.ToDouble(item["discount"]), * SellingPrice = Convert.ToDouble(item["mrp"]), * CitrineProdId = Convert.ToInt32(item["CitrineProdId"]), * productName = item["productName"], * productDesc = item["productDesc"], * Category = item["Category"], * * }); * } * return products;*/ if (robject.Status == "SUCCESS") { return(robject.Data); } else { return(null); } } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("Error", ex.Message, "ok"); return(null); } }
/* * TO get subcategory under a category */ public async Task <ObservableCollection <SubCategory> > GetSubCategories(SubCategory category) { var app = Application.Current as App; Dictionary <string, object> payload = new Dictionary <string, object>(); payload.Add("merchant_id", app.Merchantid); payload.Add("category_id", category.SubCategoryId); payload.Add("phone_number", app.UserPhoneNumber); payload.Add("access_key", app.SecurityAccessKey); Analytics.TrackEvent("Category_Clicked", new Dictionary <string, string> { { "MerchantBranchId", app.Merchantid }, { "UserPhoneNumber", app.UserPhoneNumber }, { "CategoryName", category.Name }, { "CategoryId", category.CategoryId.ToString() } }); ProductListResponse <Dictionary <string, string> > robject = await this.Post <ProductListResponse <Dictionary <string, string> > >(this.getAuthUrl("SubCategory"), payload, null); ObservableCollection <SubCategory> subCategories = new ObservableCollection <SubCategory>(); var c = 0; if (robject.Data != null) { foreach (var item in robject.Data) { subCategories.Add(new SubCategory() { SubCategoryId = int.Parse(item["SubCategoryId"]), Name = item["Name"], Icon = item["PicURL"], ImageLinkFlag = item["ImageLinkFlag"], IsDelete = item["IsDelete"] }); c++; } Log.Debug("[CategoryDataService]", "Retrieved subcategories " + robject.Data.Count); return(subCategories); } else { return(null); } }
/// <summary> /// Populates the data for view model from json file. /// </summary> /// <typeparam name="T">Type of view model.</typeparam> /// <param name="fileName">Json file to fetch data.</param> /// <returns>Returns the view model object.</returns> /* public async Task<ObservableCollection<Category>> PopulateData() * { * * Dictionary<string, string> payload = new Dictionary<string, string>(); * //hardcodeMerchantID * payload.Add("merchant_id", "180"); * ProductListResponse<Dictionary<string, string>> robject = await this.Get<ProductListResponse<Dictionary<string, string>>>(this.getAuthUrl("categoriesPicURL"), payload, null); * ObservableCollection<Category> categories = new ObservableCollection<Category>(); * var c = 0; * foreach (var item in robject.Data) * { * categories.Add(new Category() * { * Icon = item["PicURL"], * Name = item["CategoryName"] * }); * c++; * } * Log.Debug("[CategoryDataService]", "Retrieved categories " + robject.Data.Count); * return categories; * }*/ public async Task <ObservableCollection <SubCategory> > PopulateData() { try { var app = App.Current as App; Dictionary <string, object> payload = new Dictionary <string, object>(); payload.Add("merchant_id", app.Merchantid); payload.Add("category_id", "NULL"); payload.Add("phone_number", app.UserPhoneNumber); payload.Add("access_key", app.SecurityAccessKey); ProductListResponse <Dictionary <string, string> > robject = await this.Post <ProductListResponse <Dictionary <string, string> > >(this.getAuthUrl("SubCategory"), payload, null); ObservableCollection <SubCategory> subCategories = new ObservableCollection <SubCategory>(); var c = 0; foreach (var item in robject.Data) { subCategories.Add(new SubCategory() { SubCategoryId = int.Parse(item["SubCategoryId"]), Name = item["Name"], Icon = item["PicURL"], ImageLinkFlag = item["ImageLinkFlag"], IsDelete = item["IsDelete"] }); c++; } Log.Debug("[CategoryDataService]", "Retrieved categories " + robject.Data.Count); return(subCategories); } catch (Exception e) { var app = App.Current as App; Log.Debug("[Error]", "Probably an issue with secret key " + e.Message); app.IsLoggedIn = false; app.UserPhoneNumber = null; app.SecurityAccessKey = null; app.MinimumOrderAmount = 0; Application.Current.MainPage = new NavigationPage(new LoginPage()); BaseViewModel.Navigation = Application.Current.MainPage.Navigation; return(null); } }