Example #1
0
        private async Task <OrderingFlatDetailItem> GetOrderingDetailItemInternal(int id, bool nichtSichtbarEinsehen = false)
        {
            var ctx      = new ViaducContext(WebHelper.Settings["sqlConnectionString"]);
            var flatItem = ctx.OrderingFlatItem.FirstOrDefault(i => i.ItemId == id);

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

            var item = new OrderingFlatDetailItem();

            item.FromFlatItem(flatItem);

            if (flatItem.VeId.HasValue)
            {
                var elasticItem = await GetElasticArchiveRecord(flatItem.VeId.Value.ToString());

                if (elasticItem != null)
                {
                    var ancestors = GetAncestors(elasticItem);
                    item.ArchivplanKontext = ancestors;

                    if (nichtSichtbarEinsehen)
                    {
                        var snapshot = OrderHelper.GetOrderingIndexSnapshot(elasticItem);
                        OrderHelper.ApplySnapshotToDetailItem(snapshot, item.Item);
                    }
                }
                else
                {
                    Log.Warning("elasticRecord nicht gefunden ");
                }

                var orderHistory = (await orderManagerClient.GetOrderingHistoryForVe(flatItem.VeId.Value)).ToList();
                item.OrderingHistory        = orderHistory.Take(3);
                item.HasMoreOrderingHistory = orderHistory.Count > 3;
            }

            var statusHistory = await orderManagerClient.GetStatusHistoryForOrderItem(flatItem.ItemId);

            item.StatusHistory = statusHistory;
            return(item);
        }