public CategorySearchResponse SubCategories() { //get category list IProductManager productManager = ProductFactory.GetProductManager(); return(productManager.GetSubCategories()); }
public static void InsertNewProduct(string name, int productType, int stock, int price) { Product newProduct = ProductFactory.CreateNewProduct(productType, name, stock, price); db.Products.Add(newProduct); db.SaveChanges(); }
public Product GetProductJoinProductTypeAndCompanyById(int id) { try { var db = dbClient.GetDatabase(database); var collection = db.GetCollection <BsonDocument>("Product"); var filter = Builders <BsonDocument> .Filter.Eq("ProductId", id); var aggregation = collection.Aggregate() .Lookup("ProductType", "productTypeId", "ProductTypeId", "ProductType_object") .Lookup("Company", "CompanyId", "CompanyId", "Company_object") .Match(filter) ; var documents = aggregation.ToList(); var document = documents[0]; Product product = ProductFactory.Create(document); return(product); } catch (Exception e) { Console.WriteLine(e.ToString()); return(null); } }
public StorageMaster() { this.productFactory = new ProductFactory(); this.storageFactory = new StorageFactory(); this.storageRegistry = new List <Storage>(); this.productsPool = new List <Product>(); }
////////////////////////////////////////////////////////////////////////////////////////////////// /// /// /// Event click to create a Prestashop Product from an Odacash Product /// /// /// ////////////////////////////////////////////////////////////////////////////////////////////////// public void btnInsert_Click(object sender, RoutedEventArgs e) { // If no product is selected inform the user a terminates the execution if (productsBox.SelectedItem.ToString() == "-- Selecione el producto de Odacash --") { System.Windows.MessageBox.Show("Elija un producto", "Error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, System.Windows.MessageBoxOptions.DefaultDesktopOnly); return; } ProductFactory pf = new ProductFactory(ConfigurationManager.AppSettings["baseUrl"].ToString(), ConfigurationManager.AppSettings["accProduct"].ToString(), ""); ImageFactory imf = new ImageFactory(ConfigurationManager.AppSettings["baseUrl"].ToString(), ConfigurationManager.AppSettings["accImages"].ToString(), ""); TextRange textRangeLarge = new TextRange(largeDesc.Document.ContentStart, largeDesc.Document.ContentEnd); TextRange textRangeShort = new TextRange(shortDesc.Document.ContentStart, shortDesc.Document.ContentEnd); try { // Create a Product product newProd = createProduct(name.Text, yes.IsChecked, textRangeShort.Text, textRangeLarge.Text, price.Text, categoryBox.SelectedItem.ToString(), manufacturerBox.SelectedItem.ToString(), textStock.Text, textNoStock.Text); // Add the product to the web pf.Add(newProd); // If the product have images add it too. if (imgBox.HasItems) { for (int i = 0; imgBox.Items.Count > i; i++) { imf.AddProductImage((long)newProd.id, imgBox.Items[i].ToString()); } } // Create a link to sync the stock between Odacash and Prestashop insertInventory(name.Text, ConfigurationManager.AppSettings["idPrestashop"].ToString(), "0", idOdacash.Text); } catch (Exception ex) { // Display errors in a txt and alert the user with a messageBox using (StreamWriter writer = new StreamWriter($@"C:\ExportProduct\ExportProducts.txt", true)) { writer.WriteLine("Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString()); writer.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine); System.Windows.MessageBox.Show("Se ha pruducido un error.Puede ver el contenido del mismo en el log del programa", "Error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, System.Windows.MessageBoxOptions.DefaultDesktopOnly); } } finally { // Restart the fields when the executions ends productsBox.SelectedIndex = 0; idOdacash.Text = ""; name.Text = ""; price.Text = ""; shortDesc.Document.Blocks.Clear(); largeDesc.Document.Blocks.Clear(); categoryBox.SelectedIndex = 0; manufacturerBox.SelectedIndex = 0; textStock.Text = ""; textNoStock.Text = ""; imgBox.Items.Clear(); } }
static void Main(string[] args) { ProductFactory productFactory = new ProductFactory(); ProductBase product = productFactory.GetProductTablet(); // ADD // ProductBase product = productFactory.GetProductTablet("SKUTEST","tablet","Test","Test_desc","8col","testimg"); // product.AddProduct(); // GET product.SKU = "TB1234"; List <ProductBase> products = product.GetProducts(); // UPDATE products[0].Description += "_UPD"; products[0].UpdateProduct(); // DELETE products[0].RemoveProduct(); Console.ReadKey(); }
public void PutSuccessTest() { TokenModel tokenModel = GetToken(); var withQuantityPostProduct = ProductFactory.Create(StateProduct.WithQuantity); var postRequestBuilder = CreateRequestBuilder(ApiAddressProduct, Method.POST.ToString(), tokenModel.Token, CreateContent(withQuantityPostProduct)); var postResponse = postRequestBuilder.PostAsync().Result; postResponse.EnsureSuccessStatusCode(); Assert.AreEqual(HttpStatusCode.Created, postResponse.StatusCode); var putProduct = ProductFactory.Create(StateProduct.WithoutQuantity); var putRequestBuilder = CreateRequestBuilder($"{ApiAddressProduct}{withQuantityPostProduct.Sku}", Method.PUT.ToString(), tokenModel.Token, CreateContent(putProduct)); var putResponse = putRequestBuilder.SendAsync(Method.PUT.ToString()).Result; putResponse.EnsureSuccessStatusCode(); putProduct.Inventory.CalculateQuantity(); putProduct.IsMarketableProduct(); Assert.AreEqual(HttpStatusCode.NoContent, putResponse.StatusCode); Assert.AreEqual(putProduct.IsMarketable, false); Assert.IsTrue(putProduct.Inventory.Quantity == 0); }
public ActionResult EditProduct(int id) { var domainProduct = this.Repository.GetByID(id); var viewModelProduct = ProductFactory.CreateProductModel(domainProduct, this._categoryRepository); return(View("Edit", viewModelProduct)); }
public void Get_Returns_Product_When_Found_With_Includes() { var databaseName = Guid.NewGuid().ToString(); Guid addedProductId; using (var context = DbContextFactory.CreateInstance(databaseName)) { //Arrange var productToAdd = ProductFactory.CreateValidEntity(); context.Products.Add(productToAdd); context.SaveChanges(); addedProductId = productToAdd.Id; } using (var context = DbContextFactory.CreateInstance(databaseName)) { //Act var productRepository = new ProductRepository(context); var product = productRepository.Get(addedProductId, new ProductIncludes { ArticleOrderLines = true }); //Assert Assert.IsNotNull(product); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { int totalcount = 0; int pagesize = 10; int pageindex = HYRequest.GetQueryInt("p", 1); string kw = Utils.SafeCheckSearchKw(HYRequest.GetQueryString("kw")); this.SearchKw = kw; string whereSql = string.Empty; //List<ProductModel> list; if (!string.IsNullOrEmpty(kw)) { whereSql = string.Format(" where productname like '%{0}%' ", kw); searchProducts = ProductFactory.GetList(pagesize, pageindex, whereSql, " order by productid desc ", out totalcount); } else { searchProducts = ProductFactory.GetList(10, string.Empty); } PagerHtml = Utils.BuildProductListPager(totalcount, pagesize, pageindex, "search.aspx?p={0}&kw=" + kw); } }
public void Print() { AbstractFactory factoryDict = ProductFactory.GetFactory("FactoryDict"); IResponseDict response = factoryDict.GetRespDict("ResponseFunctionalKey"); PrintKeys(response.GetResponse(), ConsoleColor.Blue); }
public List <Product> GetProduct(string productName) { string getProducts = $@"SELECT ProductId, ProductName, ProductPrice, Stock, Type " + $@"FROM [dbo].[Products] WHERE ProductName LIKE '{productName}'"; List <Product> products = new List <Product>(); SqlConnection dbConnection = new SqlConnection(connectionString); SqlCommand command = new SqlCommand(getProducts, dbConnection); dbConnection.Open(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { Dictionary <String, String> productAttributes = GetProductAttributes(Convert.ToInt32(reader[0])); Product product = ProductFactory.Produce(Convert.ToInt32(reader[0]), reader[1].ToString(), Convert.ToDecimal(reader[2]), Convert.ToInt32(reader[3]), (ProductType)Enum.Parse(typeof(ProductType), reader[4].ToString()), productAttributes); products.Add(product); } return(products); }
public Product GetProduct(int productId) { string getProduct = $@"SELECT ProductId, ProductName, ProductPrice, Stock, Type " + $@"FROM [dbo].[Products] WHERE ProductId='{productId}'"; SqlConnection dbConnection = new SqlConnection(connectionString); SqlCommand command = new SqlCommand(getProduct, dbConnection); dbConnection.Open(); SqlDataReader reader = command.ExecuteReader(); Product product = null; Dictionary <String, String> productAttributes = GetProductAttributes(Convert.ToInt32(reader[0])); product = ProductFactory.Produce(Convert.ToInt32(reader[0]), reader[1].ToString(), Convert.ToDecimal(reader[2]), Convert.ToInt32(reader[3]), (ProductType)Enum.Parse(typeof(ProductType), reader[4].ToString()), productAttributes); reader.Close(); dbConnection.Close(); return(product); }
//public Command LoadMoreDataCommand => new Command(GetNextPageOfData); async Task ExecuteLoadMoreDataCommand() { IsBusy = true; ProductFactory productFactory = new ProductFactory(AppConfig.BaseUrl, AppConfig.Account, AppConfig.Password); Dictionary <string, string> filter = new Dictionary <string, string>(); filter.Add("id", "[1,10]"); List <product> itemsx = await productFactory.GetByFilterAsync(filter, null, null); for (int i = 0; i < itemsx.Count; i++) { Item item = new Item() { id = Convert.ToInt32(itemsx[i].id), name = itemsx[i].name[0].Value, reference = itemsx[i].reference, imageId = Convert.ToInt32(itemsx[i].id_default_image) }; Items.Add(item); } //return await productFactory.GetByFilterAsync(filter,null,null); //await DataStore.LoadMoreItems(); MessagingCenter.Send(this, "AddItems", Items); IsBusy = false; }
public SyncroBasePresta() : base() { var logondata = LoginData(); _url = logondata.WebServiceUrl; _url += "api/"; _autKey = logondata.AuthKey; var config = ConfigurationManager.OpenExeConfiguration( Assembly.GetExecutingAssembly().Location); CheckModeDebug(config); if (config.AppSettings.Settings["Test"].Value == "1") { _url = config.AppSettings.Settings["UrlPrestaShop"].Value; _autKey = config.AppSettings.Settings["AutKey"].Value; //StrumentiMusicali.Core.Manager.ManagerLog.Logger.Info("TEST _url "); //StrumentiMusicali.Core.Manager.ManagerLog.Logger.Info(_url); } _imageFactory = new ImageFactory(_url, _autKey, ""); _StockAvailableFactory = new StockAvailableFactory(_url, _autKey, ""); _productFactory = new ProductFactory(_url, _autKey, ""); _categoriesFact = new CategoryFactory(_url, _autKey, ""); _taxRuleGroupFact = new TaxRuleGroupFactory(_url, _autKey, ""); }
public void SetUp() { var productOnOffer = ProductFactory.CreateProduct(ProductType.Bread, 1); var conditionForOffer = ProductFactory.CreateProduct(ProductType.Butter, 2); _percentageOffer = new PercentageOffer(productOnOffer, conditionForOffer, 50); }
public IReadOnlyList <Product> HaalOp() { SqlConnection connection = GetConnection(); string query = "SELECT * FROM Product"; using (SqlCommand command = connection.CreateCommand()) { command.CommandText = query; connection.Open(); try { SqlDataReader reader = command.ExecuteReader(); List <Product> producten = new List <Product>(); while (reader.Read()) { producten.Add(ProductFactory.MaakNieuwProduct((string)reader["Naam"], (decimal)reader["Prijs"], (long)reader["Id"])); } reader.Close(); return(producten); } catch (Exception e) { Console.WriteLine($"Error: ${e.Message}"); throw new DbProductManagerException("DbProductManager: Fout bij ophalen van producten uit database"); } finally { connection.Close(); } } }
public void Remove_Deletes_Article_With_OrderLines() { //Arrange var customer = CustomerFactory.CreateValidEntity(); var productToAdd = ProductFactory.CreateValidEntity(); var article = ArticleFactory.CreateValidEntity(productToAdd); var order = OrderFactory.CreateValidEntity(customer); var orderLine = OrderLineFactory.CreateValidEntity(order, article); article.OrderLines.Add(orderLine); productToAdd.Articles.Add(article); //Setup ArticleRepository var articleRepositoryMock = new Mock <IArticleRepository>(); articleRepositoryMock.Setup(ir => ir.Get(It.IsAny <Guid>(), It.IsAny <ArticleIncludes>())).Returns(article); articleRepositoryMock.Setup(rir => rir.Remove(It.IsAny <Guid>())); //Setup UnitOfWork var unitOfWorkMock = new Mock <IUnitOfWork>(); unitOfWorkMock.Setup(uow => uow.Articles).Returns(articleRepositoryMock.Object); unitOfWorkMock.Setup(uow => uow.Complete()).Returns(1); var articleService = new ArticleService(unitOfWorkMock.Object); //Act var result = articleService.Remove(productToAdd.Id); //Assert Assert.IsTrue(result); }
public override ActionResult Index() { var domainProducts = this.Repository.GetAll(); var viewModelProducts = ProductFactory.CreateProductModelList(domainProducts, this._categoryRepository); return(View(viewModelProducts)); }
public List <Product> GetProductJoinProductTypeAndCompanyById(int lower, int upper) { MySqlConnection conn = Connect(); try { conn.Open(); string sql = "SELECT * " + "FROM product " + "JOIN producttype ON producttype.productTypeId = product.productTypeId " + "JOIN company ON company.CompanyId = product.CompanyId " + "WHERE product.ProductId BETWEEN " + lower + " AND " + upper; MySqlCommand cmd = new MySqlCommand(sql, conn); MySqlDataReader rdr = cmd.ExecuteReader(); List <Product> products = new List <Product>(); while (rdr.Read()) { products.Add(ProductFactory.Create(rdr)); } return(products); } catch (Exception e) { Console.WriteLine(e.ToString()); return(null); } finally { conn.Close(); } }
public void Remove_Deletes_Product() { var databaseName = Guid.NewGuid().ToString(); Guid productId; using (var context = DbContextFactory.CreateInstance(databaseName)) { //Arrange var productToAdd = ProductFactory.CreateValidEntity(); context.Products.Add(productToAdd); context.SaveChanges(); productId = productToAdd.Id; } using (var context = DbContextFactory.CreateInstance(databaseName)) { //Act var productRepository = new ProductRepository(context); productRepository.Remove(productId); context.SaveChanges(); var product = productRepository.Get(productId); //Assert Assert.IsNull(product); } }
public Product GetProductById(int id) { MySqlConnection conn = Connect(); try { conn.Open(); string sql = "SELECT * FROM product WHERE ProductId = " + id; MySqlCommand cmd = new MySqlCommand(sql, conn); MySqlDataReader rdr = cmd.ExecuteReader(); rdr.Read(); Product product = ProductFactory.Create(rdr); return(product); } catch (Exception e) { Console.WriteLine(e.ToString()); return(null); } finally { conn.Close(); } }
public List <Product> GetProductJoinProductTypeAndCompanyById(int lower, int upper) { try { var db = dbClient.GetDatabase(database); var collection = db.GetCollection <BsonDocument>("Product"); var builder = Builders <BsonDocument> .Filter; var filter = builder.Gte("ProductId", lower) & builder.Lte("ProductId", upper); var aggregation = collection.Aggregate() .Lookup("ProductType", "productTypeId", "ProductTypeId", "ProductType_object") .Lookup("Company", "CompanyId", "CompanyId", "Company_object") .Match(filter) ; var documents = aggregation.ToList(); List <Product> products = new List <Product>(); for (int i = 0; i < documents.Count; i++) { products.Add(ProductFactory.Create(documents[i])); } return(products); } catch (Exception e) { Console.WriteLine(e.ToString()); return(null); } }
public Product GetProductJoinProductTypeAndCompanyById(int id) { MySqlConnection conn = Connect(); try { conn.Open(); string sql = "SELECT * " + "FROM product " + "JOIN producttype ON producttype.productTypeId = product.productTypeId " + "JOIN company ON company.CompanyId = product.CompanyId " + "WHERE ProductId = " + id; MySqlCommand cmd = new MySqlCommand(sql, conn); MySqlDataReader rdr = cmd.ExecuteReader(); rdr.Read(); Product product = ProductFactory.Create(rdr); return(product); } catch (Exception e) { Console.WriteLine(e.ToString()); return(null); } finally { conn.Close(); } }
public void CreateProduct_WhenNoCurrentCategory_CreatesValidModel() { var name = "new product"; var categoryName = "category"; var category = new Category { Name = categoryName }; var description = "this is a brand new product"; var product = new ProductDto { Name = name, Description = description, Category = categoryName }; var mockContext = new Mock <DALContext>(); mockContext.Setup(x => x.GetCategoryByName(categoryName)).Returns((Category)null); var model = ProductFactory.CreateProduct(product, mockContext.Object); Assert.NotNull(model); Assert.Equal(name, model.Name); Assert.Equal(description, model.Description); Assert.Equal(categoryName, model.Category.Name); }
private void LoadListData() { string searchcid = this.ddlSearchCategorys.SelectedValue; string searchkw = this.txtSearchKeyword.Text.Trim(); string whereSql = string.Empty; if (searchcid != "0") { whereSql += " categoryid=" + searchcid; } if (searchkw != string.Empty && whereSql != string.Empty) { whereSql += " and productname like '%" + searchkw + "%' "; } else if (searchkw != string.Empty) { whereSql += " productname like '%" + searchkw + "%' "; } if (whereSql != string.Empty) { whereSql = " where" + whereSql; } this.dgProductList.DataSource = ProductFactory.GetList(whereSql); this.dgProductList.DataBind(); this.chkSelectAll.Attributes.Add("onclick", "javascript:SelectAll(this);"); this.btnBatchDelete.Attributes.Add("onclick", "return CheckDeleteHandle(this);"); }
public StorageMaster() { this.storageRegistry = new Dictionary <string, Storage>(); this.productsPool = new Dictionary <string, Stack <Product> >(); this.productFactory = new ProductFactory(); this.storageFactory = new StorageFactory(); }
public ProductSearchResponse GetAllProducts() { //Added attribute level routing IProductManager productManager = ProductFactory.GetProductManager(); return(productManager.GetAllProducts()); }
public Manager() { this.products = new Dictionary <string, Stack <Product> >(); this.storages = new Dictionary <string, Storage>(); this.ProductFactory = new ProductFactory(); this.storageFactory = new StorageFactory(); }
public void DeleteProduct(int productId) { //404 error still working IProductManager productManager = ProductFactory.GetProductManager(); productManager.DeleteProducts(productId); }
public ProductSqlRepositoryFixure() { // Fixture setup var fixture = new Fixture() .Customize(new AutoMoqCustomization()); mockProduct = fixture.Freeze<Product>(); mockProducts = fixture.Freeze<IEnumerable<Product>>(); IFactory<IProduct> productFactory = new ProductFactory(); ISqlCommandFactory commandFactory = new SqlCommandFactory(); ISqlDbInstance db = new MockSqlDbInstance(mockProduct, mockProducts); productRepo = new ProductSqlRepository(productFactory, db, commandFactory); }
/// <summary> /// Монтажная рама /// </summary> /// <param name="width">The width </param> /// <param name="lenght">The lenght </param> /// <param name="typeOfMf">The type of mf.</param> /// <param name="frameOffset">The frame offset.</param> /// <param name="material">The material.</param> /// <returns></returns> public MontageFrame(string type, string width, string lenght, string frameOffset, ProductFactory.Material material) { if (!ConvertToInt(new[] { width, lenght })) throw new Exception("Недопустимі розміри"); Type = type; Width = width; Lenght = lenght; FrameOffset = frameOffset; Material = material; addMatName = ""; if (material.Value != "1800" & material.Thikness == "2") { addMatName = "HK"; } #region Проверка введенных значений и открытие сборки typeOfMfs = "-0" + type; if (type == "0") { typeOfMfs = ""; } // Тип рымы internalCrossbeam = false; // Погашение внутренней поперечной балки internalLongitudinalBeam = false; // Погашение внутренней продольной балки var frameOffcetStr = ""; switch (type) { case "1": internalCrossbeam = true; break; case "2": internalLongitudinalBeam = true; break; case "3": internalCrossbeam = true; frameOffcetStr = "-" + frameOffset; break; } ModelName = $"10-{material.Thikness}{addMatName}-{width}-{lenght}{typeOfMfs}{frameOffcetStr}.SLDASM"; ModelPath = $@"{destRootFolder}\{DestinationFolder}\{ModelName}"; Place = GetPlace(); }
public ProductNoSqlRepositoryRegressionFixture() { // Fixture setup var fixture = new Fixture() .Customize(new AutoMoqCustomization()); mockProduct = fixture.Freeze<Product>(); mockProducts = fixture.Freeze<IEnumerable<Product>>(); IFactory<IProduct> productFactory = new ProductFactory(); ICouchbaseClient db = new CouchbaseClient(); ILocale locale = fixture.Freeze<DefaultLocale>(); IRestClient restClient = new RestClient(); productRepo = new ProductNoSqlRepository(productFactory, db, locale, restClient, "http://localhost:9200/unittests/_search"); }
internal static void AddMaterial(ProductFactory.Material material, string newName) { try { VentsMatdll(new[] { material.Value, material.Thikness, material.Name, material.Code }, null, newName); } catch (Exception e) { MessageBox.Show(e.Message); } }