internal async void OnCurrentOverShortAllocationsEXIDChanged(object sender, NotificationEventArgs <string> e)
 {
     using (OverShortAllocationsEXRepository ctx = new OverShortAllocationsEXRepository())
     {
         CurrentOverShortAllocationsEX = await ctx.GetOverShortAllocationsEX(e.Data).ConfigureAwait(continueOnCapturedContext: false);
     }
     NotifyPropertyChanged(m => CurrentOverShortAllocationsEX);
 }
        public async Task SelectAll()
        {
            IEnumerable <OverShortAllocationsEX> lst = null;

            using (var ctx = new OverShortAllocationsEXRepository())
            {
                lst = await ctx.GetOverShortAllocationsEXesByExpressionNav(vloader.FilterExpression, vloader.NavigationExpression).ConfigureAwait(continueOnCapturedContext: false);
            }
            SelectedOverShortAllocationsEXes = new ObservableCollection <OverShortAllocationsEX>(lst);
        }
        private async void OnOverShortAllocationsEXesFilterExpressionChangetals(object sender, SimpleMvvmToolkit.NotificationEventArgs <string> e)
        {
            using (var ctx = new OverShortAllocationsEXRepository())
            {
                TotalAllocatedValue = await ctx.SumNav(e.Data, vloader.NavigationExpression, "AllocatedValue").ConfigureAwait(false);

                TotalReceivedValue = await ctx.SumNav(e.Data, vloader.NavigationExpression, "ReceivedValue").ConfigureAwait(false);

                TotalInvoiceValue = await ctx.SumNav(e.Data, vloader.NavigationExpression, "InvoiceValue").ConfigureAwait(false);
            }
        }
        public IList <OverShortAllocationsEX> LoadRange(int startIndex, int count, SortDescriptionCollection sortDescriptions, out int overallCount)
        {
            try
            {
                if (FilterExpression == null)
                {
                    FilterExpression = "All";
                }
                using (var ctx = new OverShortAllocationsEXRepository())
                {
                    var r = ctx.LoadRange(startIndex, count, FilterExpression, navExp, IncludesLst);
                    overallCount = r.Result.Item2;

                    return(r.Result.Item1.ToList());
                }
            }
            catch (Exception ex)
            {
                StatusModel.Message(ex.Message);
                overallCount = 0;
                return(new List <OverShortAllocationsEX>());
            }
        }
// Send to Excel Implementation


        public async Task Send2Excel()
        {
            IEnumerable <OverShortAllocationsEX> lst = null;

            using (var ctx = new OverShortAllocationsEXRepository())
            {
                lst = await ctx.GetOverShortAllocationsEXesByExpressionNav(vloader.FilterExpression, vloader.NavigationExpression).ConfigureAwait(continueOnCapturedContext: false);
            }
            if (lst == null || !lst.Any())
            {
                MessageBox.Show("No Data to Send to Excel");
                return;
            }
            var s = new ExportToExcel <OverShortAllocationsEXExcelLine, List <OverShortAllocationsEXExcelLine> >
            {
                dataToPrint = lst.Select(x => new OverShortAllocationsEXExcelLine
                {
                    ReceivedQty = x.ReceivedQty,


                    ItemNumber = x.ItemNumber,


                    ItemDescription = x.ItemDescription,


                    Cost = x.Cost,


                    InvoiceQty = x.InvoiceQty,


                    InvoiceNo = x.InvoiceNo,


                    InvoiceDate = x.InvoiceDate,


                    CNumber = x.CNumber,


                    RegistrationDate = x.RegistrationDate,


                    Duration = x.Duration,


                    InvoiceMonth = x.InvoiceMonth,


                    AsycudaMonth = x.AsycudaMonth,


                    AllocatedValue = x.AllocatedValue,


                    ReceivedValue = x.ReceivedValue,


                    InvoiceValue = x.InvoiceValue,


                    LineNumber = Convert.ToInt16(x.LineNumber),


                    PiQuantity = x.PiQuantity,


                    OverShortDetailStatus = x.OverShortDetailStatus,


                    QtyAllocated = x.QtyAllocated,


                    AllocationStatus = x.AllocationStatus
                }).ToList()
            };

            using (var sta = new StaTaskScheduler(numberOfThreads: 1))
            {
                await Task.Factory.StartNew(s.GenerateReport, CancellationToken.None, TaskCreationOptions.None, sta).ConfigureAwait(false);
            }
        }