예제 #1
0
        public IActionResult Product(int id)
        {
            var productDataManager = new ProductDataManager(Context);
            var model = productDataManager.GetProductById(id);

            return(View(model));
        }
예제 #2
0
        public IActionResult Search(string id)
        {
            var productDataManager = new ProductDataManager(Context);
            var model = productDataManager.GetProductByQuery(id);

            return(View(model));
        }
        public CategorySearchResponse GetSubCategories()
        {
            List <Category> categories = new List <Category>();

            productDataManager = new ProductDataManager();
            DataSet ds = productDataManager.GetCategories();
            CategorySearchResponse response = new CategorySearchResponse();
            DataTable dtSubCategory         = new DataTable();

            dtSubCategory = ds.Tables[1];
            if (dtSubCategory.Rows.Count > 0)
            {
                foreach (DataRow dr in dtSubCategory.Rows)
                {
                    Category category = new Category();
                    category.CategoryId   = Convert.ToInt32(dr["CategoryId"]);
                    category.CategoryName = dr["CategoryName"].ToString();
                    categories.Add(category);
                }
            }

            response.CategoryList = categories;

            return(response);
        }
        public ProductSearchResponse GetAllProducts()
        {
            List <Product> products = new List <Product>();

            productDataManager = new ProductDataManager();
            DataSet ds = productDataManager.GetAllProducts();
            ProductSearchResponse response = new ProductSearchResponse();
            DataTable             dt       = new DataTable();

            dt = ds.Tables[0];

            if (dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    Product product = new Product();
                    product.Id                    = Convert.ToInt32(dr["Id"]);
                    product.Name                  = dr["Name"].ToString();
                    product.Description           = dr["Description"].ToString();
                    product.Price                 = Convert.ToDecimal(dr["Price"]);
                    product.Status                = dr["Status"].ToString();
                    product.Category              = new Category();
                    product.Category.CategoryName = Convert.ToString(dr["CategoryName"]);
                    if (dr["CategoryId"] != System.DBNull.Value)
                    {
                        product.Category.CategoryId = Convert.ToInt32(dr["CategoryId"]);
                    }
                    products.Add(product);
                }
            }
            // NoOfRows = dt.Rows.Count;
            response.ProductList = products;
            response.Count       = Convert.ToInt32(ds.Tables[1].Rows[0][0]);
            return(response);
        }
예제 #5
0
            private static void UpsertRemoteProductData(GetProductsServiceRequest request)
            {
                GetProductDataRealtimeRequest getProductDataServiceRequest = null;

                if (!request.ProductIds.IsNullOrEmpty())
                {
                    getProductDataServiceRequest = new GetProductDataRealtimeRequest(request.ProductIds);
                }
                else if (!request.ItemAndInventDimIdCombinations.IsNullOrEmpty())
                {
                    var itemIds = request.ItemAndInventDimIdCombinations.Select(i => i.ItemId);
                    getProductDataServiceRequest = new GetProductDataRealtimeRequest(itemIds);
                }
                else
                {
                    return;
                }

                var getProductDataResponse = request.RequestContext.Execute <GetProductDataRealtimeResponse>(getProductDataServiceRequest);
                var productsXml            = getProductDataResponse.ProductDataXml;

                var manager = new ProductDataManager(request.RequestContext);

                manager.SaveProductData(productsXml);
            }
예제 #6
0
        private static void Main(string[] args)
        {
            IUserService        userService;
            DomainManager       domainManager       = new DomainManager();
            InventoryContext    context             = new InventoryContext();
            UserServiceProvider userServiceProvider = new UserServiceProvider(context, domainManager);
            LogInService        logInService        = new LogInService(domainManager, userServiceProvider);
            var responce = logInService.LogInWithPassword("AElmendo", "Drizzle123!", false, InventorySoftwareType.PRODUCTS_SALES);

            userService = responce.Service;
            ProductDataManager dataManager   = new ProductDataManager(context, userService);
            ImportService      importService = new ImportService(dataManager);

            Console.WriteLine("Starting Service");
            importService.Load();
            Console.WriteLine("Importing Data");
            importService.ImportData();
            importService.Parse();
            Console.WriteLine("Import Finsihed");
            Console.WriteLine("Create Lots");
            var response = importService.Create();

            Console.WriteLine("Should be finished.  See results below:");
            Console.WriteLine(response.Message);
            Console.ReadKey();
        }
        public ProductSelectorViewModel(ProductDataManager dataManager, IEventAggregator eventAggregator, IRegionManager regionManager)
        {
            this._dataManager     = dataManager;
            this._eventAggregator = eventAggregator;
            this._regionManager   = regionManager;

            this.ViewProductDetailsDelegate = new PrismCommands.DelegateCommand(this.ViewProductDetailsHandler, this.CanExecuteViewDetails);
            this.StartIncomingWithDelegate  = new PrismCommands.DelegateCommand(this.StartWithSelectedHandler, this.CanExecute);
            this.NewProductCommand          = new PrismCommands.DelegateCommand(this.CreateNewProductHandler, this.CanExecute);
            this.SetInIncomingFormDelegate  = new PrismCommands.DelegateCommand(this.SetInIncomingHandler, this.CanExecuteIncoming);
            this.EditProductDelegate        = new PrismCommands.DelegateCommand(this.EditProductHandler, this.CanExecute);
            this.RefreshDataCommand         = new AsyncCommand(this.RefreshHandler, this.CanExecute);
            this.ClearDetailViewsCommand    = new PrismCommands.DelegateCommand(this.ClearDetailViewsHandler, this.CanExecute);
            this.InitializeCommand          = new AsyncCommand(this.PopulateAsync);
            this.BulkImportCommand          = new AsyncCommand(this.BulkImportHandler);

            this.OnCopyingToClipboardCommand = new PrismCommands.DelegateCommand(this.OnCopyingToClipboardHandler);

            this._eventAggregator.GetEvent <StartOutgoingListEvent>().Subscribe(() => this.outgoingInProgress = true);
            this._eventAggregator.GetEvent <DoneOutgoingListEvent>().Subscribe(this.OutgoingListDone);
            this._eventAggregator.GetEvent <CancelOutgoingListEvent>().Subscribe(this.OutgoingListDone);

            this._eventAggregator.GetEvent <DoneIncomingListEvent>().Subscribe(this.CheckInDoneHandler);
            this._eventAggregator.GetEvent <CancelIncomingListEvent>().Subscribe(this.CheckInDoneHandler);

            this._eventAggregator.GetEvent <ProductEditingDoneEvent>().Subscribe(this.EditingDoneHandler);

            this._eventAggregator.GetEvent <LotRankReservationEditingStartedEvent>().Subscribe(() => { this.editInProgress = true; });
            this._eventAggregator.GetEvent <LotRankReservationEditingDoneEvent>().Subscribe(this.EditingDoneHandler);

            //this.Populate();
        }
예제 #8
0
            /// <summary>
            /// Checks if the downloaded product contains a kit product and retrieves the component and substitutes of the kit product.
            /// </summary>
            /// <param name="request">The product retrieval request.</param>
            /// <param name="productsXml">The product xml data remotely retrieved from AX.</param>
            private static void RetrieveComponentProducts(ProductSearchServiceRequest request, XDocument productsXml)
            {
                // For kit products, components and substitutes of the kit should also be downloaded from AX using transaction services.
                // Hence identify the list of components and substitutes of the kit and download the corresponding product data from AX.
                // This should be done before reading the virtual kit product from the store db.
                var components = productsXml.Descendants("RetailKitComponent");

                // if there are any components or substitutes of a kit then download the corresponding product data from AX and save it in local db.
                if (components.Any())
                {
                    var substitutes = productsXml.Descendants("SubstituteProduct");

                    List <long> ids = new List <long>();
                    foreach (var component in components)
                    {
                        ids.Add(long.Parse(component.Element("Component").Value));
                    }

                    foreach (var substitute in substitutes)
                    {
                        ids.Add(long.Parse(substitute.Value));
                    }

                    var manager = new ProductDataManager(request.RequestContext);

                    GetProductDataRealtimeRequest getProductDataServiceRequestForComponent = new GetProductDataRealtimeRequest(ids);
                    var getProductDataResponseForComponent = request.RequestContext.Execute <GetProductDataRealtimeResponse>(getProductDataServiceRequestForComponent);

                    var componentsXml = getProductDataResponseForComponent.ProductDataXml;
                    manager.SaveProductData(componentsXml);
                }
            }
            /// <summary>
            /// Executes the workflow to end the products read session.
            /// </summary>
            /// <param name="request">The request.</param>
            /// <returns>The response.</returns>
            protected override EndReadChangedProductsResponse Process(EndReadChangedProductsRequest request)
            {
                ThrowIf.Null(request, "request");

                ProductDataManager manager = new ProductDataManager(this.Context);

                manager.EndReadChangedProducts(request.Session);

                return(new EndReadChangedProductsResponse());
            }
예제 #10
0
 public ImportLotsViewModel(ProductDataManager dataManager, IEventAggregator eventAggregator, IRegionManager regionManager)
 {
     this._dataManager             = dataManager;
     this._eventAggregator         = eventAggregator;
     this._regionManager           = regionManager;
     this.SpreadsheetLoadedCommand = new AsyncCommand <Worksheet>(this.SpreadsheetLoadedHandler);
     this.ProcessLotsCommand       = new AsyncCommand(this.ProcessLotsHandler);
     this.InitializeCommand        = new AsyncCommand(this.LoadAsync);
     this.DoneCommand   = new PrismCommands.DelegateCommand(this.FinishedHandler, () => !this.incomingInProgress);
     this.CancelCommand = new PrismCommands.DelegateCommand(this.CancelHandler, () => !this.incomingInProgress);
 }
예제 #11
0
        public IActionResult CreateProduct(CreateProductViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            var productDataManager = new ProductDataManager(Context);

            productDataManager.AddProduct(viewModel);

            return(RedirectToAction(nameof(ProductsController.Index)));
        }
예제 #12
0
        public IActionResult ShoppingCart(int id)
        {
            var productDataManager = new ProductDataManager(Context);

            productDataManager.AddProductToShoppingCart(id);
            var a = productDataManager.ShoppingCart();

            if (a.Count > 0)
            {
                return(View(a));
            }
            return(View());
        }
예제 #13
0
        public IActionResult CheckoutComplete(string id)
        {
            if (Request.Cookies["Id"].Count > 0)
            {
                int  customerId;
                bool tryParse = int.TryParse(Request.Cookies["Id"].First().ToString(), out customerId);

                if (tryParse)
                {
                    var productDataManager = new ProductDataManager(Context /*, Context2, Context3*/);
                    productDataManager.RegisterCheckout(customerId);
                    return(View());
                }
            }
            return(RedirectToAction(nameof(CustomersController.Index)));
        }
        public IncomingProductFormViewModel(IEventAggregator eventAggregator, IRegionManager regionManager, ProductDataManager dataManager)
        {
            this._eventAggregator        = eventAggregator;
            this._regionManager          = regionManager;
            this._dataManager            = dataManager;
            this.AddLotToIncomingCommand = new PrismCommands.DelegateCommand(this.AddLotToIncomingHandler);
            this.AddRankToLotCommand     = new PrismCommands.DelegateCommand(this.AddRankToLotHandler);
            this.CancelIncomingCommand   = new PrismCommands.DelegateCommand(this.CancelIncomingHandler);
            this.SetLotCommand           = new PrismCommands.DelegateCommand(this.SetLotHandler);
            this.EditLotCommand          = new PrismCommands.DelegateCommand(this.EditLotHandler);

            this._eventAggregator.GetEvent <SetInIncomingFormEvent>().Subscribe(this.SetProductHandler);
            this._eventAggregator.GetEvent <AddToIncomingCallback>().Subscribe(this.AddLotToIncomingCallBack);

            this.SetDefaults();
        }
예제 #15
0
            private static ProductSearchServiceResponse SearchProducts(ProductSearchServiceRequest request)
            {
                ProductSearchServiceResponse response;

                long currentChannelId = request.RequestContext.GetPrincipal().ChannelId;

                if (request.QueryCriteria.Context.IsRemoteLookup(currentChannelId))
                {
                    response = SearchRemoteProducts(request);
                }
                else
                {
                    response = SearchProductsLocal(request);
                    var results = response.ProductSearchResult;

                    // Download product data from AX if it is not found locally and the DownloadProductData flag is set.
                    if (results.Results.Count < request.QueryCriteria.ItemIds.Distinct().Count() && request.QueryCriteria.DownloadProductData == true)
                    {
                        List <string> itemIds = new List <string>();

                        foreach (ProductLookupClause productLookupClause in request.QueryCriteria.ItemIds)
                        {
                            itemIds.Add(productLookupClause.ItemId);
                        }

                        var getProductDataServiceRequest = new GetProductDataRealtimeRequest(itemIds);

                        var getProductDataServiceResponse = request.RequestContext.Runtime.Execute <GetProductDataRealtimeResponse>(getProductDataServiceRequest, request.RequestContext);
                        var productsXml = getProductDataServiceResponse.ProductDataXml;

                        var manager = new ProductDataManager(request.RequestContext);
                        manager.SaveProductData(productsXml);

                        // Reset the channel context since the remote product data has been saved locally.
                        request.QueryCriteria.Context.ChannelId = request.RequestContext.GetPrincipal().ChannelId;
                        request.QueryCriteria.Context.CatalogId = 0;

                        response = SearchProductsLocal(request);
                    }
                }

                return(response);
            }
예제 #16
0
 public int DeleteProducts(int Id)
 {
     productDataManager = new ProductDataManager();
     return(productDataManager.DeleteProducts(Id));
 }
예제 #17
0
 public int UpdateProducts(Product product)
 {
     productDataManager = new ProductDataManager();
     return(productDataManager.UpdateProducts(product.Id, product.Name, product.Description, product.Price, product.Status, product.Category.CategoryId));
 }
예제 #18
0
 public int InsertProduct(Product product)
 {
     productDataManager = new ProductDataManager();
     return(productDataManager.InsertProduct(product.Name, product.Description, product.Price, product.Status, product.Category.CategoryId));
 }
예제 #19
0
 public int InsertCategory(Category category)
 {
     productDataManager = new ProductDataManager();
     return(productDataManager.InsertCategory(category.CategoryName, category.ImageName, category.ParentId));
 }
예제 #20
0
            private static ProductSearchServiceResponse SearchRemoteProducts(ProductSearchServiceRequest request)
            {
                ProductSearchResultContainer results = null;

                bool searchByProduct  = request.QueryCriteria.Ids != null && request.QueryCriteria.Ids.Any();
                bool searchByCategory = request.QueryCriteria.CategoryIds != null && request.QueryCriteria.CategoryIds.Any();
                bool searchByKeyword  = !string.IsNullOrEmpty(request.QueryCriteria.SearchCondition);

                if (searchByCategory && request.QueryCriteria.CategoryIds.HasMultiple())
                {
                    throw new NotSupportedException("Only a single category identifier can be specified when searching remotely.");
                }

                if (!(searchByProduct ^ searchByCategory ^ searchByKeyword))
                {
                    throw new NotSupportedException("When searching remotely you can search only by id, category or keyword.");
                }

                string attributeIds = string.Concat(RetailProductChannelProductAttributeId.ProductName, ",", RetailProductChannelProductAttributeId.Image);

                if (searchByProduct)
                {
                    GetProductDataRealtimeRequest getProductDataServiceRequest = new GetProductDataRealtimeRequest(request.QueryCriteria.Ids);
                    var getProductDataResponse = request.RequestContext.Execute <GetProductDataRealtimeResponse>(getProductDataServiceRequest);
                    var productsXml            = getProductDataResponse.ProductDataXml;

                    var manager = new ProductDataManager(request.RequestContext);
                    manager.SaveProductData(productsXml);

                    // Checks if the downloaded product contains a kit product and retrieve the component and substitutes of the kit product.
                    RetrieveComponentProducts(request, productsXml);

                    // Reset the channel context since the remote product data has been saved locally.
                    request.QueryCriteria.Context.ChannelId = request.RequestContext.GetPrincipal().ChannelId;
                    request.QueryCriteria.Context.CatalogId = 0;

                    results = SearchProductsLocal(request).ProductSearchResult;
                }
                else if (searchByCategory)
                {
                    var getProductsByCategoryRequest = new GetRemoteProductsByCategoryRealtimeRequest(
                        request.QueryCriteria.Context.ChannelId.Value,
                        request.QueryCriteria.Context.CatalogId,
                        request.QueryCriteria.CategoryIds.First(),
                        attributeIds,
                        request.QueryCriteria.IncludeProductsFromDescendantCategories);

                    getProductsByCategoryRequest.QueryResultSettings = request.QueryResultSettings;

                    var response = request.RequestContext.Execute <ProductSearchRealtimeResponse>(getProductsByCategoryRequest);
                    results = response.ProductSearchResult;
                }
                else if (searchByKeyword)
                {
                    var getProductsByKeywordRequest = new GetRemoteProductsByKeywordRealtimeRequest(
                        request.QueryCriteria.Context.ChannelId.Value,
                        request.QueryCriteria.Context.CatalogId,
                        request.QueryCriteria.SearchCondition,
                        attributeIds);

                    getProductsByKeywordRequest.QueryResultSettings = request.QueryResultSettings;

                    var response = request.RequestContext.Execute <ProductSearchRealtimeResponse>(getProductsByKeywordRequest);
                    results = response.ProductSearchResult;
                }

                return(new ProductSearchServiceResponse(results));
            }