Exemplo n.º 1
0
            public async Task Index_ReturnsViewModel(
                [Frozen] Mock <ICustomerService> customerService,
                CustomersIndexViewModel viewModel,
                [Greedy] CustomerController sut
                )
            {
                //Arrange
                customerService.Setup(x => x.GetCustomers(
                                          It.IsAny <int>(),
                                          It.IsAny <int>(),
                                          It.IsAny <string>(),
                                          It.IsAny <CustomerType?>(),
                                          It.IsAny <string>()
                                          ))
                .ReturnsAsync(viewModel);

                //Act
                var actionResult = await sut.Index(
                    0, null, null, null
                    );

                //Assert
                var viewResult = actionResult.Should().BeAssignableTo <ViewResult>().Subject;

                viewResult.Model.Should().Be(viewModel);
            }
Exemplo n.º 2
0
        public ActionResult Index()
        {
            var model = new CustomersIndexViewModel
                        {
                            Customers = _session.Query<Customer>().ToList()
                        };

            return View(model);
        }
Exemplo n.º 3
0
        public ActionResult Index()
        {
            var model = new CustomersIndexViewModel
            {
                Customers = _session.Query <Customer>().ToList()
            };

            return(View(model));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Index()
        {
            CustomersIndexViewModel IndexViewModel = new CustomersIndexViewModel()
            {
                MenuItems  = await _db.MenuItem.Include(m => m.Category).Include(m => m.SubCategory).ToListAsync(),
                Categories = await _db.Category.ToListAsync(),
                Coupons    = await _db.Coupon.Where(m => m.IsActive == true).ToListAsync()
            };

            return(View(IndexViewModel));
        }
Exemplo n.º 5
0
        // GET: Vendors/Customers
        public ActionResult Index()
        {
            var vndrId = User.Identity.GetUserId();

            var vendor = db.EcomUsers
                         .FirstOrDefault(m => m.ApplicationUserId == vndrId);
            var customers = db.Refferals
                            .Where(m => m.VendorId == vendor.Id)
                            .Select(m => m.CustomerId)
                            .ToList();

            var model = new CustomersIndexViewModel
            {
                Customers = db.EcomUsers
                            .Include(m => m.User)
                            .Where(m => customers.Contains(m.Id))
                            .OrderBy(m => m.User.FirstName + " " + m.User.LastName)
                            .ToList(),
                Buyers        = new Dictionary <string, bool>(),
                Registrations = new Dictionary <string, bool>()
            };

            foreach (var customer in model.Customers)
            {
                var rel = db.Refferals
                          .FirstOrDefault(m => m.CustomerId == customer.Id &&
                                          m.VendorId == vendor.Id);

                if (rel.IsBuyer == true)
                {
                    model.Buyers.Add(customer.ApplicationUserId, true);
                }
                else
                {
                    model.Buyers.Add(customer.ApplicationUserId, false);
                }

                if (rel.IsRegisteredUser == true)
                {
                    model.Registrations.Add(customer.ApplicationUserId, true);
                }
                else
                {
                    model.Registrations.Add(customer.ApplicationUserId, false);
                }
            }

            return(View(model));
        }
Exemplo n.º 6
0
        public ActionResult Index(String name)
        {
            var movie = new Movie
            {
                Name = "s"
            };


            var viewModel = new CustomersIndexViewModel
            {
                Customers = customers
            };

            return(View(viewModel));
        }
Exemplo n.º 7
0
        public CustomersIndex()
        {
            this.InitializeComponent();

            customersIndexViewModel = new CustomersIndexViewModel();

            PageHelper.DoAsync(overlay, Dispatcher, () =>
            {
                customersIndexViewModel.LoadAllCustomers();

                PageHelper.MainUI(Dispatcher, () =>
                {
                    this.DataGrid.DataContext = this.customersIndexViewModel.customers;
                });
            });
        }
Exemplo n.º 8
0
        public ActionResult Index(PagerParameters pagerParameters, CustomersSearchViewModel search)
        {
            // Create a basic query that selects all customer content items, joined with the UserPartRecord table
            var customerQuery = _customerService.GetCustomers().Join <UserPartRecord>().List();

            // If the user specified a search expression, update the query with a filter
            if (!string.IsNullOrWhiteSpace(search.Expression))
            {
                var expression = search.Expression.Trim();

                customerQuery = from customer in customerQuery
                                where
                                customer.FirstName.Contains(expression, StringComparison.InvariantCultureIgnoreCase) ||
                                customer.LastName.Contains(expression, StringComparison.InvariantCultureIgnoreCase) ||
                                customer.As <UserPart>().Email.Contains(expression)
                                select customer;
            }

            // Project the query into a list of customer shapes
            var customersProjection = from customer in customerQuery
                                      select Shape.Customer
                                      (
                Id : customer.Id,
                FirstName : customer.FirstName,
                LastName : customer.LastName,
                Email : customer.As <UserPart>().Email,
                CreatedUtc : customer.CreatedUtc
                                      );

            // The pager is used to apply paging on the query and to create a PagerShape
            var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters.Page, pagerParameters.PageSize);

            // Apply paging
            var customers = customersProjection.Skip(pager.GetStartIndex()).Take(pager.PageSize);

            // Construct a Pager shape
            var pagerShape = Shape.Pager(pager).TotalItemCount(customerQuery.Count());

            // Create the viewmodel
            var model = new CustomersIndexViewModel(customers, search, pagerShape);



            return(View(model));
        }
        public async Task <CustomersIndexViewModel> GetCustomers(int pageIndex, int pageSize, string territory, CustomerType?customerType)
        {
            logger.LogInformation("GetCustomers called");
            var response = await customerApiClient.GetCustomersAsync(pageIndex, pageSize, territory, customerType);

            var vm = new CustomersIndexViewModel
            {
                Customers      = mapper.Map <List <CustomerViewModel> >(response.Customers),
                Territories    = await GetTerritories(false),
                CustomerTypes  = GetCustomerTypes(),
                PaginationInfo = new PaginationInfoViewModel()
                {
                    ActualPage   = pageIndex,
                    ItemsPerPage = response.Customers.Count,
                    TotalItems   = response.TotalCustomers,
                    TotalPages   = int.Parse(Math.Ceiling(((decimal)response.TotalCustomers / pageSize)).ToString())
                }
            };

            vm.PaginationInfo.Next     = (vm.PaginationInfo.ActualPage == vm.PaginationInfo.TotalPages - 1) ? "disabled" : "";
            vm.PaginationInfo.Previous = (vm.PaginationInfo.ActualPage == 0) ? "disabled" : "";

            return(vm);
        }