コード例 #1
0
        public SellProductDialogViewModel(MainViewModel mainViewModel, List<int> selectedProductIDs, ProductsViewModel productsViewModel)
        {
            _mainViewModel = mainViewModel;
            _selectedProductIDs = selectedProductIDs;
            _productsViewModel = productsViewModel;

            SellProductCommand = new DelegateCommand(SellProduct, Validate);
        }
コード例 #2
0
        public ProductsView()
        {
            InitializeComponent();
            IServiceAgent sa = new ServiceAgent();
            _vm = new ProductsViewModel(sa);
            this.DataContext = _vm;

            _vm.LoadProducts();
        }
コード例 #3
0
 public ProductsController(ApplicationDbContext _context, HostingEnvironment hostingEnv)
 {
     _hostingEnv = hostingEnv;
     _db         = _context;
     ProductsVM  = new ProductsViewModel()
     {
         ProductType = _db.ProductType.ToList(),
         SpecialTags = _db.SpecialTags.ToList(),
         Products    = new Products()
     };
 }
コード例 #4
0
 public ProductsController(ApplicationDbContext _db, IHostingEnvironment _hosting)
 {
     db         = _db;
     hosting    = _hosting;
     ProductsVM = new ProductsViewModel()
     {
         ProductTypes = db.ProductTypes.ToList(),
         SpecialTags  = db.SpecialTags.ToList(),
         Products     = new Products()
     };
 }
コード例 #5
0
 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()
     };
 }
コード例 #6
0
        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();
            }
        }
コード例 #7
0
 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()
     };
 }
コード例 #8
0
        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));
        }
コード例 #9
0
 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()
     };
 }
コード例 #10
0
        public async Task <IActionResult> Index()
        {
            var products = await _productsRepository.GetAllAsync();

            var viewModel = new ProductsViewModel
            {
                Products = products
            };

            return(View(viewModel));
        }
コード例 #11
0
ファイル: ProductsPage.xaml.cs プロジェクト: hhels/Diplom
        public ProductsPage()
        {
            //productGet
            InitializeComponent();
            //picker.SelectedIndex = 0;
            var type = (MenuType)picker.SelectedIndex;

            _productsViewModel = new ProductsViewModel(type);
            BindingContext     = _productsViewModel;
            //BindingContext = this;
        }
コード例 #12
0
        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));
        }
コード例 #14
0
        public ActionResult Index()
        {
            List <Category> categories = db.Categories.ToList();

            ProductsViewModel pvm = new ProductsViewModel
            {
                Categories = categories
            };

            return(View(pvm));
        }
コード例 #15
0
        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));
        }
コード例 #16
0
 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
     };
 }
コード例 #17
0
        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));
        }
コード例 #18
0
 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"));
 }
コード例 #19
0
        /// <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));
        }
コード例 #20
0
        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));
        }
コード例 #21
0
        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));
        }
コード例 #22
0
ファイル: HomeController.cs プロジェクト: 772900/Grocery2Go
        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));
        }
コード例 #23
0
        public IActionResult Index(int userId, int categoryId)
        {
            var products = _products.GetAllByCategoryId(categoryId);

            var vm = new ProductsViewModel()
            {
                Products      = products,
                CurrentUserId = userId
            };

            return(View(vm));
        }
コード例 #24
0
        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)
            };
        }
コード例 #25
0
        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));
        }
コード例 #26
0
        /// <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());
            }
        }
コード例 #27
0
 //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()
     };
 }
コード例 #28
0
        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 }));
            }
        }
コード例 #29
0
        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);
        }
コード例 #30
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()
            };
        }
コード例 #31
0
        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);
        }
コード例 #32
0
 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()
     };
 }
コード例 #33
0
        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));
        }
コード例 #34
0
        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));
        }
コード例 #35
0
        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;
        }
コード例 #36
0
ファイル: ProductsPage.xaml.cs プロジェクト: fadafido/tojeero
		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);

		}
コード例 #37
0
        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");
        }
コード例 #38
0
 public ProductsView()
 {
     InitializeComponent();
     prodViewModel = new ProductsViewModel(this, productDataService);
     this.DataContext = prodViewModel;
 }
コード例 #39
0
 public void ShowDialog(ProductsViewModel prodVM)
 {
     this.DataContext = prodVM;
     this.Show();
 }
コード例 #40
0
 private void OpenProductMessage(object parameter)
 {
     BusinessContext.Instance.BeginOperation();
     var view = new ProductsViewModel();
     view.View.ControlMode = ControlMode.ReadOnly;
     Terminal.Instance.Client.ShowWindow(view.View);
 }
コード例 #41
0
 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);
 }
コード例 #42
0
 public ShowAllTransactionsDialogViewModel(Context context, List<int> ids, ProductsViewModel productsViewModel)
 {
     var transactions = new ObservableCollection<TransactionViewModel>(GetTransactions(ids, context));
     TransactionsView = CollectionViewSource.GetDefaultView(transactions);
 }