public async Task <IEnumerable <EntryPreviousItems> > EntryPreviousItems(List <string> includesLst = null)
        {
            if (System.ComponentModel.LicenseManager.UsageMode == LicenseUsageMode.Designtime)
            {
                return(new List <EntryPreviousItems>().AsEnumerable());
            }
            try
            {
                using (var t = new EntryPreviousItemsClient())
                {
                    var res = await t.GetEntryPreviousItems(includesLst).ConfigureAwait(continueOnCapturedContext: false);

                    if (res != null)
                    {
                        return(res.Select(x => new EntryPreviousItems(x)).AsEnumerable());
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            catch (FaultException <ValidationFault> e)
            {
                throw new Exception(e.Detail.Message, e.InnerException);
            }
            catch (Exception)
            {
                Debugger.Break();
                throw;
            }
        }
        public async Task <EntryPreviousItems> GetEntryPreviousItems(string id, List <string> includesLst = null)
        {
            try
            {
                using (var t = new EntryPreviousItemsClient())
                {
                    var res = await t.GetEntryPreviousItemsByKey(id, includesLst).ConfigureAwait(continueOnCapturedContext: false);

                    if (res != null)
                    {
                        return(new EntryPreviousItems(res)
                        {
                            // AsycudaDocumentItem = (res.AsycudaDocumentItem != null?new AsycudaDocumentItem(res.AsycudaDocumentItem): null)
                        });
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            catch (FaultException <ValidationFault> e)
            {
                throw new Exception(e.Detail.Message, e.InnerException);
            }
            catch (Exception)
            {
                Debugger.Break();
                throw;
            }
        }
        public async Task <IEnumerable <EntryPreviousItems> > GetEntryPreviousItemsByItem_Id(string Item_Id, List <string> includesLst = null)
        {
            if (Item_Id == "0")
            {
                return(null);
            }
            try
            {
                using (EntryPreviousItemsClient t = new EntryPreviousItemsClient())
                {
                    var res = await t.GetEntryPreviousItemsByItem_Id(Item_Id, includesLst).ConfigureAwait(continueOnCapturedContext: false);

                    if (res != null)
                    {
                        return(res.Select(x => new EntryPreviousItems(x)).AsEnumerable());
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            catch (FaultException <ValidationFault> e)
            {
                throw new Exception(e.Detail.Message, e.InnerException);
            }
            catch (Exception)
            {
                Debugger.Break();
                throw;
            }
        }
 public async Task <decimal> SumNav(string whereExp, Dictionary <string, string> navExp, string sumExp)
 {
     try
     {
         using (var t = new EntryPreviousItemsClient())
         {
             return(await t.SumNav(whereExp, navExp, sumExp).ConfigureAwait(false));
         }
     }
     catch (FaultException <ValidationFault> e)
     {
         throw new Exception(e.Detail.Message, e.InnerException);
     }
     catch (Exception)
     {
         Debugger.Break();
         throw;
     }
 }
 public decimal SumField(string whereExp, string sumExp)
 {
     try
     {
         using (var t = new EntryPreviousItemsClient())
         {
             return(t.SumField(whereExp, sumExp));
         }
     }
     catch (FaultException <ValidationFault> e)
     {
         throw new Exception(e.Detail.Message, e.InnerException);
     }
     catch (Exception)
     {
         Debugger.Break();
         throw;
     }
 }
 public async Task <bool> DeleteEntryPreviousItems(string id)
 {
     try
     {
         using (var t = new EntryPreviousItemsClient())
         {
             return(await t.DeleteEntryPreviousItems(id).ConfigureAwait(continueOnCapturedContext: false));
         }
     }
     catch (FaultException <ValidationFault> e)
     {
         throw new Exception(e.Detail.Message, e.InnerException);
     }
     catch (Exception)
     {
         Debugger.Break();
         throw;
     }
 }
 public async Task <EntryPreviousItems> CreateEntryPreviousItems(EntryPreviousItems entity)
 {
     try
     {
         using (var t = new EntryPreviousItemsClient())
         {
             return(new EntryPreviousItems(await t.CreateEntryPreviousItems(entity.DTO).ConfigureAwait(continueOnCapturedContext: false)));
         }
     }
     catch (FaultException <ValidationFault> e)
     {
         throw new Exception(e.Detail.Message, e.InnerException);
     }
     catch (Exception)
     {
         Debugger.Break();
         throw;
     }
 }
        //Virtural List Implementation

        public async Task <Tuple <IEnumerable <EntryPreviousItems>, int> > LoadRange(int startIndex, int count, string exp, Dictionary <string, string> navExp, IEnumerable <string> includeLst = null)
        {
            var overallCount = 0;

            if (System.ComponentModel.LicenseManager.UsageMode == LicenseUsageMode.Designtime || exp == null || exp == "None")
            {
                return(new Tuple <IEnumerable <EntryPreviousItems>, int>(new List <EntryPreviousItems>().AsEnumerable(), overallCount));
            }

            try
            {
                using (var t = new EntryPreviousItemsClient())
                {
                    IEnumerable <DTO.EntryPreviousItems> res = null;

                    res = await t.LoadRangeNav(startIndex, count, exp, navExp, includeLst).ConfigureAwait(continueOnCapturedContext: false);

                    overallCount = await t.CountNav(exp, navExp).ConfigureAwait(continueOnCapturedContext: false);



                    if (res != null)
                    {
                        return(new Tuple <IEnumerable <EntryPreviousItems>, int>(res.Select(x => new EntryPreviousItems(x)).AsEnumerable(), overallCount));
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            catch (FaultException <ValidationFault> e)
            {
                throw new Exception(e.Detail.Message, e.InnerException);
            }
            catch (Exception)
            {
                Debugger.Break();
                throw;
            }
        }
        public async Task <IEnumerable <EntryPreviousItems> > GetEntryPreviousItemsByExpressionNav(string exp, Dictionary <string, string> navExp, List <string> includesLst = null)
        {
            if (System.ComponentModel.LicenseManager.UsageMode == LicenseUsageMode.Designtime || exp == null || exp == "None")
            {
                return(new List <EntryPreviousItems>().AsEnumerable());
            }
            try
            {
                using (var t = new EntryPreviousItemsClient())
                {
                    IEnumerable <DTO.EntryPreviousItems> res = null;
                    if (exp == "All" && navExp.Count == 0)
                    {
                        res = await t.GetEntryPreviousItems(includesLst).ConfigureAwait(continueOnCapturedContext: false);
                    }
                    else
                    {
                        res = await t.GetEntryPreviousItemsByExpressionNav(exp, navExp, includesLst).ConfigureAwait(continueOnCapturedContext: false);
                    }

                    if (res != null)
                    {
                        return(res.Select(x => new EntryPreviousItems(x)).AsEnumerable());
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            catch (FaultException <ValidationFault> e)
            {
                throw new Exception(e.Detail.Message, e.InnerException);
            }
            catch (Exception)
            {
                Debugger.Break();
                throw;
            }
        }
        public async Task <EntryPreviousItems> UpdateEntryPreviousItems(EntryPreviousItems entity)
        {
            if (entity == null)
            {
                return(entity);
            }
            var entitychanges = entity.ChangeTracker.GetChanges().FirstOrDefault();

            if (entitychanges != null)
            {
                try
                {
                    using (var t = new EntryPreviousItemsClient())
                    {
                        var updatedEntity = await t.UpdateEntryPreviousItems(entitychanges).ConfigureAwait(false);

                        entity.EntityId = updatedEntity.EntityId;
                        entity.DTO.AcceptChanges();
                        //var  = entity.;
                        //entity.ChangeTracker.MergeChanges(,updatedEntity);
                        //entity. = ;
                        return(entity);
                    }
                }
                catch (FaultException <ValidationFault> e)
                {
                    throw new Exception(e.Detail.Message, e.InnerException);
                }
                catch (Exception)
                {
                    Debugger.Break();
                    throw;
                }
            }
            else
            {
                return(entity);
            }
        }