public async Task <List <CustomerEntity> > GetPageList(CustomerListParam param, Pagination pagination)
        {
            var expression = ListFilter(param);
            var list       = await this.BaseRepository().FindList(expression, pagination);

            return(list.ToList());
        }
        private Expression <Func <CustomerEntity, bool> > ListFilter(CustomerListParam param)
        {
            var expression = LinqExtensions.True <CustomerEntity>();

            if (param != null)
            {
            }
            return(expression);
        }
Exemple #3
0
        public async Task <TData <List <CustomerEntity> > > GetPageList(CustomerListParam param, Pagination pagination)
        {
            TData <List <CustomerEntity> > obj = new TData <List <CustomerEntity> >();

            obj.Data = await customerService.GetPageList(param, pagination);

            obj.Total = pagination.TotalCount;
            obj.Tag   = 1;
            return(obj);
        }
Exemple #4
0
        public async Task <TData <List <CustomerEntity> > > GetList(CustomerListParam param)
        {
            TData <List <CustomerEntity> > obj = new TData <List <CustomerEntity> >();

            obj.Data = await customerService.GetList(param);

            obj.Total = obj.Data.Count;
            obj.Tag   = 1;
            return(obj);
        }
 public IActionResult GetCustomerListByFilter(CustomerListParam input)
 {
     try
     {
         var res = _repository.Customer.GetCustomerListByFilter(input);
         _logger.LogData(MethodBase.GetCurrentMethod(), res, null, input);
         return(Ok(res));
     }
     catch (Exception e)
     {
         _logger.LogError(e, MethodBase.GetCurrentMethod(), input);
         return(BadRequest(""));
     }
 }
Exemple #6
0
        public List <CustomerLIstByFilterDto> GetCustomerListByFilter(CustomerListParam input)
        {
            var list = RepositoryContext.Customer.Select(c => c.Id);

            if (input.CatProductID.HasValue)
            {
                var list1 = RepositoryContext.CustomerOrderProduct
                            .Where(c => (c.Product.CatProductId == input.CatProductID || !input.CatProductID.HasValue) &&
                                   c.DaDate == null & c.Ddate == null)
                            .Select(c => c.CustomerOrder.CustomerId.Value);
                list = list.Intersect(list1);
            }

            if (input.HaveCard.HasValue)
            {
                var list1 = RepositoryContext.CustomerOrderProduct
                            .Where(c => (c.Product.CatProduct.Rkey == 1 || !input.HaveCard.HasValue) &&
                                   c.DaDate == null & c.Ddate == null)
                            .Select(c => c.CustomerOrder.CustomerId.Value);
                list = list.Intersect(list1);
            }

            if (input.CityID.HasValue)
            {
                var list1 = RepositoryContext.CustomerAddress
                            .Where(c => (c.CityId == input.CityID || !input.CityID.HasValue) && c.DaDate == null & c.Ddate == null).Select(c => c.CustomerId.Value).ToList();
                list = list.Intersect(list1);
            }


            if (input.ToPrice.HasValue || input.FromPrice.HasValue || input.BuyDateFrom.HasValue ||
                input.BuyDateTo.HasValue)
            {
                var list1 = RepositoryContext.CustomerOrder
                            .Where(c => (c.FinalPrice <= input.ToPrice || !input.ToPrice.HasValue) &&
                                   (c.FinalPrice >= input.FromPrice || !input.FromPrice.HasValue) &&
                                   (!input.BuyDateFrom.HasValue || c.OrderDate >= input.BuyDateFrom.Value.Ticks) &&
                                   (!input.BuyDateTo.HasValue || c.OrderDate >= input.BuyDateTo.Value.Ticks) && c.DaDate == null & c.Ddate == null)
                            .Select(c => c.CustomerId.Value).ToList();
                list = list.Intersect(list1);
            }



            var  currentYear = new System.Globalization.PersianCalendar().GetYear(DateTime.Now);
            long?minYear     = null;
            long?maxYear     = null;

            if (input.FromBirth.HasValue)
            {
                minYear = ((new PersianCalendar().ToDateTime(currentYear, 1, 1, 0, 0, 0, 0)).AddYears(input.FromBirth.Value)).Ticks;
            }

            if (input.ToBirth.HasValue)
            {
                maxYear = (new PersianCalendar().ToDateTime(currentYear, 12, 29, 0, 0, 0, 0).AddYears(input.ToBirth.Value)).Ticks;
            }



            var res = RepositoryContext.Customer
                      .Where(c =>
                             (list.Contains(c.Id)) &&
                             (!input.HaveWallet.HasValue || input.HaveWallet == c.HaveWallet) &&
                             (minYear <= c.Bdate || minYear == null) &&
                             (maxYear >= c.Bdate || maxYear == null) &&
                             c.Ddate == null)
                      .Select(c => new CustomerLIstByFilterDto
            {
                CustomerId       = c.Id,
                Name             = c.Name,
                Fname            = c.Fname,
                WalletFinalPrice = c.WalletFinalPrice,
                OrderCount       = c.CustomerOrder.SelectMany(xc => xc.CustomerOrderPayment.Where(v => v.FinalStatusId == 25)).ToList().Count,
                CatProduct       = c.CustomerOrder.SelectMany(x => x.CustomerOrderProduct.Select(v => v.Product.CatProduct.Name)).ToList()
            }).ToList();

            var a = new List <CustomerLIstByFilterDto>();

            foreach (var item in res)
            {
                var ss = new CustomerLIstByFilterDto
                {
                    CatProduct       = item.CatProduct.Distinct().ToList(),
                    Name             = item.Name,
                    Fname            = item.Fname,
                    CustomerId       = item.CustomerId,
                    WalletFinalPrice = item.WalletFinalPrice,
                    OrderCount       = item.OrderCount
                };
                a.Add(ss);
            }
            return(a);
        }
Exemple #7
0
        public async Task <ActionResult> GetPageListJson(CustomerListParam param, Pagination pagination)
        {
            TData <List <CustomerEntity> > obj = await customerBLL.GetPageList(param, pagination);

            return(Json(obj));
        }