public void Go() { using (var dc = new BEDataContext()) { var sites = dc.Sites.ToList(); //dc.Sites.Add(new Site { ID = 81, Name = "Site Eight1" }); //dc.Sites.Add(new Site { ID = 91, Name = "Site Nine1" }); //dc.SaveChanges(); } }
/// <summary> /// Prepare the view model for new Visit /// </summary> public void Load() { this.VisitID = 0; this.VisitName = "New Request"; //var e = new BEDataAccess.Engine(); using (var dc = new BEDataContext()) { this.SiteID = Repository.DefaultSiteID; // this would be user's default site var sites = dc.Sites.ToList(); var visTypes = dc.SiteEvents.Where(r => r.SiteID == this.SiteID).Select(s => s.VisitType).ToList(); this.SiteSelList = new SelectList(sites, "SITEID", "SITENAME", this.SiteID); this.VisitTypeSelList = new SelectList(visTypes, "EventTypeID", "EventType1", this.VisitTypeID); this.Site = sites.Where(s => s.SITEID == this.SiteID).Single(); this.VisitTypeID = visTypes.First().EventTypeID; } #if(DEBUG) this.VisitLength = VLength.Full; this.NumAttendees = 5; #endif }
public VisitInfoViewModel Fluff() { using (var dc = new BEDataContext()) { var sites = dc.Sites; var visTypes = dc.SiteEvents.Where(r => r.SiteID == this.SiteID).Select(s => s.VisitType); this.SiteSelList = new SelectList(sites, "SITEID", "SITENAME", this.SiteID); this.VisitTypeSelList = new SelectList(visTypes, "EventTypeID", "EventTypeID1", this.VisitTypeID); } return this; }