public void Add(SaveLocationMessage message)
        {
            var location = new Location();
            location.IP = message.IP;
            location.Name = message.Name;
            location.PublicType = message.PublicType;
            location.Spot = message.Spot;
            location.MonthlyValue = message.MonthlyValue;
            foreach (var pointVm in message.Points)
                location.Points.Add(new Point { Name = pointVm.Name });

            _locationRepository.Add(location);
            _locationRepository.SaveChanges();
        }
        private void UpdatePoints(SaveLocationMessage message, Location location)
        {
            var requestPointsIds = message.Points.Where(p => p.Id.HasValue).Select(p => p.Id.Value);
            var excludedPointsIds = location.Points.Select(p => p.Id).Where(i => !requestPointsIds.Contains(i));

            foreach (var excludedId in excludedPointsIds)
            {
                var point = location.Points.FirstOrDefault(p => p.Id == excludedId);
                location.Points.Remove(point);
            }

            foreach (var pointVm in message.Points.Where(vm => !vm.Id.HasValue))
                location.Points.Add(new Point { Name = pointVm.Name });

            foreach (var pointVm in message.Points.Where(vm => vm.Id.HasValue))
            {
                var point = location.Points.FirstOrDefault(p => p.Id == pointVm.Id.Value);
                point.Name = pointVm.Name;
            }
        }
 public void Remove(VoceViuModel.Locations.Domain.Location location)
 {
     _context.Locations.Remove(location);
 }
 public void Add(Location location)
 {
     _context.Locations.Add(location);
 }