コード例 #1
0
        public async Task <IActionResult> Create([Bind("SiteID,WBName,PoolTypeID,LocationID,ConstructionID,Length,Width,Depth")] WaterBody waterBody)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(waterBody);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction("Index"));
                }
            }

            catch (DbUpdateException /*ex*/)
            {
                //Log the error uncomment ex to write a log
                ModelState.AddModelError("", "Changes not saved.  " +
                                         "Try again.  If error recurs see system administrator.");
            }

            ViewData["ConstructionID"] = new SelectList(_context.Constructions, "ConstructionID", "ConstructionID", waterBody.ConstructionID);
            ViewData["LocationID"]     = new SelectList(_context.Locations, "LocationID", "LocationID", waterBody.LocationID);
            ViewData["PoolTypeID"]     = new SelectList(_context.PoolTypes, "PoolTypeID", "PoolTypeID", waterBody.PoolTypeID);
            ViewData["SiteID"]         = new SelectList(_context.Sites, "SiteID", "SiteAddress", waterBody.SiteID);
            return(View(waterBody));
        }
コード例 #2
0
 public void OnEnterBody(WaterBody waterBody)
 {
     if (showDebug)
     {
         Debug.Log(base.name + " Something has touched us  ");
     }
     waterBodies.Add(waterBody);
     this.waterBody = waterBodies[0];
 }
コード例 #3
0
ファイル: WaterBodyTest.cs プロジェクト: nbadw/sjr_atlas
 public void FindWaterBody()
 {
     int id = 37;
     WaterBody waterbody = new WaterBody();
     waterbody.Id = id;
     waterbody.CreateAndFlush();
     WaterBody dbWaterbody = WaterBody.Find(id);
     Assert.AreEqual(id, dbWaterbody.Id);
 }
コード例 #4
0
ファイル: Buoyancy.cs プロジェクト: cecil0610/HouseSuurffing
    // Update is called once per frame
    void Update()
    {
        if (waterCount == 0)
        {
            waterBody      = null;
            isWaterBodySet = false;
        }

        buoyantForce = buoyantForce * buoyancyDecay;
    }
コード例 #5
0
    void OnTriggerEnter(Collider collider)
    {
        WaterBody wbs = collider.gameObject.GetComponent <WaterBody>();

        //if(wbs == null) throw new NullReferenceException("watertrigger just entered something tagged as water without a waterbodyscript. object in question : " + collider.name);
        //else waterLevel = wbs.waterLevel;
        if (wbs != null)
        {
            waterLevel = wbs.waterLevel;
        }
    }
コード例 #6
0
    void OnTriggerStay(Collider otherCollider)
    {
        WaterBody waterBody = otherCollider.gameObject.GetComponent <WaterBody>();

        if (waterBody != null)
        {
            //water is always in y direction. ALWAYS.
            if (head.transform.position.y < waterBody.waterLevel)
            {
                underwater = true;
            }
        }
    }
コード例 #7
0
    void OnTriggerStay(Collider otherCollider)
    {
        WaterBody waterBody = otherCollider.gameObject.GetComponent <WaterBody>();

        if (waterBody != null)
        {
            //water is always in y direction. ALWAYS.
            if ((head.transform.position.y - (waterOffsetFromEyesToSwim * rb.transform.localScale.y)) < waterBody.waterLevel)
            {
                canSwim = true;
            }
        }
    }
コード例 #8
0
 private void OnEnable()
 {
     if (waterBody == null)
     {
         waterBody = GetComponentInParent <WaterBody>();
     }
     if (NetGame.isClient)
     {
         cameraController  = Object.FindObjectOfType <CameraController3>();
         cameraWaterSensor = cameraController.gameObject.GetComponent <WaterSensor>();
         oldCameraPosition = cameraController.transform.position;
         colliders         = GetComponents <Collider>();
     }
 }
コード例 #9
0
 public void SetWaterBodyInfo(WaterBody waterBody)
 {
     if (waterBody == null)
     {
         WaterBodyName.text    = "";
         WaterBodyRegions.text = "";
         WaterBodyArea.text    = "";
     }
     else
     {
         WaterBodyName.text    = waterBody.Name;
         WaterBodyRegions.text = waterBody.BorderingLandRegions.Count.ToString();
         WaterBodyArea.text    = waterBody.Area.ToString("0.00") + " km²";
     }
 }
コード例 #10
0
 public void OnLeaveBody(WaterBody waterBody)
 {
     if (showDebug)
     {
         Debug.Log(base.name + " Something has stopped touching us ");
     }
     waterBodies.Remove(waterBody);
     if (waterBodies.Count > 0)
     {
         this.waterBody = waterBodies[0];
     }
     else
     {
         this.waterBody = null;
     }
 }
コード例 #11
0
 public static void RegisterBody(WaterBody body)
 {
     if (body.Type == WaterBodyType.Ocean)
     {
         if (WaterSystem.Ocean == null)
         {
             WaterSystem.Ocean      = body;
             WaterSystem.OceanLevel = body.Transform.position.y;
         }
         else if (WaterSystem.Ocean != body)
         {
             Debug.LogWarning("[Water] Ocean body is already registered. Ignoring call because only one is allowed.");
             return;
         }
     }
     WaterSystem.WaterBodies.Add(body);
 }
コード例 #12
0
 public static void RegisterBody(WaterBody body)
 {
     if (body.Type == WaterBodyType.Ocean)
     {
         if (Object.op_Equality((Object)WaterSystem.Ocean, (Object)null))
         {
             WaterSystem.Ocean      = body;
             WaterSystem.OceanLevel = (float)body.Transform.get_position().y;
         }
         else if (Object.op_Inequality((Object)WaterSystem.Ocean, (Object)body))
         {
             Debug.LogWarning((object)"[Water] Ocean body is already registered. Ignoring call because only one is allowed.");
             return;
         }
     }
     WaterSystem.WaterBodies.Add(body);
 }
コード例 #13
0
ファイル: WaterBodyTest.cs プロジェクト: nbadw/sjr_atlas
        public void TestAltPlace()
        {
            int id = 37;
            string cgndbKey = "ABCDE";

            Place place = new Place();
            place.CgndbKey = cgndbKey;
            place.CreateAndFlush();

            WaterBody waterbody = new WaterBody();
            waterbody.Id = id;
            waterbody.AltPlace = place;
            waterbody.CreateAndFlush();

            WaterBody dbWaterbody = WaterBody.Find(id);
            Assert.IsNotNull(dbWaterbody);
            Assert.IsNotNull(dbWaterbody.AltPlace);
            Assert.AreEqual(cgndbKey, dbWaterbody.AltPlace.CgndbKey);
        }
コード例 #14
0
ファイル: WaterBodyTest.cs プロジェクト: nbadw/sjr_atlas
        public void TestBelongsToWatershed()
        {
            int id = 73;
            string drainageCode = "01-00-00-00-00-00";

            Watershed watershed = new Watershed();
            watershed.DrainageCode = drainageCode;
            watershed.CreateAndFlush();

            WaterBody waterbody = new WaterBody();
            waterbody.Id = id;
            waterbody.Watershed = watershed;
            waterbody.CreateAndFlush();

            WaterBody dbWaterbody = WaterBody.Find(id);
            Assert.IsNotNull(dbWaterbody);
            Assert.IsNotNull(dbWaterbody.Watershed);
            Assert.AreEqual(drainageCode, dbWaterbody.Watershed.DrainageCode);
        }
コード例 #15
0
ファイル: WaterBodyTest.cs プロジェクト: nbadw/sjr_atlas
 public void TestProperties()
 {
     WaterBody waterbody = new WaterBody();
     Dictionary<string, object> properties = new Dictionary<string, object>();
     properties.Add("Abbreviation", "ABBREV");
     properties.Add("AltName", "Another Name");
     properties.Add("ComplexId", 12345);
     properties.Add("FlowsIntoWaterBodyId", 12345);
     properties.Add("FlowsIntoWaterBodyName", "TestValue");
     properties.Add("Id", 37);
     properties.Add("Name", "Saint John River");
     properties.Add("SurveyedInd", "TestValue");
     properties.Add("Type", "TestValue");
     TestHelper.ErrorSummary errors = TestHelper.TestProperties(waterbody, properties);
     Assert.IsEmpty(errors, "The following errors occurred during property testing:\n" + errors.GetSummary());
 }
コード例 #16
0
ファイル: WaterBodyTest.cs プロジェクト: nbadw/sjr_atlas
        public void TestFindByCgndbKeyOrAltCgndbKeyWhenWaterbodyHasCgndbKey()
        {
            string cgndbKey = "ABCDE";

            Place place = new Place();
            place.CgndbKey = cgndbKey;
            place.Create();

            WaterBody waterbody = new WaterBody();
            waterbody.Place = place;
            waterbody.Create();

            Flush();

            WaterBody foundWaterbody = WaterBody.FindByCgndbKeyOrAltCgndbKey(cgndbKey);
            Assert.AreEqual(waterbody, foundWaterbody);
            Assert.AreEqual(place, foundWaterbody.Place);
        }
コード例 #17
0
ファイル: WaterBodyTest.cs プロジェクト: nbadw/sjr_atlas
        public void TestRelatedInteractiveMapsNeverReturnsNull()
        {
            Assert.Ignore();

            WaterBody waterbody = new WaterBody();
            IList<InteractiveMap> interativeMaps = waterbody.RelatedInteractiveMaps;
            Assert.IsNotNull(interativeMaps);
            Assert.AreEqual(0, interativeMaps.Count);
        }
コード例 #18
0
 public static void UnregisterBody(WaterBody body)
 {
     WaterSystem.WaterBodies.Remove(body);
 }
コード例 #19
0
ファイル: WaterBodyTest.cs プロジェクト: nbadw/sjr_atlas
        public void TestRelatedInteractiveMapsWhenIsWithinBasin()
        {
            Assert.Ignore();

            string query = "place name is the default query";
            WaterBody waterbody = new WaterBody();
            waterbody.Name = query;

            Watershed watershed = mocks.CreateMock<Watershed>();
            waterbody.Watershed = watershed;

            Expect.Call(watershed.IsWithinBasin()).Return(true).Repeat.AtLeastOnce();
            mocks.ReplayAll();

            InteractiveMap[] interactiveMaps = new InteractiveMap[3];
            for (int i = 0; i < interactiveMaps.Length; i++)
            {
                interactiveMaps[i] = new InteractiveMap();
                interactiveMaps[i].Title = "Interactive Map where " + query + ": #" + i.ToString();
                interactiveMaps[i].IsBasinMap = (i % 2) == 0 ? true : false; // even to true, odd to false
                interactiveMaps[i].CreateAndFlush();
            }

            Assert.IsTrue(waterbody.IsWithinBasin());
            Assert.AreEqual(2, waterbody.RelatedInteractiveMaps.Count);
            mocks.VerifyAll();
        }
コード例 #20
0
ファイル: WaterBodyTest.cs プロジェクト: nbadw/sjr_atlas
        public void TestRelatedPublications()
        {
            Assert.Ignore();

            string query = "watershed name is the default query";
            WaterBody waterbody = new WaterBody();
            waterbody.Name = query;

            Publication[] publications = new Publication[3];
            for (int i = 0; i < publications.Length; i++)
            {
                publications[i] = new Publication();
                publications[i].Title = "Publication where " + query + ": #" + i.ToString();
                publications[i].CreateAndFlush();
            }

            Assert.AreEqual(publications.Length, waterbody.RelatedPublications.Count);
        }
コード例 #21
0
ファイル: WatershedTest.cs プロジェクト: nbadw/sjr_atlas
        public void TestHasManyWaterBodies()
        {
            string drainageCode = "01-02-03-04-05-06";
            int id1 = 1234;
            int id2 = 5678;

            Watershed watershed = new Watershed();
            watershed.DrainageCode = drainageCode;
            watershed.CreateAndFlush();

            WaterBody waterBody1 = new WaterBody();
            waterBody1.Id = id1;
            waterBody1.Watershed = watershed;
            waterBody1.CreateAndFlush();

            WaterBody waterBody2 = new WaterBody();
            waterBody2.Id = id2;
            waterBody2.Watershed = watershed;
            waterBody2.CreateAndFlush();

            watershed.WaterBodies.Add(waterBody1);
            watershed.WaterBodies.Add(waterBody2);
            watershed.SaveAndFlush();

            Watershed dbWatershed = Watershed.Find(drainageCode);
            Assert.IsNotNull(dbWatershed);
            Assert.AreEqual(2, dbWatershed.WaterBodies.Count);
            Assert.AreEqual(id1, dbWatershed.WaterBodies[0].Id);
            Assert.AreEqual(id2, dbWatershed.WaterBodies[1].Id);
        }
コード例 #22
0
ファイル: WatershedTest.cs プロジェクト: nbadw/sjr_atlas
        public void TestFindRelatedDataSets()
        {
            WaterBody waterBody1 = new WaterBody();
            WaterBody waterBody2 = new WaterBody();
            waterBody1.DataSets = new List<DataSet>(new DataSet[] { new DataSet(), new DataSet() });
            waterBody2.DataSets = new List<DataSet>(new DataSet[] { new DataSet(), new DataSet(), new DataSet() });

            Watershed watershed = new Watershed();
            watershed.WaterBodies.Add(waterBody1);
            watershed.WaterBodies.Add(waterBody2);
            Assert.AreEqual(5, watershed.DataSets.Count);
        }
コード例 #23
0
ファイル: WaterBodyTest.cs プロジェクト: nbadw/sjr_atlas
 public void TestGetCoordinate()
 {
     double lat = 3.7;
     double lon = 7.3;
     WaterBody waterbody = new WaterBody();
     waterbody.Place = new Place();
     waterbody.Place.Latitude = lat;
     waterbody.Place.Longitude = lon;
     LatLngCoord coordinate = waterbody.GetCoordinate();
     Assert.IsNotNull(coordinate);
     Assert.AreEqual(lat, coordinate.Latitude);
     Assert.AreEqual(lon, coordinate.Longitude);
 }
コード例 #24
0
ファイル: WaterBodyTest.cs プロジェクト: nbadw/sjr_atlas
        public void TestRelatedDataSets()
        {
            int id = 50001;
            WaterBody waterbody = new WaterBody();
            waterbody.Id = id;
            waterbody.CreateAndFlush();

            DataSet dataset1 = new DataSet();
            dataset1.CreateAndFlush();
            DataSet dataset2 = new DataSet();
            dataset2.CreateAndFlush();

            waterbody.DataSets.Add(dataset1);
            waterbody.DataSets.Add(dataset2);
            waterbody.SaveAndFlush();

            waterbody = WaterBody.Find(id);
            Assert.IsNotNull(waterbody);
            Assert.AreEqual(2, waterbody.DataSets.Count);
        }
コード例 #25
0
ファイル: WaterBodyTest.cs プロジェクト: nbadw/sjr_atlas
 public void TestGetCoordinateReturnsNullWhenPlaceIsNull()
 {
     WaterBody waterbody = new WaterBody();
     Assert.IsNull(waterbody.Place);
     Assert.IsNull(waterbody.GetCoordinate());
 }
コード例 #26
0
ファイル: WaterBodyTest.cs プロジェクト: nbadw/sjr_atlas
        public void TestExistsForCgndbKeyOrAltCgndbKeyWhenWaterbodyHasAltCgndbKey()
        {
            string altCgndbKey = "ABCDE";

            Place place = new Place();
            place.CgndbKey = altCgndbKey;
            place.Create();

            WaterBody waterbody = new WaterBody();
            waterbody.AltPlace = place;
            waterbody.Create();

            Flush();

            Assert.IsTrue(WaterBody.ExistsForCgndbKeyOrAltCgndbKey(altCgndbKey));
        }
コード例 #27
0
ファイル: WaterBodyTest.cs プロジェクト: nbadw/sjr_atlas
 public void TestIsWithinBasin()
 {
     WaterBody waterbody = new WaterBody();
     Watershed watershed = mocks.CreateMock<Watershed>();
     waterbody.Watershed = watershed;
     Expect.Call(watershed.IsWithinBasin()).Return(true);
     mocks.ReplayAll();
     Assert.IsTrue(waterbody.IsWithinBasin());
     mocks.VerifyAll();
 }
コード例 #28
0
ファイル: WaterBodyTest.cs プロジェクト: nbadw/sjr_atlas
        public void TestRelatedPublicationsNeverReturnsNull()
        {
            Assert.Ignore();

            WaterBody waterbody = new WaterBody();
            IList<Publication> publications = waterbody.RelatedPublications;
            Assert.IsNotNull(publications);
            Assert.AreEqual(0, publications.Count);
        }