Esempio n. 1
0
    protected void submitReview_Click(object sender, EventArgs e)
    {
        if (this.UserState.SiteVisit.PointSurveys.Count.Equals(0))
        {
            Master.SetErrorMessage(
                "<p>No point surveys have been entered yet. Please return to step 2 and complete at least one point survey for the site visit.</p>");
            this.SubmitReview.Enabled = false;
        }
        else
        {
            IbaMasterPage.ExceptionHandler(this.Master, () =>
            {
                this.UserState.SiteVisit.IsDataEntryComplete = true;
                SiteVisitMapper.Update(this.UserState.SiteVisit);

                this.UserState.SiteVisit   = null;
                this.UserState.PointSurvey = null;
                this.UserState.PointsCompleted.Clear();
                this.UserState.PointsRemaining.Clear();
                this.UserState.SamplingPoint = null;

                Response.Redirect("../Default.aspx", true);
            });
        }
    }
Esempio n. 2
0
        public void t_SiteVisit_Delete()
        {
            SiteVisit_ado setupObject = null;

            // backdoor data setup
            DbTestHelper.LoadAdoObjects(delegate(IbaUnitTestEntities iba)
            {
                setupObject = SiteVisit_ado.CreateSiteVisit_ado(TestHelper.TestGuid1, true, TestHelper.TestGuid2,
                                                                DateTime.Now, DateTime.Now.AddHours(2), TestHelper.TestGuid3);
                setupObject.ObserverId = TestHelper.TestGuid4;
                setupObject.RecorderId = TestHelper.TestGuid3;
                setupObject.Comments   = "asdf asdfasdf";
                iba.AddToSiteVisit_ado1(setupObject);
            });
            List <SiteVisit_ado> SiteVisitAdolist = DbTestHelper.LoadExtraneousSiteVisits();

            SiteVisitMapper.Delete(new SiteVisit()
            {
                Id = setupObject.EventId
            });

            // Validate results
            using (IbaUnitTestEntities iba = new IbaUnitTestEntities())
            {
                var SiteVisitQuery = from SiteVisits in iba.SiteVisit_ado1 select SiteVisits;
                Assert.IsNotNull(SiteVisitQuery, "Query result is null");
                Assert.AreEqual(SiteVisitAdolist.Count(), SiteVisitQuery.Count(), "Wrong number of results in query");
                validateExtraSiteVisitAdos(SiteVisitAdolist, SiteVisitQuery);
            }
        }
        public void SaveSiteConditions(SiteVisit visit)
        {
            if (visit == null)
            {
                throw new ArgumentNullException("visit");
            }

            SiteVisitMapper.Insert(visit);
            ConditionsMapper.Insert(visit.StartConditions);
            ConditionsMapper.Insert(visit.EndConditions);
        }
Esempio n. 4
0
        public void t_SiteVisit_SelectAllForSite()
        {
            // Backdoor setup
            List <SiteVisit_ado> list = DbTestHelper.LoadExtraneousSiteVisits();

            // Exercise the test
            List <SiteVisit> resultList = SiteVisitMapper.SelectAllForSite(list[0].LocationId);

            // Validate results
            Assert.AreEqual(resultList.Count(), 1, "Wrong number of objects in the result list");
            foreach (SiteVisit_ado ado in list.FindAll(x => x.LocationId.Equals(list[0].LocationId)))
            {
                // just check to make sure the object is there; leave specific value check for the Select_ByGuid test
                Assert.IsTrue(resultList.Exists(x => x.Id.Equals(ado.EventId)), "SiteVisitAdo " + ado.EventId.ToString() + " is not in the results");
            }
        }
Esempio n. 5
0
        public void t_SiteVisit_Save_Insert()
        {
            SiteVisit toInsert = new SiteVisit()
            {
                Id            = TestHelper.TestGuid1,
                EndConditions = new SiteCondition()
                {
                    Id          = TestHelper.TestGuid1,
                    SiteVisitId = TestHelper.TestGuid1,
                    Sky         = 0,
                    Temperature = new Business.DataTypes.Temperature()
                    {
                        Units = "C", Value = 20
                    },
                    Wind = 2
                },
                EndTimeStamp        = DateTime.Now,
                IsDataEntryComplete = true,
                LocationId          = TestHelper.TestGuid4,
                ObserverId          = TestHelper.TestGuid3,
                RecorderId          = TestHelper.TestGuid2,
                StartConditions     = new SiteCondition()
                {
                    Id          = TestHelper.TestGuid2,
                    SiteVisitId = TestHelper.TestGuid1,
                    Sky         = 1,
                    Temperature = new Business.DataTypes.Temperature()
                    {
                        Units = "C", Value = 23
                    },
                    Wind = 2
                },
                StartTimeStamp = DateTime.Now.AddHours(-2),
                Comments       = "asdf asdfa sdf asdfasdfasdf"
            };

            SiteVisitMapper.Insert(toInsert);

            using (IbaUnitTestEntities iba = new IbaUnitTestEntities())
            {
                var SiteVisitQuery = from SiteVisits in iba.SiteVisit_ado1 select SiteVisits;
                Assert.IsNotNull(SiteVisitQuery, "Query result is null");
                Assert.AreEqual(1, SiteVisitQuery.Count(), "Wrong number of results in query");
                SiteVisit_ado adoSiteVisit = SiteVisitQuery.First();
                validateObjectEquality(toInsert, adoSiteVisit);
            }
        }
Esempio n. 6
0
    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>");
        }
    }
Esempio n. 7
0
        public void t_SiteVisit_Save_Update()
        {
            SiteVisit_ado setupObject = null;

            // backdoor data setup
            DbTestHelper.LoadAdoObjects(delegate(IbaUnitTestEntities iba)
            {
                setupObject = SiteVisit_ado.CreateSiteVisit_ado(TestHelper.TestGuid1, true, TestHelper.TestGuid2,
                                                                DateTime.Now, DateTime.Now.AddHours(2), TestHelper.TestGuid3);
                setupObject.ObserverId = TestHelper.TestGuid4;
                setupObject.RecorderId = TestHelper.TestGuid3;
                setupObject.Comments   = "asdf asdfasdf";
                iba.AddToSiteVisit_ado1(setupObject);
            });
            List <SiteVisit_ado> extraList = DbTestHelper.LoadExtraneousSiteVisits();

            // Setup object to be saved. Change everything except the Id.
            SiteVisit toSave = new SiteVisit()
            {
                Id                  = setupObject.EventId,
                EndTimeStamp        = setupObject.EndTime.AddHours(1),
                IsDataEntryComplete = false,
                LocationId          = TestHelper.TestGuid4,
                ObserverId          = TestHelper.TestGuid3,
                RecorderId          = TestHelper.TestGuid2,
                StartTimeStamp      = setupObject.StartTime.AddHours(0.5),
                Comments            = "asdf asdfa sdf asdfasdfasdf"
            };

            // Execute the test
            SiteVisitMapper.Update(toSave);

            // Validate results
            using (IbaUnitTestEntities iba = new IbaUnitTestEntities())
            {
                var SiteVisitQuery = from SiteVisits in iba.SiteVisit_ado1 select SiteVisits;
                Assert.IsNotNull(SiteVisitQuery, "Query result is null");
                Assert.AreEqual(extraList.Count() + 1, SiteVisitQuery.Count(), "Wrong number of results in query");
                SiteVisit_ado adoSiteVisit = SiteVisitQuery.First(x => x.EventId == TestHelper.TestGuid1);
                validateObjectEquality(toSave, adoSiteVisit);

                validateExtraSiteVisitAdos(extraList, SiteVisitQuery);
            }
        }
Esempio n. 8
0
        public void t_SiteVisit_Select_ByGuid()
        {
            SiteVisit_ado setupObject = null;

            // backdoor data setup
            DbTestHelper.LoadAdoObjects(delegate(IbaUnitTestEntities iba)
            {
                setupObject = SiteVisit_ado.CreateSiteVisit_ado(TestHelper.TestGuid1, true, TestHelper.TestGuid2,
                                                                DateTime.Now, DateTime.Now.AddHours(2), TestHelper.TestGuid3);
                setupObject.ObserverId = TestHelper.TestGuid4;
                setupObject.RecorderId = TestHelper.TestGuid3;
                setupObject.Comments   = "asdf asdfasdf";
                iba.AddToSiteVisit_ado1(setupObject);
            });
            List <SiteVisit_ado> extraList = DbTestHelper.LoadExtraneousSiteVisits();

            // Exercise the test
            SiteVisit resultObject = SiteVisitMapper.Select(setupObject.EventId);

            validateObjectEquality(resultObject, setupObject);
        }
Esempio n. 9
0
 public void t_SiteVisit_Select_ByGuid_Empty()
 {
     SiteVisitMapper.Select(Guid.Empty);
 }