示例#1
0
        public async Task <NetworkDTO> Insert(NetworkDTO dto)
        {
            Counter counter = await _counterDAO.GetCountersAsync();

            int id = counter.Networks++;
            await _counterDAO.UpdateCountersAsync(counter);

            Network network = Network.FromDTO(dto);

            network.Id = id;

            await _context.Networks.InsertOneAsync(network);

            return(NetworkDTO.FromNetwork(network));
        }
示例#2
0
        public async Task <IEnumerable <NetworkDTO> > FindAll()
        {
            IEnumerable <Network> networks = await _context.Networks.Find(_ => true).ToListAsync();

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

            foreach (Network network in networks)
            {
                NetworkDTO dto = NetworkDTO.FromNetwork(network);
                dto = await joinWithSubscriptionAsync(dto);

                result.Add(dto);
            }

            return(result);
        }
示例#3
0
        public async Task <NetworkDTO> FindById(int id)
        {
            Network network = await _context.Networks
                              .Find(Builders <Network> .Filter.Eq(u => u.Id, id))
                              .FirstOrDefaultAsync();

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

            NetworkDTO dto = NetworkDTO.FromNetwork(network);

            dto = await joinWithSubscriptionAsync(dto);

            return(dto);
        }