public ProductEntry convertToModel(bool includeIdentity) { var cat = new ProductEntry(); dynamic _log = Newtonsoft.Json.JsonConvert.DeserializeObject(this.JsonLog); if (PropertyExists(_log, "ID")) { if (includeIdentity) { cat.ID = _log.ID; } } if (PropertyExists(_log, "CategoryId")) { cat.CategoryId = _log.CategoryId; } if (PropertyExists(_log, "Name")) { cat.Name = _log.Name; } if (PropertyExists(_log, "Description")) { cat.Description = _log.Description; } if (PropertyExists(_log, "Image")) { cat.Image = _log.Image; } return(cat); }
private void btnAdd_Click(object sender, EventArgs e) { if (txtUnit.Text.Trim() == "" || ControlValidation.IsReserveWord(txtUnit.Text.Trim().ToLower())) { lblError.Text = "Please Enter a valid Unit..."; lblError.ForeColor = Color.Red; } else { var result = AddUnit(); if (result.Result == true) { ProductEntry prodEntry = (ProductEntry)Owner.ActiveControl; prodEntry.BindUnits(); lblError.Text = result.Message; lblError.ForeColor = Color.Green; } else { lblError.Text = result.Message; lblError.ForeColor = Color.Red; } } }
public void Add(ProductEntry productEntry) { productEntry.Valid(); using (var session = NHibernateSessionFactory.OpenSession()) { try { var transaction = session.BeginTransaction(); session.Save(productEntry); var product = productEntry.Product; foreach (var variation in product.GetVariationUpdatedByProductEntryQuantity(productEntry.ProductEntryItems)) { session.Update(variation); } session.Flush(); transaction.Commit(); } catch (ConstraintViolationException ex) { throw new RepositoryException($"Entrada de produto '{productEntry.Code}' já existe.", ex); } catch (Exception ex) { throw new RepositoryException($"Não foi possível adicionar a entrada de produto '{productEntry.Code}': {ex.Message}", ex); } } }
private void bunifuThinButton21_Click(object sender, EventArgs e) { if (!(searchLookUpProvider.Text != "" && searchLookUpProvider.Text != "Fornecedor")) { MessageBox.Show("Selecione um fornecedor..!"); } else if (stock != null) { ProductEntry productEntry; decimal qdade = decimal.Parse(txtQdade.Text); stock.Quantidade += qdade; stock.UltimoPreco = decimal.Parse(txtPreco.Text); stock.PrecoMedio = (stock.PrecoMedio + stock.UltimoPreco) / 2; int idProvider = Convert.ToInt16(searchLookUpProvider.Properties.View.GetFocusedRowCellValue("Id").ToString()); string idPaymentWay = _paymentController.ListALL()[cmbPayment.SelectedIndex].Id.ToString(); int idAccounSystem = _currentAccountController.ListALLAsNoTracking()[cmbAccount.SelectedIndex].Id; CurrentAccountSystem account = _currentAccountController.getOne(idAccounSystem); account.Saldo -= decimal.Parse(txtTotal.Text); productEntry = new ProductEntry() { FornecedorId = idProvider, ProdutoId = stock.ProdutoId, Taxa = decimal.Parse(txtTaxa.Text), Preco = stock.UltimoPreco, Quantidade = qdade, PrecoTotal = stock.UltimoPreco * qdade, ContaDebitadaId = idAccounSystem, FormaPagamentoId = idPaymentWay, }; if (cbAplicaNovoPreco.Checked) { int pEntrePrecos = int.Parse(txtPentrePs.Text); stock.Produto.Preco1 = decimal.Parse(txtPrecoVenda.Text); stock.Produto.Preco2 = stock.Produto.Preco1 + (stock.Produto.Preco1 * pEntrePrecos / 100); stock.Produto.Preco3 = stock.Produto.Preco2 + (stock.Produto.Preco2 * pEntrePrecos / 100); } if (_stockController.update(stock) == 0 || _productEntry.insert(productEntry) == 0 || _currentAccountController.update(account) == 0) { MessageBox.Show("Houve um erro ao atualizar stock"); } else { searchLUpProduct.Text = ""; cleanFields(); Methods.playSuccess(); toGridEntryProducts(); } } else { MessageBox.Show("Selecione um Produto..!"); } }
/// <summary> /// /// </summary> /// <param name="productEntery"></param> public void UpdateProductEntry(ProductEntery productEntery) { ProductEntry currentEntity = _context.ProductEntry.Find(productEntery.Id); ProductEntry newEntity = Mapper.MapProductEnteries(productEntery); _context.Entry(currentEntity).CurrentValues.SetValues(newEntity); }
public static List <SimpleArticle> GetSimpleArticles() { List <SimpleArticle> simpleArticles = new List <SimpleArticle>(); Catalogue catalogue = InterplayStorage.Catalogues.Where(cat => cat.name == InterplayStorage.SelectedCatalog.name).FirstOrDefault(); if (catalogue != null) { ProductEntry productEntry = catalogue.productEntries.Where(pe => pe.referenceProductId == InterplayStorage.SelectedProductEntry.referenceProductId).FirstOrDefault(); if (productEntry != null && productEntry.articleEntries != null) { foreach (ArticleEntry article in productEntry.articleEntries) { if (article.simpleArticles != null && article.simpleArticles.Count > 0) { simpleArticles.AddRange(article.simpleArticles); } else { simpleArticles.Add(new SimpleArticle { name = article.name, referenceArticleId = article.referenceArticleId }); } } } } return(simpleArticles); }
public void ValidateProdutEntry_ProductEntryIsNull_ThrowException() { ProductEntry productEntry = null; var ex = Assert.Throws <ArgumentException>(() => productEntry.Valid()); Assert.That(ex.Message, Is.EqualTo("Entrada de produto não pode estar nula ou vazia.")); }
public void ValidateProductEntry_SupplierIsNull_ThrowException() { var productEntry = new ProductEntry { Code = "CODE_1", }; var ex = Assert.Throws <ArgumentException>(() => productEntry.Valid()); Assert.That(ex.Message, Is.EqualTo("Entrada de produto sem fornecedor.")); }
public void ValidateProductEntry_ProductIsNull_ThrowException() { var productEntry = new ProductEntry { Code = "CODE_1", Supplier = new Supplier { Name = "SUPPLIER_1" } }; var ex = Assert.Throws <ArgumentException>(() => productEntry.Valid()); Assert.That(ex.Message, Is.EqualTo("Entrada de produto sem produto.")); }
public void OnAddedNewProductEntry() { try { if (!ValidateProductEntry()) { return; } var product = this.view.Product; var supplier = this.view.Supplier; var annotation = this.view.Annotation; var date = this.view.Date; var productEntryItems = new List <ProductEntryItem>(); var productEntry = new ProductEntry { Annotation = annotation, Code = Guid.NewGuid().ToString(), Product = product, Date = date, Supplier = supplier, ProductEntryItems = productEntryItems, }; foreach (var item in this.view.ProductEntryItems) { var productEntryItem = new ProductEntryItem { ProductEntry = productEntry, Quantity = item.Quantity, Variation = product.GetProductVariation(item.Gender, item.Color, item.Size) }; productEntryItems.Add(productEntryItem); } this.productEntryRepository.Add(productEntry); this.ClearProductInfoInView(); this.view.HasUnsavedChanges = false; this.view.InfoMessage = $"Entrada adicionada com sucesso!!"; } catch (Exception ex) { LOGGER.Error($"Error while salved product entry: {ex.ToString()}"); this.view.ErrorMessage = $"Erro ao adicionar esta entrada: {ex.Message}"; } }
private gbase_product CreateGbaseInformationEntry(ProductEntry entry) { var flag = InventoryItemFlag.GBASE; if (entry.IsDraft) { flag |= InventoryItemFlag.DRAFT; } return(new gbase_product() { flags = (int)flag, expirydate = entry.ExpirationDate, externalid = entry.Id.AbsoluteUri, externallink = URLFromEntry(entry) }); }
public void Delete(ProductEntry productEntry) { productEntry.Valid(); using (var session = NHibernateSessionFactory.OpenSession()) { try { session.Delete(productEntry); session.Flush(); } catch (Exception ex) { throw new RepositoryException($"Não foi possível deletar a entrada de produto '{productEntry.Code}': {ex.Message}", ex); } } }
public async Task <ActionResult <string> > PutProductEntry(int id, ProductEntry editObj) { if (id != editObj.ProductEntryId) { return(BadRequest()); } double sTotal = 0; sTotal = Convert.ToDouble((editObj.Quantity * editObj.UnitPrice) - editObj.Discount_Percentage); string msg = null; ProductEntry Pentry = new ProductEntry() { ProductEntryId = 0, VoucherNumber = editObj.VoucherNumber, Quantity = editObj.Quantity, UnitPrice = editObj.UnitPrice, Discount_Percentage = editObj.Discount_Percentage, SubTotalCost = sTotal, DateOfEntry = DateTime.Now, CategoryId = editObj.CategoryId, EmployeeId = editObj.EmployeeId }; _db.Entry(Pentry).State = EntityState.Modified; int response = await _db.SaveChangesAsync(); if (response > 0) { msg = "Updated Record Successfully!!"; } else { msg = "Invalid Record can not Updated"; } return(msg); }
public void Update(ProductEntry productEntry) { productEntry.Valid(); using (var session = NHibernateSessionFactory.OpenSession()) { try { session.Update(productEntry); session.Flush(); } catch (ConstraintViolationException ex) { throw new RepositoryException($"Entrada de produto '{productEntry.Code}' já existe.", ex); } catch (Exception ex) { throw new RepositoryException($"Não foi possível adicionar a entrada de produto '{productEntry.Code}': {ex.Message}", ex); } } }
public static ProductEntry CreateProductEntryValid() { var productRepository = new ProductRepository(); var product = productRepository.GetAll().First(); var items = new List <ProductEntryItem>(); var productEntry = new ProductEntry { Code = "CODE_2", Date = DateTime.Now, Supplier = new Supplier { ID = 1, Name = "FORNECEDOR_1" }, Product = product, ProductEntryItems = items }; items.Add(new ProductEntryItem { Quantity = 2, Variation = product.Variations[0], ProductEntry = productEntry }); return(productEntry); }
private void btnAdd_Click(object sender, EventArgs e) { if (txtProductType.Text.Trim() == "" || ControlValidation.IsReserveWord(txtProductType.Text.Trim().ToLower())) { lblError.Text = "Please Enter a valid Item Type..."; lblError.ForeColor = Color.Red; } else { var result = AddNewType(); if (result.Result == true) { /* ProductEntry obj = null; * foreach( Object objj in Owner.Controls) * { * var test = (Panel)objj; * if (test.AccessibilityObject.Name == "Product Entry"){ * obj = (ProductEntry)test.AccessibilityObject; * } * } * //Owner.Controls.*/ ProductEntry prodEntry = (ProductEntry)Owner.ActiveControl; prodEntry.BindProductType(); txtProductType.Text = ""; lblError.Text = result.Message; lblError.ForeColor = Color.Green; } else { lblError.Text = result.Message; lblError.ForeColor = Color.Red; } } }
public async Task <ActionResult <string> > PostProductEntry(ProductEntry obj) { double sTotal = 0; sTotal = Convert.ToDouble((obj.Quantity * obj.UnitPrice) - obj.Discount_Percentage); string msg = null; ProductEntry Pentry = new ProductEntry() { ProductEntryId = 0, VoucherNumber = obj.VoucherNumber, Quantity = obj.Quantity, UnitPrice = obj.UnitPrice, Discount_Percentage = obj.Discount_Percentage, SubTotalCost = sTotal, DateOfEntry = DateTime.Now, CategoryId = obj.CategoryId, EmployeeId = obj.EmployeeId }; _db.ProductEntry.Add(Pentry); int response = await _db.SaveChangesAsync(); if (response > 0) { msg = "Inserted Record Successfully!!"; } else { msg = "Invalid Record can not Saved"; } return(msg); }
private product CreateProductFromEntry(ProductEntry entry) { // do this check assuming products all must have the same target country if (exchangerate == null) { exchangerate = 1; var targetcountry = entry.TargetCountry; switch (targetcountry) { case "AU": // australia if (currency.code != "AUD") { exchangerate = CurrencyConverter.Instance.GetRate("AUD", currency.code); } break; case "CN": // china if (currency.code != "CNY") { exchangerate = CurrencyConverter.Instance.GetRate("CNY", currency.code); } break; case "FR": // france if (currency.code != "EUR") { exchangerate = CurrencyConverter.Instance.GetRate("EUR", currency.code); } break; case "DE": // germany if (currency.code != "EUR") { exchangerate = CurrencyConverter.Instance.GetRate("EUR", currency.code); } break; case "IT": // italy if (currency.code != "EUR") { exchangerate = CurrencyConverter.Instance.GetRate("EUR", currency.code); } break; case "JP": // japan if (currency.code != "JPY") { exchangerate = CurrencyConverter.Instance.GetRate("JPY", currency.code); } break; case "NL": // netherlands if (currency.code != "EUR") { exchangerate = CurrencyConverter.Instance.GetRate("EUR", currency.code); } break; case "ES": // spain if (currency.code != "EUR") { exchangerate = CurrencyConverter.Instance.GetRate("EUR", currency.code); } break; case "GB": // united kingdom if (currency.code != "GDP") { exchangerate = CurrencyConverter.Instance.GetRate("GBP", currency.code); } break; case "US": // united states if (currency.code != "USD") { exchangerate = CurrencyConverter.Instance.GetRate("USD", currency.code); } break; default: throw new NotImplementedException(string.Format("Unknown country {0}", targetcountry)); break; } } return(new product() { flags = (int)ProductFlag.NONE, title = entry.Title.Text, details = entry.Content.Content, sellingPrice = Convert.ToDecimal(entry.Price.Value) * exchangerate, subdomainid = subdomainid }); }
public int update(ProductEntry productEntry) { return(_prodEntryRep.update(productEntry)); }
public int delete(ProductEntry productEntry) { return(_prodEntryRep.remove(productEntry)); }
public int insert(ProductEntry productEntry) { return(_prodEntryRep.insert(productEntry)); }
public override void StartSynchronisation(bool?upload) { // pull items var gbase = new GoogleBaseExporter(subdomainid, hostName, sessionid); gbase.GetAllProducts(); using (var repository = new TradelrRepository()) { // create network location var inventoryLocation = new inventoryLocation { name = LOCATIONNAME_GBASE, subdomain = subdomainid, lastUpdate = DateTime.UtcNow }; locationid = repository.AddInventoryLocation(inventoryLocation, subdomainid); // init some settings locationid = repository.GetInventoryLocation(LOCATIONNAME_GBASE, subdomainid).id; currency = repository.GetSubDomain(subdomainid).currency.ToCurrency(); var products = repository.GetProducts(subdomainid); foreach (var entry in gbase.entries) { ProductEntry entry1 = entry; var oldTypeEntry = products.SingleOrDefault(x => x.gbaseID == entry1.Id.AbsoluteUri); if (oldTypeEntry != null) { // old type entry exists // remove id oldTypeEntry.gbaseID = null; // create gbase entry, don't need to create a variant since one would already exist oldTypeEntry.gbase_product = CreateGbaseInformationEntry(entry); } else { var newtypeEntry = products.Where(x => x.gbase_product.externalid == entry1.Id.AbsoluteUri).Select( x => x.gbase_product).SingleOrDefault(); if (newtypeEntry != null) { // new type entry exists // update status newtypeEntry.expirydate = entry.ExpirationDate; if (entry.IsDraft) { newtypeEntry.flags |= (int)InventoryItemFlag.DRAFT; } else { newtypeEntry.flags &= ~(int)InventoryItemFlag.DRAFT; } } else { // entry does not exist // create and add entry to tradelr var p = CreateProductFromEntry(entry); // create variant var variants = new List <product_variant>(); var variant = new product_variant() { sku = string.Concat("GBASE", entry.Id.AbsoluteUri.Substring( entry.Id.AbsoluteUri.LastIndexOf('/') + 1)) }; variants.Add(variant); // add gbase info p.gbase_product = CreateGbaseInformationEntry(entry); p.product_variants.AddRange(variants); var pinfo = new ProductInfo() { p = p }; repository.AddProduct(pinfo, subdomainid); // images foreach (var link in entry.AdditionalImageLinks) { var image = link.Value.ReadAndSaveProductImageFromUrl(subdomainid, sessionid, p.id); p.thumb = image.id; } } } } // upload to google base for each entry that does not have a special entry if (upload.HasValue && upload.Value) { var newproducts = repository.GetProducts(subdomainid).Where( x => !x.gbase.HasValue && (x.flags & (int)ProductFlag.ARCHIVED) == 0); foreach (var p in newproducts) { var gb = new GoogleBaseExporter(subdomainid, hostName, sessionid); gb.InitValues(p); #if !DEBUG IEnumerable <Photo> productPhotos = repository.GetImages(PhotoType.PRODUCT, p.id).ToModel(Imgsize.LARGE); gb.AddProductImages(productPhotos); #endif var worker = new GoogleBaseWorker(gb); new Thread(worker.Post).Start(); } } // save repository.Save(); } }
public void AddProductEntery(ProductEntery product) { ProductEntry entity = Mapper.MapProductEnteries(product); _context.Add(entity); }
private static void RunSample(string username, string password, string accountId) { // Connect to the service ContentForShoppingService service = new ContentForShoppingService("ContentForShopping-Sample"); service.setUserCredentials(username, password); // Retrieve the list of all existing products string projection = "schema"; ProductQuery query = new ProductQuery(projection, accountId); ProductFeed feed = service.Query(query); // Display title and id for each product Console.WriteLine("Listing all products"); foreach (ProductEntry p in feed.Entries) { Console.WriteLine("Product: " + p.Title.Text + " (" + p.ProductId + ")"); } // Create a new product ProductEntry entry = new ProductEntry(); entry.Title.Text = "Wool sweater"; AtomContent c = new AtomContent(); c.Content = "Comfortable and soft, this sweater will keep you warm on those cold winter nights. Red and blue stripes."; entry.Content = c; entry.ProductId = "123457"; entry.Language = "it"; entry.TargetCountry = "US"; entry.ContentLanguage = "en"; entry.Brand = "ACME"; entry.Condition = "new"; entry.Price = new Price("usd", "25"); entry.ProductType = "Clothing & Accessories > Clothing > Outerwear > Sweaters"; entry.Quantity = 3; entry.ShippingWeight = new ShippingWeight("lb", "0.1"); entry.ImageLink = new ImageLink("http://www.example.com/image.jpg"); entry.Availability = "available for order"; entry.Channel = "online"; entry.Gender = "female"; entry.Material = "wool"; entry.Pattern = "Red and blue stripes"; entry.Color = "red"; AtomLink link = new AtomLink(); link.HRef = "http://www.example.com"; link.Rel = "alternate"; link.Type = "text/html"; entry.Links.Add(link); // Shipping rules Shipping s1 = new Shipping(); s1.Country = "US"; s1.Region = "MA"; s1.Service = "Speedy Shipping - Ground"; s1.Price = new ShippingPrice("usd", "5.95"); Shipping s2 = new Shipping(); s2.Country = "US"; s2.Region = "024*"; s2.Service = "Speedy Shipping - Air"; s2.Price = new ShippingPrice("usd", "7.95"); entry.ShippingRules.Add(s1); entry.ShippingRules.Add(s2); // Tax rules Tax t1 = new Tax(); t1.Country = "US"; t1.Region = "CA"; t1.Rate = "8.25"; t1.Ship = true; Tax t2 = new Tax(); t2.Country = "US"; t2.Region = "926*"; t2.Rate = "8.75"; t2.Ship = false; entry.TaxRules.Add(t1); entry.TaxRules.Add(t2); // Additional Image Links AdditionalImageLink il1 = new AdditionalImageLink("http://www.example.com/1.jpg"); entry.AdditionalImageLinks.Add(il1); AdditionalImageLink il2 = new AdditionalImageLink("http://www.example.com/2.jpg"); entry.AdditionalImageLinks.Add(il2); // Add the product to the server feed Console.WriteLine("Inserting product"); ProductEntry inserted = service.Insert(feed, entry); // Update the product we just inserted inserted.Title.Text = "2011 Wool sweater"; Console.WriteLine("Updating product"); ProductEntry updated = service.Update(inserted); // Retrieve the new list of products feed = service.Query(query); // Display title and id for each product Console.WriteLine("Listing all products again"); foreach (ProductEntry p in feed.Entries) { Console.WriteLine("Product: " + p.Title.Text + " (" + p.ProductId + ")"); } // Delete the item we inserted and updated Console.WriteLine("Deleting product"); service.Delete(updated); }
private GoogleBaseExporter(string hostname) : base(hostname) { entry = new ProductEntry(); entries = new List<ProductEntry>(); }
public static void SetSelectedProductEntry(ProductEntry selectedProduct) { SelectedProductEntry = selectedProduct; }
public async Task <ProductEntryDto> Create(Guid userId, ProductEntryForCreationDto productEntryForCreationDto) { try { if (productEntryForCreationDto.IsEntry) { var vendor = await _vendorRepository.GetById(productEntryForCreationDto.VendorId.Value); if (vendor == null) { throw new KeyNotFoundException($"Vendor with id: {productEntryForCreationDto.VendorId.Value} not found."); } } ProductEntry productEntry = new ProductEntry() { Date = productEntryForCreationDto.Date.ToLocalTime(), IsEntry = productEntryForCreationDto.IsEntry, VendorId = productEntryForCreationDto.VendorId, Cost = productEntryForCreationDto.Cost, PaymentType = productEntryForCreationDto.PaymentType, Observations = productEntryForCreationDto.Observations, CreatedBy = userId }; productEntry = await _productEntryRepository.Add(productEntry); //ProductEntryLines foreach (var pelDto in productEntryForCreationDto.ProductEntryLines) { var product = await _productRepository.GetById(pelDto.ProductId); if (product == null) { throw new KeyNotFoundException($"Product with id: {pelDto.ProductId} not found."); } var productEntryLine = new ProductEntryLine() { Quantity = pelDto.Quantity, ProductId = pelDto.ProductId, ProductEntryId = productEntry.Id, CreatedBy = userId }; productEntryLine = await _productEntryLineRepository.Add(productEntryLine); productEntry.ProductEntryLines.Add(productEntryLine); product.Stock += pelDto.Quantity * (productEntry.IsEntry ? 1 : -1); await _productRepository.Update(product); } await _productEntryRepository.CommitAsync(); await _productEntryLineRepository.CommitAsync(); await _productRepository.CommitAsync(); var productEntryDto = _mapper.Map <ProductEntry, ProductEntryDto>(productEntry); return(productEntryDto); } catch (Exception e) { throw e; } }
private void btnitementry_Click(object sender, EventArgs e) { ProductEntry productEntry = new ProductEntry(); productEntry.Show(); }
public static string URLFromEntry(ProductEntry entry) { return(entry.Links.Where(x => x.Type == "text/html").Select(x => x.AbsoluteUri).SingleOrDefault()); }