コード例 #1
0
        public ModelEnvelope <FieldBoundary> Get(string source, string id)
        {
            SampleObjectsIdFactory.ValidateSource(source);

            var dto       = SampleRepository.Instance.FieldBoundaries.Single(z => z.Id == int.Parse(id));
            var converter = new FieldBoundaryDtoConverter(SampleObjectsIdFactory.Instance);

            return(converter.Convert(dto));
        }
コード例 #2
0
        public ModelEnvelope <Field> Get(string source, string id)
        {
            SampleObjectsIdFactory.ValidateSource(source);

            var dto       = SampleRepository.Instance.Fields.Single(f => f.Uid == new Guid(id));
            var converter = new FieldDtoConverter(SampleObjectsIdFactory.Instance);

            return(converter.Convert(dto));
        }
コード例 #3
0
        public IReadOnlyCollection <ModelEnvelope <Field> > GetByFarm(string source, string id)
        {
            SampleObjectsIdFactory.ValidateSource(source);

            var converter = new FieldDtoConverter(SampleObjectsIdFactory.Instance);

            var list = new List <ModelEnvelope <Field> >();

            foreach (var dto in SampleRepository.Instance.Fields.Where(f => f.FarmUid == new Guid(id)))
            {
                var envelope = converter.Convert(dto);
                list.Add(envelope);
            }

            return(list);
        }
コード例 #4
0
        public IReadOnlyCollection <ModelEnvelope <CropZone> > GetByField(string source, string id, int?cropYear)
        {
            SampleObjectsIdFactory.ValidateSource(source);

            var converter = new CropZoneDtoConverter(SampleObjectsIdFactory.Instance);

            var list  = new List <ModelEnvelope <CropZone> >();
            var zones = SampleRepository.Instance.CropZones.Where(z => z.FieldUid == new Guid(id));

            if (cropYear.HasValue)
            {
                zones = zones.Where(z => z.CropYear == cropYear);
            }

            foreach (var dto in zones)
            {
                var envelope = converter.Convert(dto);
                list.Add(envelope);
            }

            return(list);
        }