void OnRemoveButtonClicked(object sender, EventArgs e) { var selectedItem = (CartItem)((Button)sender).CommandParameter; var selfBindingContext = (CartPageViewModel)BindingContext; selfBindingContext.CartItems.Remove(selectedItem); //CartItems.Add(new CartItem { Product = testVar.Product, Qty = testVar.Qty }); Task.Run(async() => { await ProductCatalogViewModel.SaveCartDataToFile(selfBindingContext.CartItems, ProductCatalogViewModel.CartListFile); }).Wait(); }
//public List<CartItem> CartItems { get; set; } //private string CartListFile = "TempCartList.txt"; public MainPage() { InitializeComponent(); //CartItems = new List<CartItem>(); //test = new ProductCatalogViewModel(); //test.ProductList = LsProduct; //BindingContext = test; //BindingContext = this; BindingContext = new ProductCatalogViewModel(); }
public IActionResult ProductCatalogByBrand(int id, int?pageSize, int?first_value, int?end_value, int?sizeid, string sortBy, int page = 1) { var productCatalog = new ProductCatalogViewModel(); ViewData["BodyClass"] = "shop_grid_page"; pageSize ??= 3; productCatalog.PageSize = pageSize; productCatalog.SortType = sortBy; productCatalog.Sizes = _billService.GetSizes(); productCatalog.Data = _productService.GetAllPaging(null, id, string.Empty, page, pageSize.Value, sortBy); productCatalog.Brand = _brandService.GetById(id); return(View(productCatalog)); }
public void ProductTappedCommand_Not_Null_Test() { var mockConnectionService = new Mock <IConnectionService>(); var mockNavigationService = new Mock <INavigationService>(); var mockDialogService = new Mock <IDialogService>(); var mockCatalogDataService = new MockCatalogDataService(); var productCatalogViewModel = new ProductCatalogViewModel( mockConnectionService.Object, mockNavigationService.Object, mockDialogService.Object, mockCatalogDataService); Assert.NotNull(productCatalogViewModel.ProductTappedCommand); }
public async Task Products_All_Get_Loaded_After_InitializeAsync_Test() { var mockConnectionService = new Mock <IConnectionService>(); var mockNavigationService = new Mock <INavigationService>(); var mockDialogService = new Mock <IDialogService>(); var mockCatalogDataService = new MockCatalogDataService(); var productCatalogViewModel = new ProductCatalogViewModel( mockConnectionService.Object, mockNavigationService.Object, mockDialogService.Object, mockCatalogDataService); await productCatalogViewModel.InitializeAsync(null); Assert.Equal(10, productCatalogViewModel.Products.Count); }
public async Task Products_Not_Null_After_InitializeAsync_Test() { var mockConnectionService = new Mock <IConnectionService>(); var mockNavigationService = new Mock <INavigationService>(); var mockDialogService = new Mock <IDialogService>(); var mockCatalogDataService = new MockCatalogDataService(); var productCatalogViewModel = new ProductCatalogViewModel( mockConnectionService.Object, mockNavigationService.Object, mockDialogService.Object, mockCatalogDataService); await productCatalogViewModel.InitializeAsync(null); Assert.NotNull(productCatalogViewModel.Products); }
public async Task <IActionResult> Catalog(ProductCatalogViewModel model) { ViewBag.ParentId = new SelectList(_db.ProductCatalogs.CatalogDll(), "value", "label"); if (!ModelState.IsValid) { return(View(model)); } var response = await _db.ProductCatalogs.AddCustomAsync(model).ConfigureAwait(false); if (response.IsSuccess) { return(RedirectToAction("CatalogList")); } ModelState.AddModelError("CatalogName", response.Message); return(View(model)); }
void OnAddToCartButtonClicked(object sender, EventArgs e) { var selectedItem = (ProductCatalog)((Button)sender).CommandParameter; var selfBindingContext = (ProductCatalogViewModel)BindingContext; selfBindingContext.CartItems.Add( new CartItem { Product = selectedItem.Product, Qty = selectedItem.Qty, PriceWithCurrency = selectedItem.PriceWithCurrency }); //CartItems.Add(new CartItem { Product = selectedItem.Product, Qty = selectedItem.Qty }); Task.Run(async() => { await ProductCatalogViewModel.SaveCartDataToFile(selfBindingContext.CartItems, ProductCatalogViewModel.CartListFile); }).Wait(); //var menuItem = sender as Button; //Button button = (Button)sender; //var imt = (Grid)button.Parent; //var child = imt.Children; //var c = (Label)imt.Children[0]; //var name = c.Text; //var c1 = (Stepper)imt.Children[6]; //var qty = c1.Value; }
public ActionResult ProductCatalog3() { if (Session["Customer"] == null) { return(Redirect("/CustomerLogin/CustomerLoginIndex")); } using (var db = new ModelContext()) { var pList = db.Products.ToList(); var pcList = new List <ProductCatalogViewModel>(); for (int i = 0; i < pList.Count(); i++) { var pc = new ProductCatalogViewModel(pList[i]); int pNo = pList[i].ItemNo; var odq = (from x in db.OrderDetails where x.ItemNo == pNo && x.Status == 1 select(int?) x.Quantity).Sum() ?? 0; pc.Stock -= odq; pcList.Add(pc); } return(View(pcList)); } }
public ProductCatalogView() { pcvm = new ProductCatalogViewModel(); this.InitializeComponent(); this.DataContext = pcvm; }