private string GetClientCapital() { var isIndex = SelectedSetup != null && SelectedSetup.Symbol != null && !_selectedsetup.Symbol.Contains("FUT"); var minicon = BasketCollection.Where(x => x.IsMini).Sum(x => x.Capital); var fullcon = BasketCollection.Where(x => !x.IsMini).Sum(x => x.Capital); return(isIndex ? (minicon + fullcon).ToString("R$ #.###,00") : fullcon + " contratos e " + minicon + " mini-contratos"); }
private void EnterOnlineMode() { SelectedSetup.Online = true; SelectedSetup.Basket = BasketCollection.Where(i => i.Capital > 0).ToList(); SysManager.CreateTasks(SelectedSetup); UpdateSetupAtDatabase(SelectedSetup); OnSave(); }
private void OnSave() { try { using (var db = new DatabaseContext()) { var OldCollection = BasketCollection.Where(i => i.Setup == SelectedSetup.SetupId).ToList(); foreach (var item in OldCollection) { var fromDB = db.Clients.FirstOrDefault(c => c.Id == item.Id); if (fromDB == null) { item.Setup = SelectedSetup.SetupId; db.Clients.Add(item); } else { fromDB.ClientID = item.ClientID; fromDB.Capital = item.Capital; fromDB.IsMini = item.IsMini; } } // Add new itens foreach (var item in BasketCollection.Where(i => i.Setup == 0)) { item.Setup = SelectedSetup.SetupId; db.Clients.Add(item); } db.SaveChanges(); } } catch (Exception e) { Log = TimeTag + "Falha ao salvar clientes na base de dados. Tente novamente.\r\n" + e.Message + "\r\n" + Log; } }