public void t_Conditions_Select_BySiteVisitId() { SiteCondition_ado conditionAdo = SiteCondition_ado.CreateSiteCondition_ado(TestHelper.TestGuid1, 32, "F", 2, 3, TestHelper.TestParentGuid); // backdoor data setup DbTestHelper.LoadAdoObjects(delegate(IbaUnitTestEntities iba) { iba.AddToSiteCondition_ado(conditionAdo); }); SiteCondition_ado conditionAdo2 = SiteCondition_ado.CreateSiteCondition_ado(TestHelper.TestGuid2, 32, "F", 2, 3, TestHelper.TestParentGuid); DbTestHelper.LoadAdoObjects(delegate(IbaUnitTestEntities iba) { iba.AddToSiteCondition_ado(conditionAdo2); }); // Exercise the test List <SiteCondition> conditions = ConditionsMapper.Select_BySiteVisitId(TestHelper.TestParentGuid); SiteCondition cond = conditions.First(x => x.Id == conditionAdo.ConditionId); validateResults(conditionAdo, cond); cond = conditions.First(x => x.Id == conditionAdo2.ConditionId); validateResults(conditionAdo2, cond); }
protected void RetrieveIncomplete_Click(object sender, EventArgs e) { if (this.SiteVisitedInput.SelectedIndex > -1 && !string.IsNullOrEmpty(this.VisitDateInput.Text)) { List <SiteVisit> visitList = SiteVisitMapper.SelectAllForSite(Guid.Parse(this.SiteVisitedInput.SelectedValue)); SiteVisit theVisit = visitList.Find(x => !x.IsDataEntryComplete && x.StartTimeStamp.Value.ToShortDateString() .Equals( DateTime.Parse(this.VisitDateInput.Text).ToShortDateString())); if (theVisit != null) { resetSession(); this.UserState.SiteVisit = theVisit; this.UserState.SiteVisit.SupplementalObservations.AddRange( SupplementalObservationMapper.SelectAllForEvent(theVisit.Id)); this.UserState.SiteVisit.PointSurveys.AddRange(PointSurveyMapper.SelectAllForSiteVisit(theVisit.Id)); this.UserState.SiteVisit.PointSurveys.ForEach(x => { x.Observations.AddRange(ObservationMapper.SelectAllForEvent <PointCountBeyond50>(x.Id)); x.Observations.AddRange(ObservationMapper.SelectAllForEvent <PointCountWithin50>(x.Id)); }); List <SiteCondition> conditions = ConditionsMapper.Select_BySiteVisitId(theVisit.Id); if (conditions != null && conditions.Count.Equals(2)) { this.UserState.SiteVisit.StartConditions = conditions.Single(x => x.Id.Equals(this.UserState.SiteVisit.StartConditions.Id)); this.UserState.SiteVisit.EndConditions = conditions.Single(x => x.Id.Equals(this.UserState.SiteVisit.EndConditions.Id)); } loadCurrentSiteVisit(); } else { Master.SetErrorMessage( "<p>No <i>incomplete</i> site visit entry has been started for this site and date.</p>"); } } else { Master.SetErrorMessage( "<p>Both site and date must be filled in to retrieve an incomplete site visit.</p>"); } }