Пример #1
0
        public ActionResult ManageSubscriptions(ManageSubscriptionsVM model)
        {
            if (!ModelState.IsValid)
            {
                model.Sites = SitesManager.GetSites();
                return(View(model));
            }
            int memberId = 0;

            Int32.TryParse(model.MemberId, out memberId);
            int siteId = 0;

            Int32.TryParse(model.SiteId, out siteId);
            int lastFourDigit = -1;

            lastFourDigit = !string.IsNullOrEmpty(model.LastFourDigit) && int.TryParse(model.LastFourDigit, out lastFourDigit) ? int.Parse(model.LastFourDigit) : -1;

            if (memberId != 0 || model.Email != null || model.Phone != null || model.Name != null || (lastFourDigit >= 0 && lastFourDigit <= 9999))
            {
                string lastFourDigitCreditCard = GenerateLastFourDigitCreditCard(lastFourDigit);

                List <CustomerDT> data = CustomersManager.GetCustomers(siteId, memberId, model.Email, model.Phone, model.Name, lastFourDigitCreditCard);
                ViewBag.Data = data;
            }

            model.Sites = SitesManager.GetSites();
            return(View(model));
        }
        public void GetCustomers_NoData()
        {
            repository
            .Setup(a => a.GetCustomers())
            .Returns(new List <Customer>());

            var customersManager = new CustomersManager(repository.Object);

            var result = customersManager.GetCustomers();

            Assert.Empty(result);
        }
        public void GetCustomers_CustomerExist(Int32 customerCount)
        {
            var testData = Builder <Customer> .CreateListOfSize(customerCount).Build();

            repository
            .Setup(a => a.GetCustomers())
            .Returns(testData);

            var customersManager = new CustomersManager(repository.Object);

            var result = customersManager.GetCustomers();

            Assert.Equal(customerCount, result.Count());
        }
 public IEnumerable <ViewCustomer> GetCustomers()
 {
     return(customersManager.GetCustomers());
 }