public TransactionTO GetData(String token) { if (!mFilterManager.checkFilters(token)) { return(null); } var random = new Random(); var amount = random.Next() % 1001; var transaction = new TransactionTO(100.0f, amount, 1); return(transaction); }
public void RegistryNewTransaction(TransactionTO t) { Stats.TotalAmount += t.Amount; // if (Stats.TotalAmount > 500) { State = new BuyState(); } else if (Stats.TotalAmount > 1000) { State = new SellState(); } Notify(); }
private void ListChanged(object sender, ListChangedEventArgs e) { //Console.WriteLine(e.ToString()); if (e.ListChangedType.Equals(System.ComponentModel.ListChangedType.ItemAdded)) { Console.WriteLine("zarejestrowanie nowej transakcji"); if (bindingSource1.List[e.NewIndex].GetType().Equals(typeof(TransactionTO))) { TransactionTO t = (TransactionTO)bindingSource1.List[e.NewIndex]; gui.RegistryNewTransaction(t); } } else if (e.ListChangedType.Equals(System.ComponentModel.ListChangedType.ItemChanged)) { //// wyslanie zmodyfikowanego obiektu na serwer //Console.WriteLine("wyslanie zmodyfikowanego obiektu na serwer"); //TransactionTO t = (TransactionTO)bindingSource1.List[e.NewIndex]; //var sClient = new ServiceReference1.Service1Client(); //sClient.Open(); //bool result = sClient.Save(t); //sClient.Close(); //if (result) //{ // MessageBox.Show("Zapisano zmiany"); //} //else //{ // MessageBox.Show("Nie udało się zapisać zmian"); //} //// dla celów dev, wyświetlenie obiektu w postaci json //MemoryStream stream1 = new MemoryStream(); //DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(TransactionTO)); //ser.WriteObject(stream1, t); //stream1.Position = 0; //StreamReader sr = new StreamReader(stream1); //Console.Write("JSON of TransactionTO object: "); //Console.WriteLine(sr.ReadToEnd()); } }
public int UpdateOrInsert(TransactionTO t) { var existingT = GetSingle(t.ID); if (null == existingT) { // nowy rekord int newId = mData.Last().ID + 1; var newT = new Transaction(t.Price, t.Amount, newId); mData.Add(newT); return(newId); } else { // aktualizacja rekordu existingT.Amount = t.Amount; existingT.Price = t.Price; return(existingT.ID); } }
public void Update() { TransactionTO t = Gui.LastTransaction; Robot.RegistryNewTransaction(t); }
public TransactionTO GetLatestTransaction() { var trans = new TransactionTO(207.9f, 10000, 999); return(trans); }
public void RegistryNewTransaction(TransactionTO t) { LastTransaction = t; Notify(); }
protected TransactionTO createTransferObject(Transaction src) { var dst = new TransactionTO(src.Price, src.Amount, src.ID); return(dst); }
public int Insert(TransactionTO t) { var newId = mMP.UpdateOrInsert(t); return(newId); }
public bool Delete(TransactionTO t) { throw new NotImplementedException(); }
public bool Update(TransactionTO t) { mMP.UpdateOrInsert(t); return(true); }
public bool Save(TransactionTO t) { return(mDAO.Update(t)); }