Exemplo n.º 1
0
        public IEnumerable <TransactionHeaderDTO> GetAll(SearchCriteria <TransactionHeaderDTO> criteria,
                                                         out int totalCount)
        {
            totalCount = 0;
            IEnumerable <TransactionHeaderDTO> piList = new List <TransactionHeaderDTO>();

            try
            {
                if (criteria != null && criteria.CurrentUserId != -1)
                {
                    var warehouseList = new WarehouseService(true)
                                        .GetWarehousesPrevilegedToUser(criteria.CurrentUserId).ToList();

                    if (criteria.TransactionType == (int)TransactionTypes.TransferStock)
                    {
                        warehouseList = new WarehouseService(true).GetAll().ToList();
                    }

                    if (criteria.SelectedWarehouseId != null)
                    {
                        warehouseList = warehouseList.Where(w => w.Id == criteria.SelectedWarehouseId).ToList();
                    }


                    foreach (var warehouse in warehouseList.Where(w => w.Id != -1))
                    {
                        var pdto = Get();

                        foreach (var cri in criteria.FiList)
                        {
                            pdto.FilterList(cri);
                        }

                        pdto.FilterList(p => p.TransactionType == (TransactionTypes)criteria.TransactionType);

                        #region By Warehouse

                        var warehouse1 = warehouse;
                        pdto.FilterList(p => p.WarehouseId == warehouse1.Id);

                        #endregion

                        #region By Duration

                        if (criteria.BeginingDate != null)
                        {
                            var beginDate = new DateTime(criteria.BeginingDate.Value.Year, criteria.BeginingDate.Value.Month,
                                                         criteria.BeginingDate.Value.Day, 0, 0, 0);
                            if (criteria.Shift == ShiftTypes.Afternoon)
                            {
                                beginDate = new DateTime(criteria.BeginingDate.Value.Year, criteria.BeginingDate.Value.Month,
                                                         criteria.BeginingDate.Value.Day, 14, 0, 0);
                            }
                            pdto.FilterList(p => p.TransactionDate >= beginDate);
                        }

                        if (criteria.EndingDate != null)
                        {
                            var endDate = new DateTime(criteria.EndingDate.Value.Year, criteria.EndingDate.Value.Month,
                                                       criteria.EndingDate.Value.Day, 23, 59, 59);
                            if (criteria.Shift == ShiftTypes.Morning)
                            {
                                endDate = new DateTime(criteria.EndingDate.Value.Year, criteria.EndingDate.Value.Month,
                                                       criteria.EndingDate.Value.Day, 13, 59, 59);
                            }
                            pdto.FilterList(p => p.TransactionDate <= endDate);
                        }

                        #endregion

                        IList <TransactionHeaderDTO> pdtoList;
                        if (criteria.Page != 0 && criteria.PageSize != 0 && criteria.PaymentListType == -1)
                        {
                            int totalCount2;
                            pdtoList   = pdto.GetPage(criteria.Page, criteria.PageSize, out totalCount2).ToList();
                            totalCount = totalCount2;
                        }
                        else
                        {
                            pdtoList   = pdto.GetList().ToList();
                            totalCount = pdtoList.Count;
                        }


                        piList = piList.Concat(pdtoList).ToList();
                    }
                }
                else
                {
                    piList = Get().Get().ToList();
                }

                #region For Eager Loading Childs

                foreach (var transactionHeaderDto in piList)
                {
                    var transactionLineDtos =
                        (ICollection <TransactionLineDTO>)GetChilds(transactionHeaderDto.Id, false);
                }

                #endregion
            }
            finally
            {
                Dispose(_disposeWhenDone);
            }

            return(piList);
        }
Exemplo n.º 2
0
        public IEnumerable <PaymentDTO> GetAll(SearchCriteria <PaymentDTO> criteria = null)
        {
            IEnumerable <PaymentDTO> piList = new List <PaymentDTO>();

            try
            {
                if (criteria != null && criteria.CurrentUserId != -1)
                {
                    var warehouseList = new WarehouseService(true)
                                        .GetWarehousesPrevilegedToUser(criteria.CurrentUserId).ToList();
                    if (criteria.SelectedWarehouseId != null)
                    {
                        warehouseList = warehouseList.Where(w => w.Id == criteria.SelectedWarehouseId).ToList();
                    }

                    foreach (var warehouse in warehouseList.Where(w => w.Id != -1))
                    {
                        var pdto = Get();

                        foreach (var cri in criteria.FiList)
                        {
                            pdto.FilterList(cri);
                        }

                        #region By Warehouse
                        var warehouse1 = warehouse;
                        pdto.FilterList(p => p.WarehouseId == warehouse1.Id);
                        #endregion

                        #region By Duration

                        if (criteria.BeginingDate != null)
                        {
                            var beginDate = new DateTime(criteria.BeginingDate.Value.Year, criteria.BeginingDate.Value.Month,
                                                         criteria.BeginingDate.Value.Day, 0, 0, 0);
                            pdto.FilterList(p => p.PaymentDate >= beginDate);
                        }

                        if (criteria.EndingDate != null)
                        {
                            var endDate = new DateTime(criteria.EndingDate.Value.Year, criteria.EndingDate.Value.Month,
                                                       criteria.EndingDate.Value.Day, 23, 59, 59);
                            pdto.FilterList(p => p.PaymentDate <= endDate);
                        }

                        #endregion

                        #region By Transaction Type
                        if (criteria.TransactionType != -1)
                        {
                            switch ((TransactionTypes)criteria.TransactionType)
                            {
                            case TransactionTypes.SellStock:
                            {
                                pdto.FilterList(p => p.PaymentType == PaymentTypes.Sale);
                            }
                            break;

                            case TransactionTypes.RecieveStock:
                            {
                                pdto.FilterList(p => p.PaymentType == PaymentTypes.Purchase);
                            }
                            break;
                            }
                        }
                        #endregion



                        #region By Payment Method
                        if (criteria.PaymentMethodType != -1)
                        {
                            switch ((PaymentMethods)criteria.PaymentMethodType)
                            {
                            case PaymentMethods.Cash:
                                pdto.FilterList(p => p.PaymentMethod == PaymentMethods.Cash);
                                break;

                            case PaymentMethods.Credit:
                                pdto.FilterList(p => p.PaymentMethod == PaymentMethods.Credit);
                                break;

                            case PaymentMethods.Check:
                                pdto.FilterList(p => p.PaymentMethod == PaymentMethods.Check);
                                break;
                            }
                        }
                        #endregion

                        #region By Payment Type
                        if (criteria.PaymentType != -1)
                        {
                            switch (criteria.PaymentType)
                            {
                            case 2:
                                pdto.FilterList(p => p.PaymentType == PaymentTypes.CashOut);
                                break;

                            case 5:
                                pdto.FilterList(p => p.PaymentType == PaymentTypes.CashIn);
                                break;
                            }
                        }
                        #endregion

                        piList = piList.Concat(pdto.GetList().ToList());
                    }
                }
                else
                {
                    piList = Get().Get().ToList();
                }
            }
            finally
            {
                Dispose(_disposeWhenDone);
            }

            return(piList);
        }
Exemplo n.º 3
0
        public IEnumerable <TransactionLineDTO> GetAllChilds(SearchCriteria <TransactionLineDTO> criteria,
                                                             out int totalCount)
        {
            totalCount = 0;
            IEnumerable <TransactionLineDTO> piList = new List <TransactionLineDTO>();

            try
            {
                if (criteria != null && criteria.CurrentUserId != -1)
                {
                    var warehouseList = new WarehouseService(true)
                                        .GetWarehousesPrevilegedToUser(criteria.CurrentUserId).ToList();

                    if (criteria.SelectedWarehouseId != null)
                    {
                        warehouseList = warehouseList.Where(w => w.Id == criteria.SelectedWarehouseId).ToList();
                    }

                    foreach (var warehouse in warehouseList.Where(w => w.Id != -1))
                    {
                        var pdto = GetChildsQuery();

                        foreach (var cri in criteria.FiList)
                        {
                            pdto.FilterList(cri);
                        }

                        #region By Warehouse

                        var warehouse1 = warehouse;
                        pdto.FilterList(p => p.Transaction.WarehouseId == warehouse1.Id);

                        #endregion

                        #region By Duration

                        if (criteria.BeginingDate != null)
                        {
                            var beginDate = new DateTime(criteria.BeginingDate.Value.Year,
                                                         criteria.BeginingDate.Value.Month,
                                                         criteria.BeginingDate.Value.Day, 0, 0, 0);
                            pdto.FilterList(p => p.Transaction.TransactionDate >= beginDate);
                        }

                        if (criteria.EndingDate != null)
                        {
                            var endDate = new DateTime(criteria.EndingDate.Value.Year, criteria.EndingDate.Value.Month,
                                                       criteria.EndingDate.Value.Day, 23, 59, 59);
                            pdto.FilterList(p => p.Transaction.TransactionDate <= endDate);
                        }

                        #endregion

                        IList <TransactionLineDTO> pdtoList;
                        if (criteria.Page != 0 && criteria.PageSize != 0)
                        {
                            int totalCount2;
                            pdtoList   = pdto.GetPage(criteria.Page, criteria.PageSize, out totalCount2).ToList();
                            totalCount = totalCount2;
                        }
                        else
                        {
                            pdtoList = pdto.GetList().ToList();
                        }

                        piList = piList.Concat(pdtoList).ToList();
                    }
                }
                else
                {
                    piList = GetChildsQuery().Get().ToList();
                }
            }
            finally
            {
                Dispose(_disposeWhenDone);
            }

            return(piList);
        }