예제 #1
0
        protected async Task HandleValidSubmit()
        {
            Product.CategoryId = int.Parse(CategoryId);

            if (Product.ProductId == 0)
            {
                var product = await ProductDataService.Add(Product);

                if (product != null)
                {
                    StatusClass = "alert-success";
                    Message     = "New category added successfully.";
                }
                else
                {
                    StatusClass = "alert-danger";
                    Message     = "Something went wrong adding the new category. Please try again.";
                }
            }
            else
            {
                await ProductDataService.Update(Product);

                StatusClass = "alert-success";
                Message     = "Category updated successfully.";
            }
        }
예제 #2
0
        protected async Task Delete(int productId)
        {
            await ProductDataService.Delete(productId);

            StatusClass = "alert-success";
            Message     = "Deleted successfully";
        }
예제 #3
0
        static void Main(string[] args)
        {
            try
            {
                var cs      = ConfigurationManager.ConnectionStrings["TestDB"].ConnectionString;
                var service = new ProductDataService(cs);

                for (int i = 0; i < 10; i++)
                {
                    var product = new ProductDTO();
                    product.Id   = i;
                    product.Name = String.Format("Product_{0}", i);

                    service.Add(product);
                    Console.WriteLine("Product {0} added", i);
                }

                Console.WriteLine("Get all products");

                var products = service.GetAll();

                foreach (var product in products)
                {
                    Console.WriteLine("Product '{0}' is retrieved", product.Name);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
예제 #4
0
 public ItemAddFormActivity()
 {
     mInventoryDataService = new InventoryDataService();
     mProductDataService   = new ProductDataService();
     mCategoryDataService  = new CategoryDataService();
     mStorageDataService   = new StorageDataService();
 }
 public ProductViewModel(ProductDataService productDataService, IEventAggregator eventAggregator)
 {
     this.productDataService = productDataService;
     SearchProductCommand    = new SearchProductCommand(this);
     DeleteProductCommand    = new DeleteProductCommand(this);
     EditProductCommand      = new EditProductCommand(this);
 }
예제 #6
0
        public DefectionProductsVM(DefectionVM defection, AccessType access)
            : base(access)
        {
            UnitOfWork = new SoheilEdmContext();
            CurrentDefection = defection;
            DefectionDataService = new DefectionDataService(UnitOfWork);
            DefectionDataService.ProductAdded += OnProductAdded;
            DefectionDataService.ProductRemoved += OnProductRemoved;
            ProductDataService = new ProductDataService(UnitOfWork);
            ProductGroupDataService = new ProductGroupDataService(UnitOfWork);
            ProductDefectionDataService = new ProductDefectionDataService(UnitOfWork);

            var selectedVms = new ObservableCollection<ProductDefectionVM>();
            foreach (var productDefection in DefectionDataService.GetProducts(defection.Id))
            {
                selectedVms.Add(new ProductDefectionVM(productDefection, Access, ProductDefectionDataService, RelationDirection.Reverse));
            }
            SelectedItems = new ListCollectionView(selectedVms);

            var allVms = new ObservableCollection<ProductVM>();
            foreach (var product in ProductDataService.GetActives(SoheilEntityType.Defections, CurrentDefection.Id))
            {
                allVms.Add(new ProductVM(product, Access, ProductDataService, ProductGroupDataService));
            }
            AllItems = new ListCollectionView(allVms);

            IncludeCommand = new Command(Include, CanInclude);
            ExcludeCommand = new Command(Exclude, CanExclude);
        }
예제 #7
0
 public TestBLL()
 {
     shopRepo     = new ShopRepository(conn);
     businessRepo = new BusinessRepository(conn);
     imgRepo      = new ImagesRepository(conn);
     prodRepo     = new ProductRepository(conn);
     unitRepo     = new UnitRepository(conn);
     priceRepo    = new PriceRepository(conn);
     costRepo     = new CostRepository(conn);
     stockRepo    = new StockRepository(conn);
     userRepo     = new UserRepository(conn);
     billsRepo    = new BillsRepository(conn);
     expRepo      = new ExpensesRepository(conn);
     foldersRepo  = new FoldersRepository(conn);
     dbBase       = new DropBoxBase("o9340xsv2mzn7ws", "xzky2fzfnmssik1");
     checker      = new ShopsChecker(shopRepo);
     dbBase.GeneratedAuthenticationURL();
     dbBase.GenerateAccessToken();
     prodService = new ProductService(shopRepo, businessRepo, imgRepo, dbBase, prodRepo, unitRepo, priceRepo,
                                      costRepo, stockRepo, ordersRepo, strategy, new FoldersDataService(foldersRepo, prodRepo));
     orderStockRepo     = new OrderStockRepository(conn);
     strategy           = new FifoStrategy(orderStockRepo, stockRepo, costRepo);
     salesService       = new SalesSerivce(userRepo, shopRepo, billsRepo, prodRepo, priceRepo, imgRepo, strategy, checker, costRepo);
     ordersRepo         = new OrdersRepository(conn);
     productDataService = new ProductDataService(dbBase);
 }
예제 #8
0
        public ActionResult EditProduct(int productId)
        {
            var productDataService = new ProductDataService();
            var product            = productDataService.GetProductById(productId);

            return(PartialView(new ProductViewModel(product)));
        }
예제 #9
0
        public ProductDefectionsVM(ProductVM product, AccessType access):base(access)
        {
            UnitOfWork = new SoheilEdmContext();
            CurrentProduct = product;
            ProductDataService = new ProductDataService(UnitOfWork);
            ProductDataService.DefectionAdded += OnDefectionAdded;
            ProductDataService.DefectionRemoved += OnDefectionRemoved;
            DefectionDataService = new DefectionDataService(UnitOfWork);
            ProductDefectionDataService = new ProductDefectionDataService(UnitOfWork);

            var selectedVms = new ObservableCollection<ProductDefectionVM>();
            foreach (var productDefection in ProductDataService.GetDefections(product.Id))
            {
                selectedVms.Add(new ProductDefectionVM(productDefection, Access, ProductDefectionDataService, RelationDirection.Straight));
            }
            SelectedItems = new ListCollectionView(selectedVms);

            var allVms = new ObservableCollection<DefectionVM>();
            foreach (var defection in DefectionDataService.GetActives(SoheilEntityType.Products, CurrentProduct.Id))
            {
                allVms.Add(new DefectionVM(defection, Access, DefectionDataService));
            }
            AllItems = new ListCollectionView(allVms);

            IncludeCommand = new Command(Include, CanInclude);
            ExcludeCommand = new Command(Exclude, CanExclude);
            IncludeRangeCommand = new Command(IncludeRange, CanIncludeRange);
            ExcludeRangeCommand = new Command(ExcludeRange, CanExcludeRange);
        }
예제 #10
0
        public ActionResult GetStock(string productCode)
        {
            var orkaDataService = new StockDataService();
            var stocks          = orkaDataService.GetStockByCodeWithWildCardFromOrka(productCode).Select(x => new StockViewModel {
                Code = x.Code, Price = x.Price, StockAmount = x.StockAmount
            }).ToList();

            var productIds = new ProductDataService().GetProductByCodeWithWildCard(productCode).Select(x => x.Id).ToList();

            foreach (var productId in productIds)
            {
                var code           = new ProductDataService().GetProductById(productId).Code;
                var reservedAmount = new SalesDataService().GetReservedCountyProductId(productId);
                var stock          = stocks.FirstOrDefault(x => x.Code == code);
                if (stock != null)
                {
                    stock.ReservedAmount = reservedAmount;
                    stock.StockAmount   -= reservedAmount;
                }
            }


            return(new JsonResult()
            {
                Data = stocks,
                ContentType = "application/json",
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
예제 #11
0
        private async void UpdateInventories()
        {
            InventoryDataService mInventoryDataService = new InventoryDataService();
            ProductDataService   mProductDataService   = new ProductDataService();

            LoginPageActivity.mGlobalProducts = await mProductDataService.GetAll();

            LoginPageActivity.mGlobalInventories = new List <InventoryViewModel>();

            List <InventoryViewModel> tempInventories = await mInventoryDataService.GetAll();

            for (int i = 0; i < tempInventories.Count(); i++)
            {
                for (int j = 0; j < LoginPageActivity.mGlobalProducts.Count(); j++)
                {
                    if (tempInventories[i].ProductId == LoginPageActivity.mGlobalProducts[j].Id)
                    {
                        tempInventories[i].ItemName = LoginPageActivity.mGlobalProducts[j].Name;
                        LoginPageActivity.mGlobalInventories.Add(tempInventories[i]);
                    }
                    if (LoginPageActivity.mGlobalProducts[j].AddedUserId == LoginPageActivity.StaticUserClass.ID.ToString())
                    {
                        LoginPageActivity.mGlobalProductsByUser.Add(LoginPageActivity.mGlobalProducts[j]);
                    }
                }
            }
        }
예제 #12
0
        public void GetProductDetailTest()
        {
            var service = new ProductDataService(repository);

            var product = service.GetProductDetail(1);

            Assert.IsNotNull(product);
        }
예제 #13
0
 public UseActivity()
 {
     mInventoryDataService = new InventoryDataService();
     mProductDataService   = new ProductDataService();
     mCategoryDataService  = new CategoryDataService();
     mStorageDataService   = new StorageDataService();
     mConsumeDataService   = new ConsumeDataService();
 }
 public CartModelFactory(IWorkContext workContext, ShoppingCartHelper shoppingCartHelper,
                         ProductDataService productDataService, ICurrentUserService currentUserService)
 {
     _workContext        = workContext;
     _shoppingCartHelper = shoppingCartHelper;
     _productDataService = productDataService;
     _currentUserService = currentUserService;
 }
예제 #15
0
        public ProductDboTest()
        {
            repository             = new ProductRepository(DbContextFactory);
            manufacturerRepository = new ManufacturerRepository(DbContextFactory);
            userRepository         = new UserRepository(DbContextFactory);
            categoryRepository     = new CategoryRepository(DbContextFactory);

            dataService = new ProductDataService(repository, UnitOfWork);
        }
예제 #16
0
        public ProductDboTest()
        {
            repository = new ProductRepository(DbContextFactory);
            manufacturerRepository = new ManufacturerRepository(DbContextFactory);
            userRepository = new UserRepository(DbContextFactory);
            categoryRepository = new CategoryRepository(DbContextFactory);

            dataService  = new ProductDataService(repository, UnitOfWork);
        }
예제 #17
0
 protected override async Task OnInitializedAsync()
 {
     Elements               = (await DataService.GetAll()).ToArray();
     Suppliers              = (await SupplierDataService.GetAll()).ToArray();
     Warehouses             = (await WarehouseDataService.GetAll()).ToArray();
     PaymentTerms           = (await PaymentTermDataService.GetAll()).ToArray();
     _productListParameters = new ProductListParameters();
     Products               = (await ProductDataService.Get(_productListParameters)).ToArray();
     Taxes = (await TaxDataService.GetAll()).ToArray();
 }
예제 #18
0
        public int GetStockInformationByProductCode(string productCode)
        {
            var stock         = new StockDataService().GetStockByCodeFromOrka(productCode);
            var productId     = new ProductDataService().GetProductByCode(productCode).Id;
            var reservedStock = new SalesDataService().GetReservedCountyProductId(productId);

            var usableStock = stock.StockAmount - reservedStock;

            return(usableStock);
        }
예제 #19
0
 protected override async Task OnInitializedAsync()
 {
     PaymentTerms = (await PaymentTermDataService.GetAll()).ToArray();
     Clients      = (await ClientDataService.GetAll()).ToArray();
     ProductsData = (await ProductDataService.GetAll()).ToArray();
     Lines        = new List <InvoiceLine> {
         InvoiceLinesRef.GetEmptyLine()
     };
     NumberSequences = (await NumberSequenceDataService.GetAll()).ToArray();
     await IsEditingInvoice();
 }
        public void GetAllProductsTest()
        {
            //arrange
            var service = new ProductDataService(repository);

            //act
            var products = service.GetAllAsync();

            //assert
            Assert.IsNotNull(products);
        }
예제 #21
0
        public ActionResult GetProductByCode(string productCode)
        {
            var products = new ProductDataService().GetProductByCodeWithWildCard(productCode);

            return(new JsonResult()
            {
                Data = products,
                ContentType = "application/json",
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
        public void GetProducts()
        {
            //Arrange
            var service = new ProductDataService(repository);

            //Act
            List <Product> products = service.GetProducts();

            //Assert
            Assert.IsNotNull(products);
        }
예제 #23
0
        public void GetAllProductsTest()
        {
            //arrange
            var service = new ProductDataService(repository);

            //act
            var products = service.GetAllAsync();

            //assert
            Assert.IsNotNull(products);
        }
        public void GetProductById()
        {
            //Arrange
            var service = new ProductDataService(repository);

            //Act
            var product = service.GetProductById(1);

            //Assert
            Assert.IsNotNull(product);
        }
예제 #25
0
        public ActionResult DeleteProduct(int productId)
        {
            var result = new ProductDataService().DeleteProductById(productId);

            return(new JsonResult()
            {
                Data = result,
                ContentType = "application/json",
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
예제 #26
0
 public AddItemBarcodeFragment()
 {
     mInventoryDataService = new InventoryDataService();
     mProductDataService   = new ProductDataService();
     mCategoryDataService  = new CategoryDataService();
     mStorageDataService   = new StorageDataService();
     spinnerListCategories = new List <CategoryViewModel>();
     mProducts             = LoginPageActivity.mGlobalProducts;
     mStorages             = LoginPageActivity.mGlobalStorages;
     mCategories           = LoginPageActivity.mGlobalCategories;
 }
예제 #27
0
 public AddItemBarcodeFragment()
 {
     mInventoryDataService = new InventoryDataService();
     mProductDataService   = new ProductDataService();
     mCategoryDataService  = new CategoryDataService();
     mStorageDataService   = new StorageDataService();
     mProducts             = new List <ProductViewModel>();
     mStorages             = new List <StorageViewModel>();
     mCategories           = new List <CategoryViewModel>();
     isBarcodeFound        = false;
 }
예제 #28
0
        public ActionResult EditProduct(ProductViewModel product)
        {
            var productDataService = new ProductDataService();

            productDataService.UpdateProduct(product);
            return(new JsonResult()
            {
                Data = product,
                ContentType = "application/json"
            });
        }
예제 #29
0
 public HomeFragment()
 {
     mLocationDataService  = new LocationDataService();
     mInventoryDataService = new InventoryDataService();
     mProductDataService   = new ProductDataService();
     mStorageDataService   = new StorageDataService();
     mInventories          = new List <InventoryViewModel>();
     mProducts             = new List <ProductViewModel>();
     mStorages             = new List <StorageViewModel>();
     mLocations            = new List <LocationViewModel>();
     mUserLoc = new List <UserLocationViewModel>();
 }
예제 #30
0
        public ActionResult GetProducts()
        {
            var products = new ProductDataService().GetAllProducts();

            return(new JsonResult()
            {
                Data = products,
                ContentType = "application/json",
                JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                MaxJsonLength = Int32.MaxValue
            });
        }
예제 #31
0
 public LoginPageActivity()
 {
     mAccountDataService      = new AccountDataService();
     mInventoryDataService    = new InventoryDataService();
     mProductDataService      = new ProductDataService();
     mStorageDataService      = new StorageDataService();
     mLocationDataService     = new LocationDataService();
     mCategoryDataService     = new CategoryDataService();
     mConsumeDataService      = new ConsumeDataService();
     mUserDataDataService     = new UserDataDataService();
     mUserLocationDataService = new UserLocationDataService();
 }
예제 #32
0
        protected override async Task OnInitializedAsync()
        {
            int.TryParse(ProductId, out var productId);
            Product = await ProductDataService.Get(productId);

            CategoryId = Product.CategoryId.ToString();

            Categories = await CategoryDataService.Get();

            Categories.Insert(0, new Category {
                CategoryId = -1, Name = "Please select"
            });
        }
예제 #33
0
 public SplashScreenActivity()
 {
     mAccountDataService      = new AccountDataService();
     mInventoryDataService    = new InventoryDataService();
     mProductDataService      = new ProductDataService();
     mStorageDataService      = new StorageDataService();
     mLocationDataService     = new LocationDataService();
     mCategoryDataService     = new CategoryDataService();
     mConsumeDataService      = new ConsumeDataService();
     mUserDataDataService     = new UserDataDataService();
     mUserLocationDataService = new UserLocationDataService();
     mShopListDataService     = new ShoplistDataService();
     mShopItemDataService     = new ShopItemDataService();
 }
예제 #34
0
        public IList <Product> GetProducts()
        {
            IList <Product> products = new List <Product>();
            DataTable       ds;

            using (ProductDataService data = new ProductDataService())
            {
                string sql = "SELECT *  FROM [Production].[Product]";

                ds = data.GetProducts(sql);
            }
            products = ConvertToProducts(ds);

            return(products);
        }
예제 #35
0
파일: FpcsVm.cs 프로젝트: T1Easyware/Soheil
        private void InitializeData()
        {
            UnitOfWork = new SoheilEdmContext();
			FpcDataService = new FPCDataService();
            ProductDataService = new ProductDataService(UnitOfWork);
            ProductGroupDataService = new ProductGroupDataService(UnitOfWork);
			FpcDataService.FpcAdded += OnFpcAdded;

            ColumnHeaders = new List<ColumnInfo> 
            { 
                new ColumnInfo("Code",0), 
                new ColumnInfo("Name",1), 
                new ColumnInfo("Status",2) ,
                new ColumnInfo("Mode",3,true) 
            };

            AddCommand = new Command(Add, CanAdd);
			RefreshCommand = new Command(CreateItems);
            AddGroupCommand = new Command(Add, () => false);
            CreateItems(null);
        }
예제 #36
0
        private void InitializeData()
        {
            UnitOfWork = new SoheilEdmContext();
            ProductGroupDataService = new ProductGroupDataService(UnitOfWork);
            ProductDataService = new ProductDataService(UnitOfWork);
            ProductDataService.ProductAdded += OnProductAdded;
            ProductGroupDataService.ProductGroupAdded += OnProductGroupAdded;

            ColumnHeaders = new List<ColumnInfo> 
            { 
                new ColumnInfo("Code",0), 
                new ColumnInfo("Name",1), 
                new ColumnInfo("Color",3), 
                new ColumnInfo("Status",2) ,
                new ColumnInfo("Mode",4,true) 
            };

            AddCommand = new Command(Add, CanAdd);RefreshCommand = new Command(CreateItems);
            AddGroupCommand = new Command(AddGroup);
            ViewCommand = new Command(View, CanView);

            CreateItems(null);
        }
예제 #37
0
 private void InitializeData(ProductDataService dataService, ProductGroupDataService groupDataService)
 {
     ProductDataService = dataService;
     GroupDataService = groupDataService;
     SaveCommand = new Command(Save, CanSave);
 }
예제 #38
0
 public static Product CreateNew(ProductDataService dataService, int groupId)
 {
     var color = PickRandomColor();
     int id = dataService.AddModel(new Product { Name = "جدید", Code = string.Empty, CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now , Color = color}, groupId);
     return dataService.GetSingle(id);
 }
예제 #39
0
		/// <summary>
		/// Creates a UOW and initializes DataServices and adds ProductGroups and stuff
		/// </summary>
		private void InitializeData()
		{
			var uow = new Dal.SoheilEdmContext();
			ProductGroupDataService = new ProductGroupDataService(uow);
			ProductDataService = new ProductDataService(uow);

			//Create Tree

			//add general node first
			var general = new GeneralVm();
			general.Selected += SelectNode;
			Tree.Add(general);

			//add all groups and their children recursively
			var allGroups = ProductGroupDataService.GetActives();
			foreach (var productGroup in allGroups)
			{
				var pg = new ProductGroupVm(productGroup);
				pg.Selected += SelectNode;
				Tree.Add(pg);
			}

			IsLoading = false;
		}
예제 #40
0
        public RootFishbonesVM(RootVM root, ProductDefectionVM productDefection, AccessType access) : base(access)
        {
            UnitOfWork = new SoheilEdmContext();
            CurrentRoot = root;
            RootDataService = new RootDataService(UnitOfWork);
            RootDataService.FishboneAdded += OnFishboneNodeAdded;
            RootDataService.FishboneRemoved += OnFishboneNodeRemoved;
            ProductDefectionDataService = new ProductDefectionDataService(UnitOfWork);
            ProductDataService = new ProductDataService(UnitOfWork);
            DefectionDataService = new DefectionDataService(UnitOfWork);
            SwitchItemsCommand = new Command(SetProductDefections);
            ViewProductDefectionsCommand = new Command(ViewProductDefections);
            InitializeFishboneCommand = new Command(InitializeFishbone);
            FishboneNodeDataService = new FishboneNodeDataService(UnitOfWork);

            RootNode = new FishboneNodeVM(Access, FishboneNodeDataService) { Title = string.Empty, Id = -1, ParentId = -2 };

            var selectedVms = new ObservableCollection<FishboneNodeVM>();
            foreach (var rootFishboneNode in RootDataService.GetFishboneNodes(root.Id))
            {
                selectedVms.Add(new FishboneNodeVM(rootFishboneNode, Access, FishboneNodeDataService));
            }

            SetProductDefections();

            IncludeCommand = new Command(Include, CanInclude);
            ExcludeTreeCommand = new Command(ExcludeTree, CanExcludeTree);


            foreach (FishboneNodeVM item in selectedVms)
            {
                if (item.ParentId == RootNode.Id)
                {
                    RootNode.ChildNodes.Add(item);
                    break;
                }
            }

            CurrentNode = RootNode;

            if (productDefection != null)
            {
                foreach (IInfoViewModel item in DefectionList)
                {
                    if (item.Id == productDefection.DefectionId)
                    {
                        CurrentDefection = item;
                        ViewProductDefections(null);
                        break;
                    }
                }
				if(AllItems!=null)
                foreach (ProductDefectionVM item in AllItems)
                {
                    if (item.Id == productDefection.Id)
                    {
                        CurrentProductDefection = item;
                        IsEnabled = false;
                        break;
                    }
                }
            }

        }
예제 #41
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProductVM"/> class from the model.
 /// </summary>
 /// <param name="entity">The model.</param>
 /// <param name="groupItems">The group view models.</param>
 /// <param name="access"></param>
 /// <param name="dataService"></param>
 /// <param name="groupDataService"></param>
 public ProductVM(Product entity, ListCollectionView groupItems, AccessType access, ProductDataService dataService, ProductGroupDataService groupDataService)
     : base(access)
 {
     InitializeData(dataService, groupDataService);
     _model = entity;
     Groups = groupItems;
     foreach (ProductGroupVM groupVm in groupItems)
     {
         if (groupVm.Id == entity.ProductGroup.Id)
         {
             SelectedGroupVM = groupVm;
             break;
         }
     }
 }
예제 #42
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProductVM"/> class.
 /// </summary>
 /// <param name="entity">The entity.</param>
 /// <param name="access"></param>
 /// <param name="dataService"></param>
 /// <param name="groupDataService"></param>
 public ProductVM(Product entity, AccessType access, ProductDataService dataService, ProductGroupDataService groupDataService)
     : base(access)
 {
     _model = entity;
     InitializeData(dataService, groupDataService);
     Groups = new ListCollectionView(new ObservableCollection<ProductGroupVM>());
 }