コード例 #1
0
        public int InsertOrUpdate(AreaDto item)
        {
            var area = _mapper.Map <AreaMPZT>(item);

            if (!(item.Location == null))
            {
                var id = _locationRepository.InsertOrUpdate(area.Location);
                area.Location.Id = id;
            }

            int areaId = _areaRepository.InsertOrUpdate(area);

            if (area.GeoPoints.Count > 0)
            {
                var geopoints = new List <GeoPoint>();
                foreach (GeoPointDto point in item.GeoPoints)
                {
                    if (point.Latitude > 0 && point.Longitude > 0)
                    {
                        var geopoint = _mapper.Map <GeoPoint>(point);
                        var pointId  = _geopointRepository.InsertOrUpdate(geopoint);
                        geopoint.Id = pointId;
                        geopoints.Add(geopoint);
                    }
                    _areaRepository.AddGeoPointsToArea(geopoints, areaId);
                }
            }
            return(areaId);
        }
コード例 #2
0
ファイル: AreaRepositoryTests.cs プロジェクト: stysdor/MPZT
        public void AddGeopointsToAreaReturnFalseWhenListEmpty()
        {
            List <GeoPoint> points = new List <GeoPoint>();

            Assert.IsFalse(_areaRepository.AddGeoPointsToArea(points, 1));
        }