Beispiel #1
0
        public async Task <ServiceDTO> FindById(int id)
        {
            Service service = await _context.Services
                              .Find(Builders <Service> .Filter.Eq(s => s.Id, id))
                              .FirstOrDefaultAsync();

            if (service == null)
            {
                return(null);
            }

            return(ServiceDTO.FromService(service));
        }
Beispiel #2
0
        public async Task <IEnumerable <ServiceDTO> > FindAll()
        {
            IEnumerable <Service> services = await _context.Services.Find(_ => true).ToListAsync();

            List <ServiceDTO> result = new List <ServiceDTO>();

            foreach (Service service in services)
            {
                result.Add(ServiceDTO.FromService(service));
            }

            return(result);
        }