string Poyavilsya(User user, Product product, TransferProduct transferProduct) { string send; if (product.PriceMinBYN > transferProduct.CostBYN) //цена меньше { send = $"Появился в продаже /I{product.Artikul} \n" + "ПО МИНИМАЛЬНОЙ ЦЕНЕ" + "\n" + transferProduct.Name + "\n" + $"{product.PriceMinBYN} ({product.PriceMinRUS}) - прошлая цена \n" + $"{transferProduct.CostBYN} ({transferProduct.CostRUS}) - текщая цена \n" + $"Удалить /D{product.Artikul}"; product.PriceMinBYN = transferProduct.CostBYN; product.PriceMinRUS = transferProduct.CostRUS; product.DateTimeMinCost = DateTime.Now; } else //цена больше { send = $"Появился в продаже /I{product.Artikul}" + "\n" + transferProduct.Name + "\n" + $"{product.PriceMinBYN} ({product.PriceMinRUS}) - минимальная цена \n" + $"{transferProduct.CostBYN} ({transferProduct.CostRUS}) - текущая цена \n" + $"Удалить /D{product.Artikul}"; } SendTextAndPhotoToBot(user.UserId, product.FullURL, send); product.ProductIsNow = true; product.PricePreviousBYN = transferProduct.CostBYN; product.PricePreviousRUS = transferProduct.CostRUS; return(send); }
public virtual void Update(TransferProduct dataObject) { using (IDAL dal = this.DAL) { dal.BeginTransaction(); try { // Update via DAL dal.Update <TransferProduct>(dataObject); // Delete and ReInsert Mikro Records, if status is completed //if (dataObject.TransferStatus == 5) //{ // IUniParameter prmTransferProduct = dal.CreateParameter("TransferProductId", dataObject.TransferProductId); // dal.ExecuteNonQuery("WHS_DEL_WAYBILLBYTRANSFERPRODUCTID_SP", prmTransferProduct); // dal.ExecuteNonQuery("WHS_INS_WAYBILLBYTRANSFERPRODUCTID_SP", prmTransferProduct); //} dal.CommitTransaction(); } catch { dal.RollbackTransaction(); throw; } } }
public virtual void UpdateAll(IEnumerable <TransferProductDetail> dataObjects) { using (IDAL dal = this.DAL) { dal.BeginTransaction(); try { TransferProduct transferProduct = null; if (dataObjects.Count() > 0) { transferProduct = dal.Read <TransferProduct>(dataObjects.First().TransferProduct); } // Update via DAL foreach (TransferProductDetail td in dataObjects) { dal.Update <TransferProductDetail>(td); if (transferProduct != null && transferProduct.TransferStatus == 5) { IUniParameter prmTransferProductDetail = dal.CreateParameter("TransferProductDetailId", td.TransferProductDetailId); dal.ExecuteNonQuery("WHS_UPD_WAYBILLBYTRANSFERPRODUCTDETAIL_SP", prmTransferProductDetail); } } dal.CommitTransaction(); } catch { dal.RollbackTransaction(); throw; } } }
public virtual void DeleteAll(IEnumerable <long> objectIds) { using (IDAL dal = this.DAL) { dal.BeginTransaction(); try { TransferProduct transferProduct = null; if (objectIds.Count() > 0) { TransferProductDetail td = dal.Read <TransferProductDetail>(objectIds.First()); transferProduct = dal.Read <TransferProduct>(td.TransferProduct); } // Delete via DAL foreach (long id in objectIds) { dal.Delete <TransferProductDetail>(id); if (transferProduct != null && transferProduct.TransferStatus == 5) { IUniParameter prmTransferProductDetail = dal.CreateParameter("TransferProductDetailId", id); dal.ExecuteNonQuery("WHS_DEL_WAYBILLBYTRANSFERPRODUCTDETAIL_SP", prmTransferProductDetail); } } dal.CommitTransaction(); } catch { dal.RollbackTransaction(); throw; } } }
private bool CheckErrorSite(TransferProduct transferProduct) //логировать { if (transferProduct.Name == "" && transferProduct.CostRUS == 0 && transferProduct.CostBYN == 0) { return(true); } return(false); }
string OperanionOnProduct(MessageEventArgs e, TransferProduct backCheckProduct) { using var db = new ApplicationContext(); var user = db.Users.Where(u => u.UserId == e.Message.Chat.Id) .Include(p => p.Products) .FirstOrDefault(); var result = String.Empty; if (user.Products.Contains(new Product(e.Message.Text))) { result = $"Товара с артикулом {e.Message.Text} уже добавлен в отслеживание \n /I{e.Message.Text}"; } else { if (backCheckProduct.Name != string.Empty) { var newProduct = new Product(e.Message.Text); newProduct.FullURL = GroupURL(e.Message.Text); newProduct.NameProduct = backCheckProduct.Name; newProduct.URLImage = backCheckProduct.URLImage; newProduct.DateTimeAdd = DateTime.Now; newProduct.DateTimeMinCost = DateTime.Now; newProduct.PriceMinBYN = backCheckProduct.CostBYN; newProduct.PricePreviousBYN = newProduct.PriceMinBYN; newProduct.PriceMinRUS = backCheckProduct.CostRUS; newProduct.PricePreviousRUS = newProduct.PriceMinRUS; newProduct.PriceHistories = new List <PriceHistory>(); if (backCheckProduct.CostRUS == 0 || backCheckProduct.CostBYN == 0) { newProduct.ProductIsNow = false; result = backCheckProduct.Name + "\n" + "Товара нет в наличии" + "\n" + "Сообщу вам о поступлении \n" + $"Удалить /D{newProduct.Artikul}"; } else { newProduct.ProductIsNow = true; newProduct.PriceHistories.Add(new PriceHistory(newProduct.ProductId, DateTime.Now, backCheckProduct.CostBYN, backCheckProduct.CostRUS)); result = $"Добавлен товар /I{newProduct.Artikul}\n" + backCheckProduct.Name + "\n" + "Цена - " + backCheckProduct.CostBYN + $"р" + $" ({backCheckProduct.CostRUS}) \n" + $"Удалить /D{newProduct.Artikul}"; } user.Products.Add(newProduct); db.SaveChanges(); } else { result = $"По Вашему запросу {e.Message.Text} ничего не найдено"; } } return(result); }
string CenaSnizilas(User user, Product product, TransferProduct transferProduct) { string send = $"СНОВА МИНИМАЛЬНАЯ ЦЕНА /I{product.Artikul}" + "\n" + transferProduct.Name + "\n" + $"{product.PricePreviousBYN} ({product.PricePreviousRUS}) - предыдущая цена \n" + $"{transferProduct.CostBYN} ({transferProduct.CostRUS}) - текущая цена \n" + $"Удалить /D{product.Artikul}"; product.PricePreviousBYN = transferProduct.CostBYN; product.PricePreviousRUS = transferProduct.CostRUS; product.DateTimeMinCost = DateTime.Now; SendTextAndPhotoToBot(user.UserId, product.FullURL, send); return(send); }
string Disappeared(User user, Product product, TransferProduct transferProduct) { string send = $"Пропал из продажи /I{product.Artikul} \n" + $"{transferProduct.Name} \n" + $"Сообщу вам о поступлении. \n" + $"Удалить /D{product.Artikul}"; SendTextAndPhotoToBot(user.UserId, product.FullURL, send); product.ProductIsNow = false; product.PricePreviousBYN = transferProduct.CostBYN; product.PricePreviousRUS = transferProduct.CostRUS; return(send); }
private bool CheckErrorСost(TransferProduct transferProduct) //логировать { if (transferProduct.CostBYN == 0 && transferProduct.CostRUS != 0) { return(true); } if (transferProduct.CostBYN != 0 && transferProduct.CostRUS == 0) { return(true); } return(false); }
public override void Delete(long objectId) { using (IDAL dal = this.DAL) { dal.BeginTransaction(); try { // Get processInstanceNo of the sugggestion var processInstance = dal.Read <TransferProduct>(objectId).ProcessInstance; // Delete via DAL TransferProduct tp = Read(objectId, dal); foreach (TransferProductDetail td in tp.TransferDetails) { dal.Delete <TransferProductDetail>(td.TransferProductDetailId); } dal.Delete <TransferProduct>(objectId); // Delete Mikro Records, if status is completed if (tp.TransferStatus == 5) { IUniParameter prmTransferProduct = dal.CreateParameter("TransferProductId", objectId); dal.ExecuteNonQuery("WHS_DEL_WAYBILLBYTRANSFERPRODUCTID_SP", prmTransferProduct); } // Kill process via ProcessOperations (other then already completed processes) if (processInstance != null & tp.TransferStatus < 5) { ProcessOperations processOperations = new ProcessOperations(OTApplication.Context.User.Id); processOperations.Cancel(processInstance.Value); } dal.CommitTransaction(); } catch (Exception ex) { dal.RollbackTransaction(); throw ex; } } }
public override TransferProduct Create(TransferProduct dataObject) { using (IDAL dal = this.DAL) { dal.BeginTransaction(); try { if (dataObject.TransferProductId > 0) { dal.Update(dataObject); } else { dataObject.TransferProductId = dal.Create(dataObject); } foreach (TransferProductDetail td in dataObject.TransferDetails) { td.TransferProduct = dataObject.TransferProductId; if (td.TransferProductDetailId > 0) { dal.Update(td); } else { dal.Create(td); } } dal.CommitTransaction(); } catch (Exception ex) { dal.RollbackTransaction(); throw (ex); } return(dataObject); } }
static void Other(Product product, TransferProduct transferProduct) { product.PricePreviousBYN = transferProduct.CostBYN; product.PricePreviousRUS = transferProduct.CostRUS; }