private static async Task SupplierPriceChange( UserSettingsView settings, Listing listing, List <string> priceChangeList, ISupplierItem wmItem, decimal wmShipping, decimal wmFreeShippingMin, string token, double eBayPct, List <string> response) { string body = null; priceChangeList.Add(listing.ListingTitle); var str = listing.ListedItemID + " db supplier price " + listing.SupplierItem.SupplierPrice.Value.ToString("c") + " different from just captured " + wmItem.SupplierPrice.Value.ToString("c"); string note = "db supplier price " + listing.SupplierItem.SupplierPrice.Value.ToString("c") + " different from just captured " + wmItem.SupplierPrice.Value.ToString("c"); priceChangeList.Add(str); Console.WriteLine("Price change."); if (wmItem.SupplierPrice < listing.SupplierItem.SupplierPrice) { str = "Supplier dropped their price."; note += " " + str; priceChangeList.Add(str); priceChangeList.Add(listing.SupplierItem.ItemURL); } else { str = "Supplier INCREASED their price!"; note += " " + str; priceChangeList.Add(str); priceChangeList.Add(listing.SupplierItem.ItemURL); } dsutil.DSUtil.WriteFile(_logfile, body, log_username); var priceProfit = wallib.wmUtility.wmNewPrice(wmItem.SupplierPrice.Value, listing.PctProfit, wmShipping, wmFreeShippingMin, eBayPct); decimal newPrice = priceProfit.ProposePrice; priceChangeList.Add(string.Format("New price: {0:c}", newPrice)); note += string.Format(" New price: {0:c}", newPrice); priceChangeList.Add(string.Empty); response = Utility.eBayItem.ReviseItem(token, listing.ListedItemID, price: (double)newPrice); await _repository.UpdatePrice(listing, (decimal)newPrice, wmItem.SupplierPrice.Value); var log = new ListingLog { ListingID = listing.ID, MsgID = 700, Note = note, UserID = settings.UserID }; await _repository.ListingLogAdd(log); }
private static async Task PutBackInStock(UserSettingsView settings, Listing listing, List <string> putBackInStockList, string token, List <string> response, ISupplierItem wmItem, decimal wmShipping, decimal wmFreeShippingMin, double eBayPct, int newListedQty, string output) { try { putBackInStockList.Add(listing.ListingTitle); putBackInStockList.Add(listing.SupplierItem.ItemURL); putBackInStockList.Add(string.Empty); var priceProfit = wallib.wmUtility.wmNewPrice(wmItem.SupplierPrice.Value, listing.PctProfit, wmShipping, wmFreeShippingMin, eBayPct); decimal newPrice = priceProfit.ProposePrice; output += string.Format(" Price: {0:0.00} ", newPrice); listing.ListingPrice = newPrice; response = Utility.eBayItem.ReviseItem(token, listing.ListedItemID, price: (double)newPrice, qty: newListedQty); if (response.Count > 0) { output += dsutil.DSUtil.ListToDelimited(response, ';'); } var log = new ListingLog { ListingID = listing.ID, MsgID = 600, UserID = settings.UserID, Note = output }; await _repository.ListingLogAdd(log); listing.Qty = newListedQty; await _repository.ListingSaveAsync(settings, listing, false, "Qty", "ListingPrice"); } catch (Exception exc) { string msg = dsutil.DSUtil.ErrMsg("PutBackInStock", exc); dsutil.DSUtil.WriteFile(_logfile, msg, settings.UserName); throw; } }
private static async Task ParseArrivalDateAsync(UserSettingsView settings, Listing listing, List <string> parseArrivalDateList, string token, int daysBack, List <string> response, ISupplierItem wmItem) { try { parseArrivalDateList.Add(listing.ListingTitle); parseArrivalDateList.Add(listing.SupplierItem.ItemURL); parseArrivalDateList.Add(string.Format("Code: {0}", wmItem.ArrivalDateFlag)); parseArrivalDateList.Add(string.Empty); int cnt = CountMsgID(listing.ID, 1000, daysBack); int total = CountMsgID(listing.ID, 0, daysBack); parseArrivalDateList.Add(string.Format("Parse arrival date: {0}/{1}", cnt, total)); parseArrivalDateList.Add(string.Empty); var log = new ListingLog { ListingID = listing.ID, MsgID = 1000, UserID = settings.UserID }; await _repository.ListingLogAdd(log); } catch (Exception exc) { string msg = dsutil.DSUtil.ErrMsg("ParseArrivalDateAsync", exc); dsutil.DSUtil.WriteFile(_logfile, msg, settings.UserName); throw; } }