[HttpGet("oneshotposition")] //temporary for OLD GPS Integration during development phase public void GetPositionsfromfile() { using (StreamReader r = new StreamReader("getPositions.json")) { var json = r.ReadToEnd(); var data = JsonConvert.DeserializeObject <Rootobject>(json); foreach (var pos in data.positionarray) { _positionRepo.Add(pos); } } }
public void UpdateAll(List <Position> positionsFetched) { var positions = _repository.GetAll(); // Delete should be cascade if it's necessary // foreach (var position in positions) // { // if (!positionsFetched.Select(v => v.Id).Contains(position.Id)) // _repository.Delete(position); // } foreach (var positionFetched in positionsFetched) { var foundPosition = positions.SingleOrDefault(v => v.Id == positionFetched.Id); if (foundPosition == null) { _repository.Add(positionFetched); } else { var name = positionFetched.Name.Trim(); if (foundPosition.Name != name) { foundPosition.Name = name; _repository.Update(foundPosition); } } } }
public void Create(Position position) { if (position == null) { throw new ArgumentNullException(nameof(position)); } _repository.Add(position); }