public List <BDCustomerAccount> GetCustomerAccounts(int id)
        {
            List <BDCustomerAccount> customerAccountCollection = new List <BDCustomerAccount>();

            BDCustomerPrimaryKey pk = new BDCustomerPrimaryKey();

            pk.CustomerID = id;
            var query = SelectAllByForeignKeyCustomerID(pk);

            if (query.Count == 0)
            {
                return(customerAccountCollection);
            }

            customerAccountCollection = (from item in query
                                         join customer in _customerService.SelectAll() on item.CustomerID equals customer.CustomerID
                                         join _user in _userService.SelectAll() on item.CreatedBy equals _user.UserID
                                         select new BDCustomerAccount()
            {
                CustomerAccountNumber = item.CustomerAccountNumber,
                CustomerID = item.CustomerID,
                CustomerName = customer.CustomerName,
                InvoiceNumber = item.InvoiceNumber,
                IsVoid = item.IsVoid,
                PaidAmount = item.PaidAmount,
                RemainingAmount = item.RemainingAmount,
                SalesDate = item.SalesDate,
                SalesInvoiceId = item.SalesInvoiceId,
                TotalPrice = item.TotalPrice,
                CreateDate = item.CreateDate,
                CreatedByName = _user.UserFullName
            }
                                         ).ToList();
            return(customerAccountCollection);
        }
Esempio n. 2
0
        public List <BDCustomerAccount> GetCustomerAccounts(int?id, DateTime?dateFrom = null, DateTime?toFrom = null)
        {
            List <BDCustomerAccount> customerAccountCollection = new List <BDCustomerAccount>();
            var query = SelectAll().ToList();


            DateTime?fromCreationDate = dateFrom != null ? dateFrom : null;
            DateTime?toCreationDate   = toFrom != null ? toFrom : null;

            if (fromCreationDate != null && toCreationDate != null)
            {
                query = (from item in query
                         where (item.CreateDate.Value.Date >= dateFrom.Value.Date
                                &&
                                item.CreateDate.Value.Date <= toFrom.Value.Date)
                         select item).ToList();
            }


            if (id != null)
            {
                BDCustomerPrimaryKey pk = new BDCustomerPrimaryKey();
                pk.CustomerID = id;
                query         = SelectAllByForeignKeyCustomerID(pk).ToList();
            }

            if (query.Count == 0)
            {
                return(customerAccountCollection);
            }

            customerAccountCollection = (from item in query
                                         join customer in _customerService.SelectAll() on item.CustomerID equals customer.CustomerID
                                         join _user in _userService.SelectAll() on item.CreatedBy equals _user.UserID
                                         select new BDCustomerAccount()
            {
                CustomerAccountNumber = item.CustomerAccountNumber,
                CustomerID = item.CustomerID,
                CustomerName = customer.CustomerName,
                InvoiceNumber = item.InvoiceNumber,
                IsVoid = item.IsVoid,
                PaidAmount = item.PaidAmount,
                RemainingAmount = item.RemainingAmount,
                SalesDate = item.SalesDate,
                SalesInvoiceId = item.SalesInvoiceId,
                TotalPrice = item.TotalPrice,
                CreateDate = item.CreateDate,
                CreatedByName = _user.UserFullName,
                ChequeNumber = item.ChequeNumber,
                Credit = item.Credit,
                Depit = item.Depit,
                InvoiceType = item.InvoiceType,
                LstDayToPay = item.LstDayToPay
            }
                                         ).ToList();
            return(customerAccountCollection);
        }