public async Task <OfferDTO> Insert(OfferDTO dto) { Counter counter = await _counterDAO.GetCountersAsync(); int id = counter.Offers++; await _counterDAO.UpdateCountersAsync(counter); Offer offer = Offer.FromDTO(dto); offer.Id = id; await _context.Offers.InsertOneAsync(offer); return(OfferDTO.FromOffer(offer)); }
public async Task <UserDTO> Insert(UserDTO dto) { Counter counter = await _counterDAO.GetCountersAsync(); int id = counter.Users++; await _counterDAO.UpdateCountersAsync(counter); User user = User.FromDTO(dto); user.Id = id; await _context.Users.InsertOneAsync(user); return(UserDTO.FromUser(user)); }
public async Task <SubscriptionDTO> insertAsync(SubscriptionDTO dto) { Counter counter = await _counterDAO.GetCountersAsync(); int id = counter.Subscriptions++; await _counterDAO.UpdateCountersAsync(counter); Subscription subscription = Subscription.FromDTO(dto); subscription.Id = id; await _context.Subscriptions.InsertOneAsync(subscription); return(SubscriptionDTO.FromSubscription(subscription)); }
public async Task <PublicationDTO> Insert(PublicationDTO dto) { Counter counter = await _counterDAO.GetCountersAsync(); int id = counter.Publications++; await _counterDAO.UpdateCountersAsync(counter); Publication publication = Publication.FromDTO(dto); publication.Id = id; await _context.Publications.InsertOneAsync(publication); return(FindById(publication.Id).Result); }
public async Task <TradeDTO> Insert(TradeDTO dto) { Counter counter = await _counterDAO.GetCountersAsync(); int id = counter.Trades++; await _counterDAO.UpdateCountersAsync(counter); Trade trade = Trade.FromDTO(dto); trade.Id = id; await _context.Trades.InsertOneAsync(trade); return(TradeDTO.FromTrade(trade)); }
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)); }