public void AddTest() { Init(); Assert.AreEqual(dataRepository.GetLocationsIds().Count, 5); dataRepository.AddLocation(6, "F", 10, 20, new DateTime(2020, 1, 1)); Assert.AreEqual(dataRepository.GetLocationsIds().Count, 6); }
public void Init() { dataRepository = new DataRepositoryInMemory(); dataRepository.AddLocation(1, "A", 10, 20, new DateTime(2020, 1, 1)); dataRepository.AddLocation(2, "B", 10, 20, new DateTime(2020, 1, 1)); dataRepository.AddLocation(3, "C", 10, 20, new DateTime(2020, 1, 1)); dataRepository.AddLocation(4, "D", 10, 20, new DateTime(2020, 1, 1)); dataRepository.AddLocation(5, "E", 10, 20, new DateTime(2020, 1, 1)); }
public string CreateLocation(short id, string name, decimal costRate, decimal availability, DateTime modifiedDate) { Location location = new Location(); location.LocationID = id; location.Name = name; location.CostRate = costRate; location.Availability = availability; location.ModifiedDate = modifiedDate; return(dataRepository.AddLocation(new DataLocation(location))); }
public ActionResult <Responce> AddLocation(string device_id, double lat, double lon, int radius) { try { var person = _repository.GetPerson(device_id); if (person == null || person.HasQuarantineStop) { return new Responce() { IsOk = false, Error = "Вас нет в карантине или карантин закончен для вас" } } ; if (person.HasQuarantineStop || person.LastLocationUpdateRequest < DateTime.UtcNow.AddSeconds(-30)) { return new Responce() { IsOk = true } } ; if (lat > -90 && lat < 90 && lon > -180 && lon < 180) { if (_repository.AddLocation(device_id, lat, lon, radius)) { return new Responce() { IsOk = true } } ; } return(new Responce() { IsOk = false, Error = "Координаты неизвестны" }); } catch (Exception e) { return(new Responce() { IsOk = false, Error = e.Message }); } }