public void CustomerCreationWithCustomerParams()
        {
            CustomerParams input = JsonConvert.DeserializeObject<CustomerParams>(CustomerInput);
            CustomerResponse actualResponse = customer.Create(input);

            CustomerCreationSuccessCheck(actualResponse.JsonResponse());
        }
        private string CreateUrl(PagedType pagedType, CustomerParams customerParams)
        {
            string url = string.Empty;

            switch (pagedType)
            {
            case PagedType.Previous:
                url = Url.Link(nameof(GetCustomer), new
                {
                    PageSize     = customerParams.PageSize,
                    CustomerName = customerParams.CustomerName,
                    PageNum      = customerParams.PageNum - 1
                });
                break;

            case PagedType.Next:
                url = Url.Link(nameof(GetCustomer), new
                {
                    PageSize     = customerParams.PageSize,
                    CustomerName = customerParams.CustomerName,
                    PageNum      = customerParams.PageNum + 1
                });
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(pagedType), pagedType, null);
            }
            return(url);
        }
        public void CustomerUpdateWithCustomerParams()
        {
            CustomerParams input = JsonConvert.DeserializeObject<CustomerParams>(CustomerInput);
            CustomerResponse actualResponse = customer.Update("TN344YY67HH09KK", input);

            CustomerCreationSuccessCheck(actualResponse.JsonResponse());
        }
Beispiel #4
0
 public static async Task <object> GetCustomers(CustomerParams param)
 {
     using (T_Customer_Entities entity = new T_Customer_Entities())
     {
         return(await entity.List(param));
     }
 }
 public void Setup()
 {
     customer    = new Customer();
     restClient  = new Mock <IRequestExecute>();
     param       = new Hashtable();
     paramValues = new CustomerParams();
 }
        public async Task <PagedList <SlCustomer> > GetCustomerPaged(CustomerParams customerParams)
        {
            var items = _slcustomerrepository.GetEntitys();

            if (!string.IsNullOrWhiteSpace(customerParams.CustomerName))
            {
                items = items.Where(a => a.Name.Contains(customerParams.CustomerName));
            }
            return(await PagedList <SlCustomer> .CreatePagedList(items, customerParams.PageSize, customerParams.PageNum));
        }
Beispiel #7
0
        public async Task <IActionResult> GetCustomers([FromQuery] CustomerParams customerParams)
        {
            var customers = await _customerRepo.GetCustomers(customerParams);

            var customersInPage = _mapper.Map <ICollection <CustomerListDto> >(customers);

            Response.AddPagination(customers.CurrentPage, customers.PageSize, customers.TotalCount, customers.TotalPages);

            return(Ok(customersInPage));
        }
        public async Task <IActionResult> GetCustomerList([FromQuery] CustomerParams cond)
        {
            var customers = await _customerRepo.GetCustomers(cond);

            var customerList = _mapper.Map <List <CustomerResource> >(customers);

            Response.AddPagination(
                customers.CurrentPage, customers.PageSize, customers.TotalCount, customers.TotalPages);

            return(Ok(customerList));
        }
Beispiel #9
0
        public async Task <object> GetCustomers(CustomerParams param)
        {
            string[] str = new string[] { };

            var data = await T_Customer_BLL.GetCustomers(param);

            return(Ok(new
            {
                statusCode = 200,
                result = data
            }));
        }
Beispiel #10
0
        public async Task <object> GetRoles(CustomerParams param)
        {
            param.CategoryId = "0";
            param.Cids       = new string[] { };
            var data = await T_Customer_BLL.GetCustomers(param);

            return(Ok(new
            {
                statusCode = 200,
                result = data
            }));
        }
Beispiel #11
0
        private CustomerParams BuildCustomerParams(string companyName, string siteName, RequestOptions options)
        {
            CustomerParams custParams = new CustomerParams();

            options             = SetRequestOptionsObject(options);
            custParams.Customer = new CustomerTag()
            {
                Name     = companyName,
                SiteName = siteName
            };
            return(custParams);
        }
        public async Task <Pagination <Customer> > FindCustomersAsync(CustomerParams customerParams)
        {
            var specification = new CustomerSpecification(customerParams);

            var countSpecification = new CustomerFilterForCountSpecification(customerParams);

            int totalItems = await _customerRepository.CountAsync(countSpecification);

            var data = await _customerRepository.FindListAsync(specification);


            return(new Pagination <Customer>(customerParams.PageIndex, customerParams.PageSize, totalItems, data));
        }
Beispiel #13
0
        public async Task <PagedList <Customer> > GetCustomers(CustomerParams cus)
        {
            var customers = _context.Customers.Include(cg => cg.CustomerGroup).Where(c =>
                                                                                     (cus.SearchString != null &&
                                                                                      (
                                                                                          c.CompanyName.Contains(cus.SearchString) ||
                                                                                          c.ContactName.Contains(cus.SearchString) ||
                                                                                          cus.SearchString == string.Empty
                                                                                      )) || cus.SearchString == null
                                                                                     );

            return(await PagedList <Customer> .CreateListAsync(customers, cus.PageNumber, cus.PageSize));
        }
        public async Task <IActionResult> GetCustomers([FromQuery] CustomerParams customerParams)
        {
            var customers = _context.Customers
                            .Where(x =>
                                   (
                                       (x.Name.Contains(customerParams.SearchText)) ||
                                       (x.Note.Contains(customerParams.SearchText)) ||
                                       (x.PhoneNumber.Contains(customerParams.SearchText))
                                   ) &&
                                   (x.IsActive == true));

            var result = await PagedList <Customer> .CreateAsync(customers, customerParams.PageNumber, customerParams.PageSize);

            Response.AddPagination(result.CurrentPage, result.PageSize, result.TotalCount, result.TotalPages);

            return(Ok(result));
        }
        public async Task <ActionResult <IEnumerable <SlCustomerDto> > > GetCustomer([FromQuery] CustomerParams customerParams)
        {
            MessageModel <IEnumerable <SlCustomerDto> > res = new MessageModel <IEnumerable <SlCustomerDto> >();
            PagedList <SlCustomer> customerPaged            = await _slCustomerServices.GetCustomerPaged(customerParams);

            string previousLink = customerPaged.HasPrevious ? CreateUrl(PagedType.Previous, customerParams) : null;
            string nextLink     = customerPaged.HasNext ? CreateUrl(PagedType.Next, customerParams) : null;
            var    pagination   = new
            {
                currentPage = customerPaged.PageNum,
                totalPage   = customerPaged.TotalPage,
                totalCount  = customerPaged.TotalCount,
                previousLink,
                nextLink
            };

            HttpContext.Response.Headers.Add("X-Pagination", JsonConvert.SerializeObject(pagination));
            res.Data = _mapper.Map <IEnumerable <SlCustomerDto> >(customerPaged);
            return(Ok(res));
        }
Beispiel #16
0
        public async Task <object> List(CustomerParams param)
        {
            using (db = new KBLDataContext())
            {
                var entities = from c in db.Customers
                               join t in db.CustomerTasks on c.Cid equals t.CId into ct
                               from lct in ct.DefaultIfEmpty()
                               where (c.CategoryID == param.CategoryId && !string.IsNullOrEmpty(param.CategoryId) || string.IsNullOrEmpty(param.CategoryId))
                               group lct by c into gct
                               select gct;
                var data = await entities.ToListAsync();

                var json = from gct in data
                           orderby gct.Key.Cid descending
                           select new
                {
                    c = gct.Key,
                    t = new
                    {
                        Unfinished = gct.Any(a => a != null) ? gct.Where(w => w.StartDate.Value.Date < DateTime.Now.Date && w.ReviewStatus == false).Select(s => new {
                            s.StartDate,
                            s.ReviewStatus
                        }) : new object { },
                        //Prev = gct!=null ? gct.Any(a=>a !=null)? gct.Where(w => w.StartDate.Value.Date < DateTime.Now.Date).OrderBy(o => o.StartDate).Take(1):null : null,
                        Prev = gct.Any(a => a != null) ? gct.Where(w => w.StartDate.Value.Date < DateTime.Now.Date).OrderBy(o => o.StartDate).LastOrDefault() : null,
                        //Next = gct != null ? gct.Any(a => a != null) ? gct.Where(w => w.StartDate.Value.Date > DateTime.Now.Date).OrderByDescending(o => o.StartDate).Take(1) : null : null,
                        Next = gct.Any(a => a != null) ? gct.Where(w => w.StartDate.Value.Date > DateTime.Now.Date).OrderBy(o => o.StartDate).FirstOrDefault() : null,
                        //Today = gct != null ? gct.Any(a => a != null) ? gct.Where(w => w.StartDate.Value.Date == DateTime.Now.Date).OrderByDescending(o => o.StartDate).Take(1) : null : null
                        Today = gct.Any(a => a != null) ? gct.Where(w => w.StartDate.Value.Date == DateTime.Now.Date).OrderByDescending(o => o.StartDate).LastOrDefault() : null,

                        Finishing = gct.Any(a => a != null) ? gct.Where(w => w.StartDate.Value.Date > DateTime.Now.Date && w.ReviewStatus == false).Select(s => new {
                            s.StartDate,
                            s.ReviewStatus
                        }) : new object { },
                    }
                };

                return(json);
            }
        }
Beispiel #17
0
        public async Task <PagedList <CustomerDto> > GetPaginationCustomersAsyc(CustomerParams customerParams)
        {
            var query = _context.Customers.AsQueryable();

            query = query.Where(c => c.AppUserId == customerParams.userId);

            if (customerParams.Search != null)
            {
                query = query.Where(
                    c => c.CompanyName.ToLower().Contains(customerParams.Search.ToLower()) ||
                    c.CustomerName.ToLower().Contains(customerParams.Search.ToLower()));
            }

            query = customerParams.OrderBy switch
            {
                "companyName" => query.OrderByDescending(u => u.Id),
                _ => query.OrderBy(u => u.CustomerName)
            };

            return(await PagedList <CustomerDto> .CreateAsync(query.ProjectTo <CustomerDto>(_mapper
                                                                                            .ConfigurationProvider).AsNoTracking(),
                                                              customerParams.PageNumber, customerParams.PageSize));
        }
 public CustomerFilterForCountSpecification(CustomerParams customerParams) : base(c =>
                                                                                  (string.IsNullOrEmpty(customerParams.Search) || c.Firstname.ToLower().Contains(customerParams.Search))
                                                                                  )
 {
 }
Beispiel #19
0
 /// <summary>
 /// It's a POST request to create Customer
 /// https://gds.eligibleapi.com/rest#create_customers
 /// </summary>
 /// <param name="CustomerParams">Required parameters in the form of CustomerParams object</param>
 /// <returns></returns>
 public CustomerResponse Create(CustomerParams customerParams, RequestOptions options = null)
 {
     return(this.Create(JsonSerialize(customerParams), options));
 }
Beispiel #20
0
        public async Task <ActionResult <IReadOnlyList <CustomerDto> > > GetCustomerWithPagination([FromQuery] CustomerParams customerParams)
        {
            var user = await _userManager.FindByEmailFromClaimsPrinciple(HttpContext.User);

            var results = await _unitOfWork.CustomerService.GetPaginationCustomersAsyc(customerParams);

            Response.AddPaginationHeader(results.CurrentPage, results.PageSize, results.TotalCount, results.TotalPages);
            return(Ok(results));
        }
Beispiel #21
0
        public async Task <PageList <Customer> > GetCustomers(CustomerParams customerParams)
        {
            var customers = _dbContext.Customers.AsQueryable();

            return(await PageList <Customer> .CreateAsync(customers, customerParams.PageNumber, customerParams.PageSize));
        }
Beispiel #22
0
        /// <summary>
        /// It's a PUT request to Update Customer
        /// https://gds.eligibleapi.com/rest#update_customers
        /// </summary>
        /// <param name="customerId"></param>
        /// <param name="companyName"></param>
        /// <param name="siteName"></param>
        /// <returns></returns>
        public CustomerResponse Update(string customerId, string companyName, string siteName, RequestOptions options = null)
        {
            CustomerParams custParams = this.BuildCustomerParams(companyName, siteName, options);

            return(this.Update(customerId, JsonSerialize(custParams)));
        }
Beispiel #23
0
 public async Task <IActionResult> GetCustomers([FromQuery] CustomerParams customerParams)
 {
     return(Ok(await _customerService.FindCustomersAsync(customerParams)));
 }
 public CustomerSpecification(CustomerParams customerParams) : base(c =>
                                                                    (string.IsNullOrEmpty(customerParams.Search) || c.Firstname.ToLower().Contains(customerParams.Search))
                                                                    )
 {
     ApplyPaging(customerParams.PageSize * (customerParams.PageIndex - 1), customerParams.PageSize);
 }
Beispiel #25
0
 /// <summary>
 /// It's a PUT request to Update Customer
 /// https://gds.eligibleapi.com/rest#update_customers
 /// </summary>
 /// <param name="customerID"></param>
 /// <param name="jsonParams">Required params in the form of CustomerParams object</param>
 /// <returns></returns>
 public CustomerResponse Update(string customerId, CustomerParams customerParams, RequestOptions options = null)
 {
     return(this.Update(customerId, JsonSerialize(customerParams), options));
 }