コード例 #1
0
        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();
        }
コード例 #2
0
        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;
            }
        }
コード例 #3
0
 public void Remove(VoceViuModel.Locations.Domain.Location location)
 {
     _context.Locations.Remove(location);
 }
コード例 #4
0
 public void Add(Location location)
 {
     _context.Locations.Add(location);
 }