private static bool SameMetaInfo(PriceItem priceItem, product product) { if (string.IsNullOrWhiteSpace(priceItem.Name)) { return(true); } if (product.meta_title == null || !product.meta_title.Any() || !product.meta_title[0].Value.Equals(priceItem.Name, StringComparison.OrdinalIgnoreCase)) { return(false); } if (product.meta_description == null || !product.meta_description.Any() || !product.meta_description[0].Value.Equals($"Купить {priceItem.Name} дёшево с доставкой", StringComparison.OrdinalIgnoreCase)) { return(false); } if (product.meta_keywords == null || !product.meta_keywords.Any()) { return(false); } if (!product.meta_keywords.Exists(s => s.Value.Equals($"Купить {priceItem.Name} дёшево с доставкой", StringComparison.OrdinalIgnoreCase))) { return(false); } return(true); }
public void BasicUsage() { var reader = new CsvPriceReader("stock1.csv"); PriceItem price = null; int count = 0; bool foundStopper = false; reader.NewPrice += (sender, e) => { if (e.NewPrice == null) { foundStopper = true; } else { TestOutput.WriteLine($"{e.NewPrice.Date:s} {e.NewPrice.Last,10:n2} {e.NewPrice.Bid,10:n2} {e.NewPrice.Offer,10:n2}"); price = e.NewPrice; count++; } }; reader.Start(); Assert.Equal(4, count); Assert.True(foundStopper); }
public void Func3([FromBody] PriceItem priceItem) { string txt = JsonConvert.SerializeObject(priceItem); var fileName = Path.Combine(HttpContext.Current.Server.MapPath(@"\"), @"assets\item22.json"); File.WriteAllText(fileName, txt); }
public async Task FillOptions(PriceItem priceItem, product product) { foreach (var assort in priceItem.Assort) { await GetOrCreateCombination(product, assort); } }
public List <PriceItem> GetHotelActiveCurrency(string hotelCode, decimal?price) { List <PriceItem> list = new List <PriceItem>(); PriceItem item = null; IList <HotelCurrencyItem> currencies = plannerEventRepo.GetHotelActiveCurrency(hotelCode); if (currencies == null || !currencies.Any() || !price.HasValue) { item = new PriceItem { CurrencyCode = "USD", CurrencyCultureID = "en-US", CurrencySymbol = "$", CurrencySymbolPosition = "Left", Price = price }; list.Add(item); } else { foreach (var c in currencies) { item = new PriceItem { CurrencyCode = c.CurrencyCode, CurrencyCultureID = c.CurrencyCultureID, CurrencySymbol = c.CurrencySymbol, CurrencySymbolPosition = c.CurrencySymbolPosition, Price = price * c.USD_to_Rate }; list.Add(item); } } return(list); }
public async Task <product_supplier> GetProductSupplierValue(PriceItem priceItem, product product, supplier supplierFeature) { var filter = new Dictionary <string, string> { { "id_product", product.id.Value.ToString(CultureInfo.InvariantCulture) } }; var supplier = (await _apiFactory.ProductSupplierFactory.GetByFilter(filter, null, null)).FirstOrDefault(); if (supplier != null) { return(supplier); } supplier = new product_supplier { id_currency = 1, id_product = product.id, id_product_attribute = 0, id_supplier = supplierFeature.id, product_supplier_reference = priceItem.SupplierReference, product_supplier_price_te = Convert.ToDecimal(priceItem.WholesalePrice) }; supplier = await _apiFactory.ProductSupplierFactory.Add(supplier); return(supplier); }
private async Task UpdateMetaInfo(PriceItem item, product product) { if (!SameMetaInfo(item, product)) { product = ProductsMapper.FillMetaInfo(item, product); if (product.on_sale == 1) { var specialPriceRule = await GetSpecialPriceRule(product); if (specialPriceRule != null) { if (specialPriceRule.reduction_type != "percentage") { throw new NotImplementedException(); } product.price = product.price / specialPriceRule.reduction; } } Log.Debug("Updating meta info. Reference: {0}", item.Reference); await _apiFactory.ProductFactory.Update(product); Log.Information("Meta info updated. Reference: {0}", item.Reference); } }
public void Get_email_price_date_test() { //триггер на Обновлении PriceItem - PriceItemBeforeUpdate, постоянно обновляет дату текущим временем, поэтому ноужно вставлять "просроченную" дату. _email = Guid.NewGuid().ToString().Replace("-", string.Empty) + "@analit.net"; _supplier = DataMother.CreateSupplier(); _supplier.ContactGroupOwner.Group(ContactGroupType.ClientManagers).AddContact(ContactType.Email, _email); Save(_supplier); var item = _supplier.Prices.First().Costs.First().PriceItem; var itemCosts = _supplier.Prices.First().Costs.First(); var newpPriceItem = new PriceItem() { DownloadLogs = item.DownloadLogs, FormRule = item.FormRule, PriceDate = DateTime.MinValue, Source = item.Source }; itemCosts.PriceItem = newpPriceItem; Save(itemCosts); _defaults = session.Query <DefaultValues>().First(); _service = new NotificationService(session, _defaults); _client = DataMother.TestClient(); Flush(); var emails = _service.GetEmailsForNotification(_client); Assert.IsFalse(emails.Contains(_email)); }
private void UpdateProductPriceAndActivity(PriceItem item, product product) { // price of onSale products is updated by special file if (product.on_sale != 0 || product.active == Convert.ToInt32(item.Active) && product.price == Convert.ToDecimal(item.RetailPrice) && product.wholesale_price == Convert.ToDecimal(item.WholesalePrice)) { return; } var prevPrice = product.price; var prevWholesalePrice = product.wholesale_price; product.active = Convert.ToInt32(item.Active); product.price = Convert.ToDecimal(item.RetailPrice); product.wholesale_price = Convert.ToDecimal(item.WholesalePrice); Log.Debug("Updating price. Reference: {0}", item.Reference); _apiFactory.ProductFactory.Update(product); if (prevPrice != product.price) { Log.Information("Price changed from {prevPrice} to {price}. Reference: {reference}", prevPrice.ToString("##.###"), product.price.ToString("##.###"), item.Reference); } if (prevWholesalePrice != product.wholesale_price) { Log.Information("Wholesale price changed from {prevPrice} to {price}. Reference: {reference}", prevWholesalePrice.ToString("##.###"), product.wholesale_price.ToString("##.###"), item.Reference); } }
protected virtual PriceItem GetPriceItemFromReader(IDataReader reader) { PriceItem priceItem = new PriceItem() { Id = (int)reader["Id"], PartnerId = (int)reader["PartnerId"], SectionId = (int)reader["SectionId"], ItemState = (ItemState)reader["ItemState"], Name = reader["Name"].ToString(), Created = (DateTime)reader["Created"] }; if (reader["UnitType"] != DBNull.Value) { priceItem.UnitType = reader["UnitType"].ToString(); } if (reader["RetailPrice"] != DBNull.Value) { priceItem.RetailPrice = (decimal)reader["RetailPrice"]; } if (reader["SmallWholeSalePrice"] != DBNull.Value) { priceItem.RetailPrice = (decimal)reader["SmallWholeSalePrice"]; } if (reader["LargeWholeSalePrice"] != DBNull.Value) { priceItem.RetailPrice = (decimal)reader["LargeWholeSalePrice"]; } return(priceItem); }
internal static product Create(PriceItem item) { var result = new product { active = Convert.ToInt32(item.Active), ean13 = item.Ean13, reference = item.Reference, supplier_reference = item.SupplierReference, price = Convert.ToDecimal(item.RetailPrice), wholesale_price = Convert.ToDecimal(item.WholesalePrice), show_price = 1, redirect_type = "404", id_shop_default = 1, available_for_order = 1, advanced_stock_management = 0, id_tax_rules_group = 1, minimal_quantity = 1, weight = !string.IsNullOrWhiteSpace(item.Weight) ? Convert.ToDecimal(item.Weight) : 0, associations = new AssociationsProduct(), name = new List <language> { new language(1, item.Name) }, description = new List <language> { new language(1, item.Description) }, description_short = new List <language> { new language(1, item.ShortDescription) } }; return(result); }
public IHttpActionResult PutPriceItem(int id, PriceItem priceItem) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != priceItem.Id) { return(BadRequest()); } try { unitOfWork.PriceItems.Update(priceItem); unitOfWork.Complete(); } catch (DbUpdateConcurrencyException) { if (!PriceItemExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public List <PriceItem> CreatePriceItem(PriceItem priceItem) { priceItemsService.Add(priceItem); List <PriceItem> priceItems = priceItemsService.GetAll(); return(priceItems); }
private void spawnPrice(List <ValueClass> price) { foreach (ValueClass value_class in price) { PriceItem item = Instantiate(price_item, root); item.init(value_class); } }
public async Task <PriceItem> UpsertAsync(PriceItem price) { using (var conn = await GetOpenConnectionAsync()) { conn.Update <PriceItem>(price); } return(null); }
protected void OnButtonEdit1Clicked(object sender, EventArgs e) { editingItem = pricesTreeView.GetSelectedObject <PriceItem> (); var dlg = new ReferenceRepresentation(new FittingsVM()); dlg.Mode = OrmReferenceMode.Select; dlg.ObjectSelected += Dlg_EditObjectSelected; TabParent.AddSlaveTab(this, dlg); }
public async Task <PriceItem> CreateAsync(PriceItem price) { using (var conn = await GetOpenConnectionAsync()) { price.Id = Guid.NewGuid(); conn.Insert(price); } return(price); }
private async Task UpdatePhotos(PriceItem item, product product) { if (product.id_default_image == null && product.associations.images.Any()) { var imageId = product.associations.images.First().id; Log.Information("Product's default photo is null, setting default photo. Reference: {reference}, ImageId: {id}", item.Reference, imageId); product.id_default_image = imageId; await _apiFactory.ProductFactory.Update(product); } }
private float GetDefaultPrice(PriceItem priceItem) { // 0 means leave supplier recommended price if (_settings.DefaultMultiplicator.Equals(0)) { return(priceItem.RetailPrice); } return(priceItem.WholesalePrice * _settings.DefaultMultiplicator); }
public int AddPriceItem(PriceItem pi) { string str = ""; str = " begin "; if (pi.IsDefault) { str = str + " update EPM_Res_PriceItem set IsDefault = 0,VersionTime = getdate() where IsDefault=1"; } return(publicDbOpClass.ExecSqlString(string.Format(((str + " insert into EPM_Res_PriceItem(PriceItemID,PriceItemName,IsFixed,IsDefault,IsReadonly,IsValid,Owner,VersionTime) values({0},'{1}',0,{2},{3},{4},'000000',getdate())" + " insert into EPM_Res_PriceRelations (VersionCode,ResourceCode,PriceItemID,Price,Owner,VersionTime) ") + " select VersionCode,ResourceCode,{0},0,'000000',getdate() from EPM_Res_Resource " + " insert into EPM_Ration_ItemSynthPrice(ItemCode,VersionCode,PriceItemID,SynthPrice) ") + " select ItemCode,VersionCode,{0},0 from EPM_Ration_PrivateItem" + " end ", new object[] { this.GetNextID(), pi.PriceItemName, pi.IsDefault ? 1 : 0, pi.IsValid ? 1 : 0, pi.IsReadonly ? 1 : 0 }))); }
public int UpdPriceItem(PriceItem pi) { string str = ""; str = " begin "; if (pi.IsDefault) { str = str + " update EPM_Res_PriceItem set IsDefault = 0,VersionTime=getdate() where IsDefault = 1 and PriceItemID <> {3} "; } return(publicDbOpClass.ExecSqlString(string.Format(str + " update EPM_Res_PriceItem set PriceItemName = '{0}',IsDefault={1},IsValid={2},VersionTime=getdate() where PriceItemID = {3} " + " end ", new object[] { pi.PriceItemName, pi.IsDefault ? 1 : 0, pi.IsValid ? 1 : 0, pi.PriceItemID }))); }
public IHttpActionResult GetPriceItem(int id) { PriceItem priceItem = unitOfWork.PriceItems.Get(id); if (priceItem == null) { return(NotFound()); } return(Ok(priceItem)); }
public void SetMaterialPrice(int rawMaterialId, int ownerId, DateTime date, decimal?price) { Argument.Require(rawMaterialId > 0, "Raw material identifier is required."); Argument.Require(ownerId > 0, "Owner identifier is required."); Argument.Require(date > DateTime.MinValue, "Date is required."); Argument.Require(null == price || price.Value >= 0, "Price should be >= 0."); using (var storage = new Storage()) { var priceExtra = storage .RawMaterials .SingleOrDefault(pe => pe.RawMaterialId == rawMaterialId); if (null == priceExtra) { throw new InvalidOperationException($"Raw material with id {rawMaterialId} not found."); } var existingPriceItem = storage .PriceItems .SingleOrDefault(pi => pi.RawMaterialId == rawMaterialId && pi.OwnerId == ownerId && pi.Date == date); if (null != existingPriceItem) { existingPriceItem.Price = price; storage.Update(existingPriceItem); } else { var priceItem = new PriceItem { PriceType = PriceType.RawMaterial, RawMaterialId = rawMaterialId, Date = date, OwnerId = ownerId, Price = price, }; storage.Insert(priceItem); } var products = storage .Products .Where(product => product.ManufacturerId == ownerId && product.RawMaterialId == rawMaterialId) .Select(p => p.ProductId) .ToList(); foreach (var productId in products) { UpdatePriceCache(storage, productId, date); } } }
public IHttpActionResult PostPriceItem(PriceItem priceItem) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } unitOfWork.PriceItems.Add(priceItem); unitOfWork.Complete(); return(CreatedAtRoute("DefaultApi", new { id = priceItem.Id }, priceItem)); }
public IHttpActionResult DeletePriceItem(int id) { PriceItem priceItem = unitOfWork.PriceItems.Get(id); if (priceItem == null) { return(NotFound()); } unitOfWork.PriceItems.Remove(priceItem); unitOfWork.Complete(); return(Ok(priceItem)); }
private void GetListPrices() { for (int i = 0; i < 2; i++) /*editor by trongntn 11-08-2016*/ { PriceItem item = new PriceItem(); item.PriceName = _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("Price") + " " + (i + 1); if (i == 0) { item.IsDefault = true; item.PriceTag = _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("Default Price"); } ListPrices.Add(item); } }
private bool SameBalance(PriceItem item, PriceItem oldItem) { foreach (var assort in item.Assort) { var oldAssort = oldItem.Assort .FirstOrDefault(s => s.Size != null && s.Size.Equals(assort.Size, StringComparison.OrdinalIgnoreCase) && s.Color.Equals(assort.Color, StringComparison.OrdinalIgnoreCase)); if (oldAssort != null && oldAssort.Balance != assort.Balance) { return(false); } } return(true); }
public async Task Update(product product, PriceItem item, PriceType processingPriceType) { await _stockProcessor.UpdateStockValue(item, product); await UpdateMetaInfo(item, product); await UpdatePhotos(item, product); if (processingPriceType == PriceType.Stock || processingPriceType == PriceType.Full) { UpdateProductPriceAndActivity(item, product); } if (processingPriceType == PriceType.Discount) { await UpdateDiscountInfo(item, product); } }
public void NoSeedPrice_GetOnlyNullNewPriceItem() { var reader = new InMemoryPriceReader(); PriceItem price = null; int count = 0; reader.NewPrice += (sender, e) => { price = e.NewPrice; count++; }; reader.Start(); Assert.Equal(1, count); Assert.Null(price); }
public static PriceItem GetPriceItemByPriceItemId(int priceItemId) { PriceItem priceItem = null; string key = "PriceItems_GetPriceItemByPriceItemId_" + priceItemId; if (Cache[key] != null) { priceItem = (PriceItem)Cache[key]; } else { priceItem = DataAccess.PriceItems.GetPriceItemByPriceItemId(priceItemId); CacheData(key, priceItem); } return(priceItem); }
// ���ܼ۸� // ���ҵ�λ��ͬ�ģ�������� // parameters: // prices ��ɵ�һ�۸��ַ������ɵ����顣��δ���й����� // return: // -1 error // 0 succeed public static int TotalPrice(List<string> prices, out List<string> results, out string strError) { strError = ""; results = new List<string>(); List<CurrencyItem> items = new List<CurrencyItem>(); // �任ΪPriceItem for (int i = 0; i < prices.Count; i++) { string strText = prices[i].Trim(); if (String.IsNullOrEmpty(strText) == true) continue; #if NO string strLeft = ""; string strRight = ""; string strOperator = ""; // �ȴ���˳��� // return: // -1 ���� // 0 û�з��ֳ˺š����� // 1 ���ֳ˺Ż��߳��� int nRet = ParseMultipcation(strText, out strLeft, out strRight, out strOperator, out strError); if (nRet == -1) return -1; if (nRet == 1) { Debug.Assert(strOperator.Length == 1, ""); if (String.IsNullOrEmpty(strLeft) == true || String.IsNullOrEmpty(strRight) == true) { strError = "����ַ�����ʽ���� '" + strText + "'���˺Ż���ŵ����߱��붼������"; return -1; } } string strPrice = ""; string strMultiper = ""; if (nRet == 0) { Debug.Assert(String.IsNullOrEmpty(strLeft) == true, ""); Debug.Assert(String.IsNullOrEmpty(strRight) == true, ""); Debug.Assert(String.IsNullOrEmpty(strOperator) == true, ""); strPrice = strText.Trim(); } else { Debug.Assert(nRet == 1, ""); if (StringUtil.IsDouble(strLeft) == false && StringUtil.IsDouble(strRight) == false) { strError = "����ַ�����ʽ���� '" + strText + "'���˺Ż���ŵ����߱���������һ���Ǵ�����"; return -1; } if (StringUtil.IsDouble(strLeft) == false) { strPrice = strLeft; strMultiper = strRight; } else if (StringUtil.IsDouble(strRight) == false) { strPrice = strRight; strMultiper = strLeft; if (strOperator == "/") { strError = "����ַ�����ʽ���� '" + strText + "'�����ŵ��ұ߲����Ǵ�����"; return -1; } } else { // Ĭ������Ǽ۸��ұ��DZ��� strPrice = strLeft; strMultiper = strRight; } } string strPrefix = ""; string strValue = ""; string strPostfix = ""; nRet = ParsePriceUnit(strPrice, out strPrefix, out strValue, out strPostfix, out strError); if (nRet == -1) return -1; // 2012/1/5 if (string.IsNullOrEmpty(strValue) == true) { strError = "��������ַ��� '" + strPrice + "' ��û�а������ֲ���"; return -1; } decimal value = 0; try { value = Convert.ToDecimal(strValue); } catch { strError = "��������ַ��� '" + strPrice + "' ��, ���ֲ��� '" + strValue + "' ��ʽ����ȷ"; return -1; } if (String.IsNullOrEmpty(strOperator) == false) { double multiper = 0; try { multiper = Convert.ToDouble(strMultiper); } catch { strError = "���� '" + strMultiper + "' ��ʽ����ȷ"; return -1; } if (strOperator == "*") { value = (decimal)((double)value * multiper); } else { Debug.Assert(strOperator == "/", ""); if (multiper == 0) { strError = "����ַ�����ʽ���� '" + strText + "'�����������У���������Ϊ0"; return -1; } value = (decimal)((double)value / multiper); } } PriceItem item = new PriceItem(); item.Prefix = strPrefix.ToUpper(); item.Postfix = strPostfix.ToUpper(); item.Value = value; // ȱʡ����Ϊ����� if (item.Prefix == "" && item.Postfix == "") item.Prefix = "CNY"; #endif CurrencyItem item = null; int nRet = ParseSinglePrice(strText, out item, out strError); if (nRet == -1) return -1; items.Add(item); } // ���� for (int i = 0; i < items.Count; i++) { CurrencyItem item = items[i]; for (int j = i + 1; j < items.Count; j++) { CurrencyItem current_item = items[j]; if (current_item.Prefix == item.Prefix && current_item.Postfix == item.Postfix) { item.Value += current_item.Value; items.RemoveAt(j); j--; } /* else break; * */ // ������һ��BUG��û��������֪�����滹��û���ظ��������أ�����break��2009/10/10 changed } } // ��� for (int i = 0; i < items.Count; i++) { CurrencyItem item = items[i]; decimal value = item.Value; // ����Ҫ������ǰ�� if (value < 0) results.Add("-" + item.Prefix + (-value).ToString() + item.Postfix); else results.Add(item.Prefix + value.ToString() + item.Postfix); } return 0; }