Exemplo n.º 1
0
        public void Test_AddSameLocationTwice()
        {
            LocationRepository repository = LocationRepository.GetInstance();

            repository.AddLocation(location1);
            repository.AddLocation(location1);
        }
Exemplo n.º 2
0
        public void Test_UpdateLocationAlreadyExists()
        {
            LocationRepository repository = LocationRepository.GetInstance();

            repository.AddLocation(location1);
            repository.AddLocation(location2);

            location2.Name = "Medulin";
            repository.UpdateLocation(0, location2);
        }
Exemplo n.º 3
0
        public void AddLocation([FromBody] LocationDto.In location)
        {
            var user = _userRepository.GetUserByDeviceId(location.DeviceId);

            _locationRepository.AddLocation(new LocationDao
            {
                Latitude  = location.Latitude,
                Longitude = location.Longitude,
                UserId    = user.UserId,
                Time      = location.Time
            });
        }
Exemplo n.º 4
0
        public ActionResult Create([Bind(Include = "id,name,address")] Location location)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    lr.AddLocation(location);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }

            return(View(location));
        }
Exemplo n.º 5
0
        public LocationController()
        {
            if (LocationRepository.LocationList.Count == 0)
            {
                Location location = new Location()
                {
                    Title   = "Lane Community College",
                    Address = "4000 E 30th Ave, Eugene, OR 97405",
                    About   = "This is the gathering place of the current community."
                };
                LocationRepository.AddLocation(location);

                Location newLocation1 = new Location()
                {
                    Title   = "Tiger's Den",
                    Address = "6552 W Someplace Ave, Eugene, OR 97401",
                    About   = "This is an imaginary bar for our favorite community members."
                };
                LocationRepository.AddLocation(newLocation1);

                Location newLocation2 = new Location()
                {
                    Title   = "Wandering Goat",
                    Address = "3717 E Somewhere Ave, Eugene, OR 97405",
                    About   = "This is the urban watering hole."
                };
                LocationRepository.AddLocation(newLocation2);
            }
        }
Exemplo n.º 6
0
        // Link: http://geowebservice.azurewebsites.net/Api/Geo
        //private string HARDCODEDDATA = "$GPGGA,110730.000,5049.4781,N,00314.9857,E,1,10,0.9,44.9,M,47.2,M,,0000*6F\r\n$GPGSA,A,3,07,30,15,20,09,05,28,21,13,10,,,1.5,0.9,1.2*38\r\n$GPGSV,3,1,12,30,70,079,34,05,67,250,21,13,47,281,20,07,39,057,45*73\r\n$GPGSV,3,2,12,20,39,170,21,28,29,141,20,10,28,157,24,15,12,281,32*72\r\n$GPGSV,3,3,12,02,08,219,,09,08,097,23,21,08,330,22,27,04,026,30*79\r\n$GPRMC,110730.000,A,5049.4781,N,00314.9857,E,0.61,161.13,260315,,*00\r\n$GPVTG,161.13,T,,M,0.61,N,1.1,K*63\r\n$GPGGA,110731.000,5049.4777,N,00314.9859,E,1,10,0.9,44.1,M,47.2,M,,0000*61\r\n$GPGSA,A,3,07,30,15,20,09,05,28,21,13,10,,,1.5,0.9,1.2*38\r\n$GPRMC,110731.000,A,5049.4777,N,00314.9859,E,0.24,107.31,260315,,*07\r\n$GPVTG,107.31,T,,M,0.24,N,0.4,K*66\r\n$GPGGA,110732.000,5049.4776,N,00314.9861,E,1,10,0.9,43.7,M,47.2,M,,0000*69\r\n$GPGSA,A,3,07,30,15,20,09,05,28,21,13,10,,,1.5,0.9,1.2*38\r\n$GPRMC,110732.000,A,5049.4776,N,00314.9861,E,0.32,86.57,260315,,*31\r\n$GPVTG,86.57,T,,M,0.32,N,0.6,K*5B\r\n";
        // text


        public void Get(int id)
        {
            LocationRepository LocRepo = new LocationRepository();

            LocRepo.ClearDb();

            while (1 > 0)
            {
                System.Threading.Thread.Sleep(5000);

                SerialPortHelpers SerialPort = new SerialPortHelpers();
                Location          Location   = new Location();
                SerialPort.Init();
                SerialPort.Open();
                System.Threading.Thread.Sleep(5000);
                string data = SerialPort.ReadExisting();
                Location           = SerialPort.GetLocation(data);
                Location.TimeStamp = DateTime.Now;

                if (Location.Altitude != null && Location.Latitude != null && Location.Longitude != null)
                {
                    if (Location.Altitude.Value != "" && Location.Latitude.Value != "" && Location.Longitude.Value != "")
                    {
                        LocRepo.AddLocation(Location);
                    }
                }

                if (LocRepo.GetAmmountOfLocations() > 100)
                {
                    LocRepo.ClearDb();
                }
                Console.WriteLine("Location Updated:" + "Latitude: " + Location.Latitude + ", Longtitude : " + Location.Longitude + ", Altitude : " + Location.Longitude + ".");
                SerialPort.Close();
            }
        }
Exemplo n.º 7
0
        public void Test_AddLocation()
        {
            LocationRepository repository = LocationRepository.GetInstance();

            repository.AddLocation(location1);

            Assert.AreEqual(1, repository.Count());
        }
Exemplo n.º 8
0
        public void Test_GetLocationByNameDoesntExist()
        {
            LocationRepository repository = LocationRepository.GetInstance();

            repository.AddLocation(location1);
            Location locationGet = repository.GetLocation("Pula");

            Assert.AreEqual(location1, locationGet);
        }
Exemplo n.º 9
0
        public void Test_GetLocationByName()
        {
            LocationRepository repository = LocationRepository.GetInstance();

            repository.AddLocation(location1);
            Location locationGet = repository.GetLocation("Medulin");

            Assert.AreEqual(location1, locationGet);
        }
Exemplo n.º 10
0
        public void Test_UpdateLocation()
        {
            LocationRepository repository = LocationRepository.GetInstance();

            repository.AddLocation(location1);
            repository.UpdateLocation(0, location2);
            Location locationGet = repository.GetLocation(0);

            Assert.AreEqual(location1, locationGet);
            Assert.AreEqual(15, locationGet.Depth);
        }
Exemplo n.º 11
0
        private static void CreateLocations()
        {
            LocationRepository repo = new LocationRepository(context);

            Location projectName = new Location();

            projectName.Description = "St. Teilo School";
            int locationId = repo.AddLocation(projectName);

            Location groundFloor = new Location();

            groundFloor.Description = "Ground Floor";
            groundFloor.ParentId    = locationId;
            repo.AddLocation(groundFloor);

            Location firstFloor = new Location();

            firstFloor.Description = "First Floor";
            firstFloor.ParentId    = locationId;
            repo.AddLocation(firstFloor);
        }
Exemplo n.º 12
0
        public async Task AddLocation(DomainLocation newLocation, string travelIdentity)
        {
            var location = LocationConverter.ToDbLocation(newLocation);
            var tours    = await TriposoApiClient.GetTourInformation(location.Name);

            var toursDb = tours.Select(t => TourConverter.ToDbTour(t));

            foreach (var t in toursDb)
            {
                await TourRepository.AddTour(t, travelIdentity);
            }
            await LocationRepository.AddLocation(location, travelIdentity);
        }
        public void Test_Transfer_When_VehicleObj_Null_ShouldReturnFalse()
        {
            _vehicleRepository.ClearRepository();
            _locationRepository.ClearRepository();
            _vehicleRepository.AddVehicle("HONDA", "2015", "CR", "ABCDEFGH1234567891234567", VehicleTypes.Semi, VehicleStatus.Repair);

            _locationRepository.AddLocation(1, LocationType.Branch);
            _locationRepository.AddLocation(2, LocationType.Branch);

            Location fromLocation = _locationRepository.GetLocationById(1);
            Location toLocation   = _locationRepository.GetLocationById(2);

            //Invaild Vin, Transfer should fail
            Assert.IsFalse(_vehicleTransfer.Transfer(fromLocation.LocationId, toLocation.LocationId, "ABCDEFGH1234567891234522"));
        }
Exemplo n.º 14
0
        public async Task <ActionResult> Create(LocationViewModel viewModel)
        {
            _locationRepository.AddLocation(viewModel);

            if (viewModel.Location != null)
            {
                _landmarkRepository.AddLandmark(await _landmarkGenerator.GetLandmarkDataByLocationAsync(viewModel), viewModel.Location);
            }

            if (viewModel.Latitude != null && viewModel.Logitude != null)
            {
                _landmarkRepository.AddLandmark(await _landmarkGenerator.GetLandmarkDataByLatLonAsync(viewModel), viewModel.Location);
            }

            return(RedirectToAction("List", "Landmarks", new { Id = _locationRepository.GetLocation(viewModel.Location) }));
        }
Exemplo n.º 15
0
        public void Test_DeleteLocationThanIsPartOfAFishingRecord()
        {
            LocationRepository locRepository = LocationRepository.GetInstance();

            locRepository.AddLocation(location1);

            FishingRecordRepository recRepository = FishingRecordRepository.GetInstance();

            recRepository.DeleteAllRecords();
            FishingRecord record = EntityGenerator.GetFishingRecord1();

            record.Location = location1;
            recRepository.AddRecord(record);

            locRepository.DeleteLocation(0);
        }
Exemplo n.º 16
0
        public int Generate([FromBody] GenerationDto dto)
        {
            var a = _infectionManager.GetDistance(_longitudeDownBoundary + _longStep, _latitudeDownBoundary + _latStep,
                                                  _longitudeDownBoundary, _latitudeDownBoundary);
            var random    = new Random();
            var contacted = new List <int>();
            var i         = 0;

            for (; contacted.Count < dto.ContactQuantity; i++)
            {
                var beginDate = new DateTime(2020, 6, 10, 10, 10, 10);
                var endDate   = beginDate.AddSeconds(dto.LengthInSeconds);
                _userRepository.AddUser(i.ToString(), i.ToString(), false);
                var userId = _userRepository.GetUserByDeviceId(i.ToString()).UserId;

                var lastPosition = (random.NextDouble() * (dto.LatTo - dto.LatFrom) + dto.LatFrom,
                                    random.NextDouble() * (dto.LongTo - dto.LongFrom) + dto.LongFrom);
                while (beginDate < endDate)
                {
                    _locationRepository.AddLocation(new LocationDao
                    {
                        Latitude  = lastPosition.Item1,
                        Longitude = lastPosition.Item2,
                        UserId    = userId,
                        Time      = beginDate
                    });
                    lastPosition = (lastPosition.Item1 + dto.StepLength * (random.NextDouble() * 2 - 1),
                                    lastPosition.Item2 + dto.StepLength * (random.NextDouble() * 2 - 1));
                    beginDate = beginDate.AddSeconds(dto.StepInSeconds);
                }

                var contact = _infectionManager.SimpleCheckUserWhoHadContact(userId);
                if (contact.Count > 0)
                {
                    contacted.Add(userId);
                    contacted.AddRange(contact);
                    contacted = contacted.Distinct().ToList();
                }
            }

            return(i);
        }
Exemplo n.º 17
0
 private void AddLocation(Location location) => _locationRepository.AddLocation(location);
Exemplo n.º 18
0
        public ActionResult AddLocation(CreateLocationRequest newLocation)
        {
            var newLocations = _locationRepository.AddLocation(newLocation);

            return(Ok(newLocations));
        }