public async void Initialize_Customer_Does_Exist()
        {
            IUserService userService = TestUtilities.GetUserService();
            IMapper      mapper      = TestUtilities.GetMapper(new CustomerProfile());

            var mock = new Mock <ICustomerService>();

            mock.Setup(x => x.GetCurrentCustomer <CustomerItemModel>())
            .Returns(Task.FromResult <CustomerItemModel?>(new CustomerItemModel()
            {
                Contact =
                {
                    Email     = userService.User.Email,
                    FirstName = userService.User.FirstName,
                    LastName  = userService.User.LastName,
                }
            }));

            CustomerManager manager = new CustomerManager(_logger, mapper, mock.Object, userService, Mock.Of <IIsotopeOrderingAuthorizationService>(), _eventService, Mock.Of <INotificationService>());

            CustomerItemModel customer = await manager.InitializeCustomerForCurrentUser();

            Assert.Equal(customer.Contact.Email, userService.User.Email);
            Assert.Equal(customer.Contact.FirstName, userService.User.FirstName);
            Assert.Equal(customer.Contact.LastName, userService.User.LastName);
            Assert.Equal(CustomerStatus.New, customer.Status);
        }
        public async void Initialize_Customer_Does_Not_Exist()
        {
            IUserService userService = TestUtilities.GetUserService();
            IMapper      mapper      = TestUtilities.GetMapper(new CustomerProfile());

            var mock = new Mock <ICustomerService>();

            mock.Setup(x => x.Get <CustomerItemModel>(It.IsAny <string>()))
            .Returns(Task.FromResult <CustomerItemModel?>(null));
            mock.Setup(x => x.Create(It.IsAny <Customer>()))
            .Returns(Task.FromResult(1));
            mock.Setup(x => x.Get <CustomerItemModel>(It.Is <int>(x => x == 1)))
            .Returns(Task.FromResult(new CustomerItemModel()
            {
                Contact =
                {
                    Email     = userService.User.Email,
                    FirstName = userService.User.FirstName,
                    LastName  = userService.User.LastName,
                }
            }));


            Mock <INotificationService> mockNotificationService = new Mock <INotificationService>();

            mockNotificationService.Setup(x => x.GetConfigurationList <NotificationConfigurationItemModel>(It.IsAny <NotificationTarget>())).ReturnsAsync(new List <NotificationConfigurationItemModel>());
            CustomerManager manager = new CustomerManager(_logger, mapper, mock.Object, userService, Mock.Of <IIsotopeOrderingAuthorizationService>(), _eventService, mockNotificationService.Object);

            CustomerItemModel customer = await manager.InitializeCustomerForCurrentUser();

            Assert.Equal(customer.Contact.Email, userService.User.Email);
            Assert.Equal(customer.Contact.FirstName, userService.User.FirstName);
            Assert.Equal(customer.Contact.LastName, userService.User.LastName);
            Assert.Equal(CustomerStatus.New, customer.Status);
        }
예제 #3
0
        public async Task <OrderDetailModel> GetOrderForm(CustomerItemModel customer)
        {
            OrderDetailModel model = new OrderDetailModel();

            model.Customer = customer;
            return(await GetOrderForm(model));
        }
        public async void Get_Customer_Mapping_Correct(Customer customer, NotificationConfiguration configuration)
        {
            string instanceName = Guid.NewGuid().ToString();

            using (var context = TestUtilities.GetDbContext(instanceName)) {
                customer.Subscriptions.Add(new NotificationSubscription()
                {
                    NotificationConfiguration = configuration,
                    IsDeleted = false
                });
                context.Customers.Add(customer);
                await context.SaveChangesAsync();
            }
            using (var context = TestUtilities.GetDbContext(instanceName)) {
                CustomerService service = new CustomerService(context, TestUtilities.GetMapper());

                CustomerItemModel item = await service.Get <CustomerItemModel>(customer.Id);

                Assert.Equal(customer.Contact.FirstName, item.Contact.FirstName);

                CustomerDetailModel model = await service.Get <CustomerDetailModel>(customer.Id);

                Assert.NotEmpty(model.SubscriptionConfiguration.Subscriptions);
            }
        }
예제 #5
0
        public async Task <FormDetailModel> GetInitiationForm(CustomerItemModel customer)
        {
            FormDetailModel formDetailModel = await _service.Get <FormDetailModel>(FormType.Initiation);

            formDetailModel.InitiationModel       = new FormInitiationDetailModel();
            formDetailModel.InitiationModel.Items = await _itemService.GetList <FormInitiationItemModel>();

            formDetailModel.Customer = customer;
            return(formDetailModel);
        }
예제 #6
0
        public async Task <OrderDetailModel> GetOrderForm(OrderDetailModel order)
        {
            CustomerItemModel customer = order.Customer;

            order.Items = await _itemService.GetListForOrder <OrderItemDetailModel>(customer.Id, customer.ParentCustomerId);

            List <OrderAddressDetailModel> addresses = await _customerService.GetAddressListForOrder <OrderAddressDetailModel>(customer.Id, customer.ParentCustomerId);

            order.BillingAddresses  = addresses.Where(x => x.Type == AddressType.Billing || x.Type == AddressType.Default).ToList();
            order.ShippingAddresses = addresses.Where(x => x.Type == AddressType.Shipping || x.Type == AddressType.Default).ToList();
            return(order);
        }
예제 #7
0
        void AddItemToGrid(Backend.Objects.Customer customer)
        {
            //Fill Grid [ ItemsGrid ] With Rows
            CustomerItemModel customerItemModel = new CustomerItemModel
            {
                OnAdd    = OnAddItem,
                Customer = customer,
                User     = User,
                Store    = Store,
            };

            //Add To Grid
            ItemsGrid.Controls.Add(customerItemModel);
        }
        public async void Get_InitiationForm_For_Customer(CustomerItemModel customer)
        {
            var mockFormService = new Mock <IFormService>();

            mockFormService.Setup(x => x.Get <FormDetailModel>(It.Is <FormType>(x => x == FormType.Initiation))).ReturnsAsync(new FormDetailModel());

            var mockItemService = new Mock <IItemService>();

            mockItemService.Setup(x => x.GetList <FormInitiationItemModel>()).ReturnsAsync(new List <FormInitiationItemModel>());

            IMapper     mapper  = TestUtilities.GetMapper(new CustomerProfile(), new FormProfile(), new InstitutionProfile());
            FormManager manager = new FormManager(_logger, mapper, mockFormService.Object, mockItemService.Object, Mock.Of <IIsotopeOrderingAuthorizationService>(), Mock.Of <ICustomerService>(), _eventService, Mock.Of <INotificationManager>());

            FormDetailModel?model = await manager.GetInitiationForm(customer);

            Assert.Equal(model?.Customer, customer);
        }
        public async void Get_Order_Form_As_Parent(CustomerItemModel model)
        {
            model.ParentCustomerId = null;
            var mockItemService = new Mock <IItemService>();

            mockItemService.Setup(x => x.Create(It.IsAny <Item>())).ReturnsAsync(1);

            var mockOrderService = new Mock <IOrderService>();

            var mockCustomerService = new Mock <ICustomerService>();

            mockCustomerService.Setup(x => x.GetAddressListForOrder <OrderAddressDetailModel>(It.IsAny <int>(), It.IsAny <int?>())).ReturnsAsync(new List <OrderAddressDetailModel>());

            var mockInstitutionService = new Mock <IInstitutionService>();

            IMapper      mapper  = TestUtilities.GetMapper(new ItemProfile());
            OrderManager manager = new OrderManager(_logger, mapper, mockOrderService.Object, mockItemService.Object, mockCustomerService.Object, Mock.Of <IShipmentService>(), _eventService, Mock.Of <IIsotopeOrderingAuthorizationService>());

            OrderDetailModel result = await manager.GetOrderForm(model);
        }
예제 #10
0
        public async void Get_CompletedInitiationForm_ReturnsForm(CustomerItemModel customer)
        {
            var mockFormService = new Mock <IFormService>();

            mockFormService.Setup(x => x.GetCustomerForm <FormDetailModel>(customer.Id, It.IsAny <int>())).ReturnsAsync(new FormDetailModel()
            {
                Customer = customer
            });

            var mockItemService = new Mock <IItemService>();

            mockItemService.Setup(x => x.GetList <FormInitiationItemModel>()).ReturnsAsync(new List <FormInitiationItemModel>());

            var mockCustomerService = new Mock <ICustomerService>();

            mockCustomerService.Setup(x => x.GetCurrentCustomer <CustomerItemModel>()).ReturnsAsync(customer);

            IMapper     mapper  = TestUtilities.GetMapper(new CustomerProfile(), new FormProfile(), new InstitutionProfile());
            FormManager manager = new FormManager(_logger, mapper, mockFormService.Object, mockItemService.Object, Mock.Of <IIsotopeOrderingAuthorizationService>(), mockCustomerService.Object, _eventService, Mock.Of <INotificationManager>());

            FormDetailModel?model = await manager.GetInitiationForm(1);

            Assert.NotNull(model);
        }
예제 #11
0
        public List <CustomerItemModel> GetCustomerList()
        {
            using (var db = new EntityContext())
            {
                var customers = customerUtility.GetAllCustomer(db);

                List <CustomerItemModel> model = new List <CustomerItemModel>();
                foreach (var customer in customers)
                {
                    CustomerItemModel ci = new CustomerItemModel();
                    ci.CustomerId              = customer.Id;
                    ci.CustomerName            = customer.Name;
                    ci.CountItems              = itemsUtility.GetAllItem(db).Count(i => i.Customer.Id == customer.Id);
                    ci.CountItemsToPickup      = itemsUtility.GetAllItem(db).Count(i => i.Customer.Id == customer.Id && i.Status.Id == 2);
                    ci.CountItemsPickedUp      = itemsUtility.GetAllItem(db).Count(i => i.Customer.Id == customer.Id && i.Status.Id == 3);
                    ci.CountItemsInProcess     = itemsUtility.GetAllItem(db).Count(i => i.Customer.Id == customer.Id && i.Status.Id == 4);
                    ci.CountItemsToSend        = itemsUtility.GetAllItem(db).Count(i => i.Customer.Id == customer.Id && i.Status.Id == 5);
                    ci.CountItemsAlreadySend   = itemsUtility.GetAllItem(db).Count(i => i.Customer.Id == customer.Id && i.Status.Id == 6);
                    ci.CountItemsCannotContact = itemsUtility.GetAllItem(db).Count(i => i.Customer.Id == customer.Id && i.Status.Id == 7);
                    model.Add(ci);
                }
                return(model.ToList());
            }
        }