private void Form1_Load(object sender, EventArgs e) { stockInfos = new XPQuery<StockInfo>(sess); stockHoldings = new XPQuery<StockHolding>(sess); stockFlows = new XPQuery<StockFlow>(sess); dailyCounts = new XPQuery<DailyCount>(sess); DailyCount todayCount; moneyFlows = new XPQuery<MoneyFlow>(sess); moneyHolding = new XPQuery<MoneyHolding>(sess).SingleOrDefault(); if (moneyHolding == null) { moneyHolding = new MoneyHolding(); moneyHolding.Save(); } if (stockHoldings.Count() > 0&&! new DayOfWeek[]{DayOfWeek.Sunday,DayOfWeek.Saturday}.Contains( DateTime.Today.DayOfWeek)) { todayCount= dailyCounts.SingleOrDefault(p => p.Date.Date == DateTime.Today); if (todayCount == null) { todayCount = new DailyCount() { Date = DateTime.Now }; todayCount.Save(); dailyCounts = new XPQuery<DailyCount>(sess); } } dgvDaily.DataSource = dailyCounts.ToList() ; comboBox1.DisplayMember = "Text"; comboBox1.ValueMember = "Value"; comboBox1.DataSource =EnumHelper.GetItems< StockTradeType>(); }
internal string GetAttributeByName(string clientId, string attributeName) { try { using (Session result = XpoHelper.GetNewSession()) { XPQuery <DAL.Datamodel.APP_CompanyValue> items = result.Query <DAL.Datamodel.APP_CompanyValue>(); return(items.SingleOrDefault(a => a.EntityId.Name == clientId && a.AttributeId.Code == attributeName).Value); } } catch (Exception ex) { return(null); } }
public void Should_update_project() { var project = CreateProject(); project.Save(); const string changedname = "changedName"; project.Name = changedname; _repository.Update(project); var changedProject = _projectQuery.SingleOrDefault(p => p.Oid == project.Oid); Assert.AreEqual(1, _projectQuery.Count()); Assert.AreEqual(changedname, changedProject.Name); Assert.AreEqual(project.Identify, changedProject.Identify); }
public string GetAuthorizationCookie(string name, string password) { using (UnitOfWork uow = new UnitOfWork(Context.ObjectLayer)) { List <Employees> contacts = new XPQuery <Employees>(uow).Where(i => i.LastName == name).ToList(); Employees contact = contacts.SingleOrDefault(); if (contact == null) { return(string.Empty); } FormsAuthenticationTicket ticket = new FormsAuthenticationTicket( 1, contact.LastName, DateTime.Now, DateTime.Now.AddMinutes(30), true, contact.EmployeeID.ToString()); string encryptedTicket = FormsAuthentication.Encrypt(ticket); return(encryptedTicket); } }
public Project FindById(string id) { var guid = new Guid(id); return(_query.SingleOrDefault(p => p.Oid == guid)); }