Esempio n. 1
0
        /// <summary>
        /// Gets an <see cref="IInvoice"/>.
        /// </summary>
        /// <param name="key">
        /// The key.
        /// </param>
        /// <returns>
        /// The <see cref="IInvoice"/>.
        /// </returns>
        protected override IInvoice PerformGet(Guid key)
        {
            var sql = GetBaseQuery(false)
              .Where(GetBaseWhereClause(), new { Key = key });

            var dto = Database.Fetch<InvoiceDto, InvoiceIndexDto, InvoiceStatusDto>(sql).FirstOrDefault();

            if (dto == null)
                return null;

            var lineItems = GetLineItemCollection(key);
            var orders = GetOrderCollection(key);
            var factory = new InvoiceFactory(lineItems, orders);
            return factory.BuildEntity(dto);
        }