public MarketOrder CreateMarketOrder(decimal filledPrice, decimal fee, decimal size, DateTime date, bool buy, int portfolioEntryId) { // create a MarketOrder instance var order = new MarketOrder(filledPrice, fee, size, date, buy, PortfolioEntryId: portfolioEntryId); // add it to the repository var id = _marketOrderRepository.Add(order); // return the created instance with the ID generated by the repository return(order with { Id = id }); }