public SellProductDialogViewModel(MainViewModel mainViewModel, List<int> selectedProductIDs, ProductsViewModel productsViewModel) { _mainViewModel = mainViewModel; _selectedProductIDs = selectedProductIDs; _productsViewModel = productsViewModel; SellProductCommand = new DelegateCommand(SellProduct, Validate); }
public ProductsView() { InitializeComponent(); IServiceAgent sa = new ServiceAgent(); _vm = new ProductsViewModel(sa); this.DataContext = _vm; _vm.LoadProducts(); }
public ProductsController(ApplicationDbContext _context, HostingEnvironment hostingEnv) { _hostingEnv = hostingEnv; _db = _context; ProductsVM = new ProductsViewModel() { ProductType = _db.ProductType.ToList(), SpecialTags = _db.SpecialTags.ToList(), Products = new Products() }; }
public ProductsController(ApplicationDbContext _db, IHostingEnvironment _hosting) { db = _db; hosting = _hosting; ProductsVM = new ProductsViewModel() { ProductTypes = db.ProductTypes.ToList(), SpecialTags = db.SpecialTags.ToList(), Products = new Products() }; }
public ProductsController(ApplicationDbContext db, HostingEnvironment hostingEnvironment) { _db = db; _hostingEnvironment = hostingEnvironment; ProductVM = new ProductsViewModel { ProductTypes = _db.ProductTypes.ToList(), SpecialTags = _db.SpecialTags.ToList(), Products = new Models.Products() }; }
private void QtyOnHandHistory_Click(object sender, RoutedEventArgs e) { ProductsViewModel pvm = (ProductsViewModel)this.DataContext; if (pvm.GotSomethingSelected()) { StoreProductsView spv = new StoreProductsView(pvm.SelectedProduct.TheEntity); spv.WindowStartupLocation = WindowStartupLocation.CenterScreen; spv.Show(); } }
public ProductsController(ApplicationDbContext db, HostingEnvironment hostingEnvironment) //dependency injection { _db = db; _hostingEnvironment = hostingEnvironment; ProductsVM = new ProductsViewModel() { ProductTypes = _db.ProductTypes.ToList(), //products are retrieved from db SpecialTags = _db.SpecialTags.ToList(), Products = new Models.Products() }; }
public ActionResult Category(int?id) { ProductsViewModel blerg = new ProductsViewModel(); blerg.db = db; blerg.products = (from item in db.Products where item.CategoriesID == id.Value select item); blerg.categories = db.Categories.ToList(); blerg.SelectedID = id.Value; return(View("Index", blerg)); }
public ProductsController(ApplicationDbContext context, HostingEnvironment hostingEnvironment) { _context = context; _hostingEnvironment = hostingEnvironment; ProductsVM = new ProductsViewModel { ProductTypes = _context.ProductTypes.ToList(), SpecialTags = _context.SpecialTags.ToList(), Products = new Models.Products() }; }
public async Task <IActionResult> Index() { var products = await _productsRepository.GetAllAsync(); var viewModel = new ProductsViewModel { Products = products }; return(View(viewModel)); }
public ProductsPage() { //productGet InitializeComponent(); //picker.SelectedIndex = 0; var type = (MenuType)picker.SelectedIndex; _productsViewModel = new ProductsViewModel(type); BindingContext = _productsViewModel; //BindingContext = this; }
public ActionResult GetProducts(ProductsViewModel model) { model.Products = businessLayer.Products.Where(p => p.CategoryId == model.Filter.CategoryId && p.IsDeleted == false); if (!ModelState.IsValid) { return(View(model)); } model.Products = ApplyFilters(model.Products, model.Filter); return(View(model)); }
public IActionResult Index() { var products = this.productService.GetAllProducts(); var displayProducts = new ProductsViewModel { Count = products.Count, Products = this.ExtractDisplayProducts(products) }; return(View(displayProducts)); }
public ActionResult Index() { List <Category> categories = db.Categories.ToList(); ProductsViewModel pvm = new ProductsViewModel { Categories = categories }; return(View(pvm)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Description,NetPrice,GrossPrice")] ProductsViewModel product) { if (ModelState.IsValid) { _context.Update(ProductMapper.MapViewToProduct(product)); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(product)); }
public ProductController(ApplicationDbContext context, HostingEnvironment hostingEnv) { _hostingEnv = hostingEnv; // assigning local obj to the injected obj _context = context; // injected object ProductVm = new ProductsViewModel() // new instance of an object { ProductTypes = _context.ProductTypes.ToList(), SpecialTags = _context.SpecialTags.ToList(), Products = new Models.Products() // new instance of Products model }; }
public ActionResult Products(int categoryId) { NorthwindManager mgr = new NorthwindManager(Properties.Settings.Default.ConStr); IEnumerable <Product> products = mgr.GetProducts(categoryId); ProductsViewModel vm = new ProductsViewModel(); vm.Products = products; vm.CategoryName = mgr.GetCategoryName(categoryId); return(View(vm)); }
public ActionResult Create(ProductsViewModel instance) { if (!ModelState.IsValid) { ViewBag.ResultMessage = "輸入資料錯誤"; return(View(instance)); } _service.productService.Create(instance); TempData["ResultMessage"] = String.Format("[{0}]成功建立", instance.ProductName); return(RedirectToAction("Index")); }
/// <summary> /// Get the products in paged format /// </summary> /// <param name="page"></param> /// <returns></returns> public IActionResult Products([FromQuery] int itemsPerPage = 10, [FromQuery] int page = 1) { ProductsViewModel result = new ProductsViewModel() { Pagination = this.RetailInventoryService.ProductsPages("Products", itemsPerPage), Products = this.RetailInventoryService.GetProductsPaged(itemsPerPage, page) }; result.Pagination.CurrentPage = page; return(View(result)); }
public ActionResult ProductDetails(int id, int custId) { ProductsViewModel productsView = new ProductsViewModel(); productsView.products = new List <Product>(); productsView.Customer = context.Customers.Include(c => c.ApplicationUser).Where(c => c.Id == custId).SingleOrDefault(); Product product = context.Products.Include(p => p.Image).Where(p => p.Id == id).SingleOrDefault(); productsView.products.Add(product); return(View(productsView)); }
public IActionResult Index(int userId, int categoryId) { var products = _db.Products.Where(_ => _.CategoryId == categoryId).ToList(); var vm = new ProductsViewModel() { Products = products, CurrentUserId = userId }; return(View(vm)); }
public ActionResult Index() { var vm = new ProductsViewModel { Products = _db.Products.ToList(), ShoppingCartList = _db.Users.Where(m => m.UserName == User.Identity.Name).Include(m => m.ShoppingCart.ShoppingCartList).FirstOrDefault().ShoppingCart.ShoppingCartList, User = _db.Users.Where(m => m.UserName == User.Identity.Name).FirstOrDefault() }; return(View(vm)); }
public IActionResult Index(int userId, int categoryId) { var products = _products.GetAllByCategoryId(categoryId); var vm = new ProductsViewModel() { Products = products, CurrentUserId = userId }; return(View(vm)); }
protected async override void OnAppearing() { base.OnAppearing(); await unitOfWork.ProductsRepo.PullAsync(null); var res = await unitOfWork.ProductsRepo.GetAsync(); BindingContext = new ProductsViewModel() { ProductList = new System.Collections.ObjectModel.ObservableCollection <Models.Products>(res) }; }
public async Task <IActionResult> Index(Guid Id) { ProductsViewModel productsViewModel = new ProductsViewModel(); // load products and categories from database productsViewModel.Id = Id; productsViewModel.Products = await shopRepository.GetProductsAsync(); productsViewModel.Categories = await shopRepository.GetCategoriesAsync(); return(View(productsViewModel)); }
/// <summary> /// Consulta los productos por id /// </summary> /// <param name="model"></param> /// <returns></returns> public async Task <ProductsModel> GetProductsById(ProductsViewModel model) { using (ApplicactionDbContext Db = new ApplicactionDbContext()) { var products = from u in Db.ProductsModel where u.idProduct == model.ProductoId select u; return(await products.FirstOrDefaultAsync()); } }
//constructor for dependency injection. Grabs the data from the "cloud" and then brings it here and then we will save it to a local variable _db and then use it in our application public ProductsController(ApplicationDbContext db, HostingEnvironment hostingEnvironment) { _db = db; _hostingEnvironment = hostingEnvironment; // initialize our ProductViewModel ProductsVM = new ProductsViewModel() { ProductTypes = _db.ProductTypes.ToList(), SpecialTag = _db.SpecialTag.ToList(), Products = new Models.Products() }; }
public ActionResult SaveToDatabase(ProductsViewModel model, int deleteFlag) { if (ModelState.IsValid) { var product = db.Products.FirstOrDefault(x => x.Id == model.Id); if (deleteFlag == 1) { db.Products.Remove(product); db.SaveChanges(); return(RedirectToAction("Index")); } else { if (model.Id == 0) { var newproduct = new Product { Name = model.Name.Trim(), Price = model.Price }; try { db.Products.Add(newproduct); db.SaveChanges(); } catch (Exception ex) { return(Json(new { success = false })); } return(RedirectToAction("Index")); } else { try { product.Name = model.Name; product.Price = model.Price; db.SaveChanges(); } catch (Exception e) { return(Json(new { success = false })); } return(RedirectToAction("Index")); } } } else { return(Json(new { success = false })); } }
public void Get_Products_By_Starting_String() { // Arrange var prodString = "M"; ProductsController productsController = new ProductsController(new BuildModelsService()); // Act ProductsViewModel productViewModel = productsController.GetMultipleProducts(prodString); // Assert productViewModel.Products.Count.Should().BeGreaterThan(0); }
public ProductsController(ApplicationDbContext db, IHostingEnvironment hostingEnvironment) { this.db = db; this.hostingEnvironment = hostingEnvironment; productsVM = new ProductsViewModel { ProductTypes = this.db.ProductTypes.ToList(), SpecialTags = this.db.SpecialTags.ToList(), Product = new Product() }; }
public void InitializeDataTest() { // Arrange var mockDataService = new MockDataService(); var mockNavigationService = new MockNavigationService(); // Act var vm = new ProductsViewModel(mockDataService, mockNavigationService); // Assert Assert.True(vm.Products.Count == 3); }
public ProductsController(ApplicationDbContext db, HostingEnvironment hostingEnvironment) { _db = db; _hostingEnvironment = hostingEnvironment; dirSep = Path.DirectorySeparatorChar.ToString(); ProductsVM = new ProductsViewModel() { ProductTypes = _db.ProductTypes.OrderBy(p => p.Name).ToList(), SpecialTags = _db.SpecialTags.OrderBy(p => p.Name).ToList(), Products = new Products() }; }
public ActionResult Products_Destroy([DataSourceRequest]DataSourceRequest request, ProductsViewModel product) { if (ModelState.IsValid) { var entity = new Product { Id = product.Id, Name = product.Name, Description = product.Description, Price = product.Price, Quantity = product.Quantity, SoldQuantity = product.SoldQuantity, Material = product.Material, Color = product.Color }; this.products.Delete(entity.Id); } return Json(new[] { product }.ToDataSourceResult(request, ModelState)); }
public ActionResult Products_Create([DataSourceRequest]DataSourceRequest request, ProductsViewModel product) { if (ModelState.IsValid) { var entity = new Product { Name=product.Name, Description=product.Description, Color=product.Color, CategoryId=product.CategoryId, Material=product.Material, Price=product.Price, Quantity=product.Quantity, SoldQuantity=product.Quantity }; this.products.AddProduct(entity); product.Id = entity.Id; } return Json(new[] { product }.ToDataSourceResult(request, ModelState)); }
public EditProductDialogViewModel(Context context, List<int> selectedProductIDs, ProductsViewModel productsViewModel) { _context = context; _productsViewModel = productsViewModel; _selectedProductIDs = selectedProductIDs; var firstSelectedProduct = _context.Products.FirstOrDefault(x => x.ID == selectedProductIDs.FirstOrDefault()); EditProductCommand = new DelegateCommand(EditProduct, Validate); Categories = _context.Categories.Include(x => x.Models).ToList(); SelectedCategory = Categories.FirstOrDefault(x => x.ID == firstSelectedProduct.Model.CategoryID); if (SelectedCategory != null) Models = SelectedCategory.Models.Select(x => x.Name).ToList(); ModelName = firstSelectedProduct.Model.Name; SerialNumber = firstSelectedProduct.SerialNumber; Notes = firstSelectedProduct.Notes; SellingPrice = firstSelectedProduct.SellingPrice; DateSellTo = firstSelectedProduct.DateSellTo; }
public ProductsPage() : base() { InitializeComponent(); this.ProductsButton.IsSelected = true; this.StoresButton.IsSelected = false; this.ViewModel = MvxToolbox.LoadViewModel<ProductsViewModel>(); this.ViewModel.ShowFiltersAction = async () => { await this.Navigation.PushModalAsync(new NavigationPage(new FilterProductsPage(this.ViewModel.SearchQuery))); }; this.ViewModel.ChangeListModeAction = (mode) => { updateListLayout(mode); }; this.SearchBar.Placeholder = AppResources.PlaceholderSearchProducts; ListView.ItemSelected += itemSelected; updateListLayout(this.ViewModel.ListMode); }
public void AddProductSelection(ProductsViewModel prod) { // Search for the product already being in the list ProductsViewModel existing = selectedProducts.Find((x) => x.product == prod.product); prod.amount++; // Not existing yet, add it! if (existing == default(ProductsViewModel)) { selectedProducts.Add(prod); } // Inform Binding objects about changes RaisePropertyChanged("SelectedProductsString"); }
public ProductsView() { InitializeComponent(); prodViewModel = new ProductsViewModel(this, productDataService); this.DataContext = prodViewModel; }
public void ShowDialog(ProductsViewModel prodVM) { this.DataContext = prodVM; this.Show(); }
private void OpenProductMessage(object parameter) { BusinessContext.Instance.BeginOperation(); var view = new ProductsViewModel(); view.View.ControlMode = ControlMode.ReadOnly; Terminal.Instance.Client.ShowWindow(view.View); }
private void OpenProductView(object parameter) { BusinessContext.Instance.BeginOperation(); var view = new ProductsViewModel(); if (!Terminal.Instance.Session.Rules.IsValid(Rules.IsTerminalZero)) view.View.ControlMode = ControlMode.ReadOnly; Terminal.Instance.Client.ShowView(view.View); }
public ShowAllTransactionsDialogViewModel(Context context, List<int> ids, ProductsViewModel productsViewModel) { var transactions = new ObservableCollection<TransactionViewModel>(GetTransactions(ids, context)); TransactionsView = CollectionViewSource.GetDefaultView(transactions); }