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)); }
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)); }
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); }
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); }