예제 #1
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Listening for new messages...");

            var messageingService = new MessagingService();

            using (var context = new CheckoutContext())
            {
                context.Database.EnsureCreated();

                messageingService.ActivateMessageListener(ConfigurationDefaults.RABBITMQ_HOST, ConfigurationDefaults.RABBITMQ_EXCHANGENAME,
                                                          (nav) =>
                {
                    var navObject = JsonConvert.DeserializeObject <Navigation>(nav);
                    context.Navigations.Add(navObject);
                    context.SaveChanges();

                    Console.WriteLine($"MSG: {navObject.ToString()}");
                });

                while (Console.Read() != 13)
                {
                }

                messageingService.DeactivateMessageListener();
            }
        }
예제 #2
0
파일: Program.cs 프로젝트: kl00t/Checkout
        static void Main(string[] args)
        {
            using (var context = new CheckoutContext())
            {
                context.Products.Add(new Product
                {
                    Id           = Guid.NewGuid(),
                    Sku          = "A",
                    UnitPrice    = 9.99m,
                    Description  = "new product",
                    SpecialOffer = new SpecialOffer
                    {
                        Id          = Guid.NewGuid(),
                        IsAvailable = false
                    }
                });

                context.SaveChanges();

                var products = context.Products.ToList <Product>();
                foreach (var product in products)
                {
                    Console.WriteLine(product.Sku);
                }

                Console.WriteLine(@"Press any key.");
                Console.ReadLine();
            }
        }
예제 #3
0
        public PaymentsController(CheckoutContext context)
        {
            _context = context;

            if (!_context.Loaded)
            {
                _context.AddRandomData();
            }
        }
예제 #4
0
        public void MockContext()
        {
            var options = new DbContextOptionsBuilder <CheckoutContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            context = new CheckoutContext(options);
            DbInitialiser.Initialize(context);
        }
예제 #5
0
        public CheckoutController(CheckoutContext context)
        {
            _context = context;

            if (_context.CheckoutItems.Count() == 0)
            {
                // Create a new CheckoutItem if collection is empty,
                // which means you can't delete all CheckoutItems.
                _context.CheckoutItems.Add(new CheckoutItem {
                    Name = "Juan Requeijo"
                });
                _context.SaveChanges();
            }
        }
예제 #6
0
        /// <summary>
        /// The get checkout context.
        /// </summary>
        /// <param name="basket">
        /// The basket.
        /// </param>
        /// <param name="merchelloContext">
        /// The merchello context.
        /// </param>
        /// <param name="settings">
        /// The settings.
        /// </param>
        /// <returns>
        /// The <see cref="ICheckoutContext"/>.
        /// </returns>
        internal static ICheckoutContext CreateCheckoutContext(this IBasket basket, IMerchelloContext merchelloContext, ICheckoutContextSettings settings)
        {
            var context = CheckoutContext.CreateCheckoutContext(merchelloContext, basket.Customer, basket.VersionKey, settings);

            if (context.IsNewVersion && basket.Validate())
            {
                if (!context.ItemCache.Items.Any() && basket.Validate())
                {
                    // this is either a new preparation or a reset due to version
                    foreach (var item in basket.Items)
                    {
                        // convert to a LineItem of the same type for use in the CheckoutPrepartion collection
                        context.ItemCache.AddItem(item.AsLineItemOf <ItemCacheLineItem>());
                    }
                }
            }

            return(context);
        }
 public void Load()
 {
     try
     {
         IAvailableCheckout[] checkoutContextAvailableNow = CheckoutContext.AvailableNow();
         AvailableCheckouts = new ObservableCollection <IAvailableCheckout>(checkoutContextAvailableNow);
     }
     catch (DistributorRequestException)
     {
         DisplayState.NotifyUser("There has been an issue contacting your distributor server. Please try again. If the problem persists, please contact your system administrator.");
     }
     catch (DistributorIntegrityException)
     {
         DisplayState.NotifyUser("We have detected an integrity issue with your distributor server. Please contact your system administrator.");
     }
     catch (NoDistributorException)
     {
         DisplayState.NotifyUser("There is no distributor server configured. Please configure a server in the configuration dialog.");
     }
 }
예제 #8
0
        public void BuyAProduct()
        {
            //Arrange
            var minpriceValueToSet = 100;
            var maxpriceValueToSet = 2000;
            var name = "‘ол≥о";

            var booksResultsPage = new FilterPage(driver);
            var SingleBookPage   = new GoodsItemPage(driver);
            var Basket           = new BasketPage(driver);
            var Checkout         = new CheckoutPage(driver);

            //Act
            FilteringContext.FilterByPriceRange(booksResultsPage, minpriceValueToSet, maxpriceValueToSet);
            FilteringContext.ClickCheckbox(booksResultsPage, name);
            ResultSetContext.BuyElement(booksResultsPage, 0);
            BasketContext.ProceedToCheckout(Basket);
            CheckoutContext.InputReceiverData(Checkout, "Testik", "0980000001", "*****@*****.**");
            //Assert
            GoodStateVerificationContext.VerifyMakeOrderIsClickable(Checkout);
        }
예제 #9
0
        public void Buy()
        {
            //Arrange
            var minpriceValueToSet = 100;
            var maxpriceValueToSet = 2000;
            var name            = "ю-аю-аю-цю-кю-лю-цю";
            int HowCanlongIwait = 15000;

            var booksResultsPage = new FilterPage(driver);
            var SingleBookPage   = new GoodsItemPage(driver);
            var Basket           = new BasketPage(driver);
            var Checkout         = new CheckoutPage(driver);

            //Act
            FilteringContext.FilterByPriceRange(booksResultsPage, minpriceValueToSet, maxpriceValueToSet, HowCanlongIwait);
            FilteringContext.ClickCheckbox(booksResultsPage, name, HowCanlongIwait);
            ResultSetContext.BuyElement(booksResultsPage, 0, HowCanlongIwait);
            BasketContext.ProceedToCheckout(Basket, HowCanlongIwait);
            CheckoutContext.InputReceiverData(Checkout, HowCanlongIwait);//modification with volid date
            //Assert
            VerificationContext.VerifyMakeOrderIsClickable(Checkout);
        }
 public CustomerService(CheckoutContext checkoutContext)
 {
     _checkoutContext = checkoutContext;
 }
예제 #11
0
 public CartRepository(CheckoutContext context)
 {
     this.context = context;
 }
예제 #12
0
 public UoW(CheckoutContext context)
 {
     Context = context;
 }
예제 #13
0
 public OfferRepository(CheckoutContext context) : base(context)
 {
 }
예제 #14
0
 public ProductUoW(CheckoutContext context) : base(context)
 {
     ProductRepository      = new ProductRepository(context);
     DiscountFileRepository = new OfferRepository(context);
 }
 public ProductService(CheckoutContext checkoutContext)
 {
     _checkoutContext = checkoutContext;
 }
예제 #16
0
 protected Repository(CheckoutContext dbContext)
 {
     DbContext = dbContext;
     DbSet     = DbContext.Set <T>();
 }
 // TODO: replace with valid logic
 public ProductRepository(CheckoutContext context)
 {
     this.context = context;
 }
예제 #18
0
        public CheckoutServiceTests()
        {
            // TODO: Consider refactoring data lists.
            var equipmentData = new List <ICheckable>
            {
                new Equipment
                {
                    SerialNumber        = 100,
                    Location            = "Warehouse 1",
                    LastCheckedById     = 0,
                    RequestedByIds      = new List <int> {
                    },
                    IsAvailable         = true,
                    RequiredSafetyLevel = SafetyLevel.A
                },
                new Equipment
                {
                    SerialNumber        = 200,
                    Location            = "Warehouse 2",
                    LastCheckedById     = 0,
                    RequestedByIds      = new List <int> {
                    },
                    IsAvailable         = true,
                    RequiredSafetyLevel = SafetyLevel.B
                },
                new Equipment
                {
                    SerialNumber        = 300,
                    Location            = "Warehouse 3",
                    LastCheckedById     = 003,
                    RequestedByIds      = new List <int> {
                    },
                    IsAvailable         = false,
                    RequiredSafetyLevel = SafetyLevel.C
                }
            };
            var employeeData = new List <Employee>
            {
                new Employee
                {
                    Id                 = 001,
                    CheckedItems       = new List <ICheckable> {
                    },
                    CheckedItemHistory = new List <ICheckable> {
                        equipmentData.First(e => e.SerialNumber == 100)
                    },
                    EMailAddress           = "*****@*****.**",
                    MaximumSafetyClearance = SafetyLevel.A
                },
                new Employee
                {
                    Id                     = 002,
                    CheckedItems           = new List <ICheckable> {
                    },
                    CheckedItemHistory     = new List <ICheckable> {
                    },
                    EMailAddress           = "*****@*****.**",
                    MaximumSafetyClearance = SafetyLevel.B
                },
                new Employee
                {
                    Id           = 003,
                    CheckedItems = new List <ICheckable> {
                        equipmentData.First(e => e.SerialNumber == 300)
                    },
                    CheckedItemHistory     = new List <ICheckable> {
                    },
                    EMailAddress           = "*****@*****.**",
                    MaximumSafetyClearance = SafetyLevel.C
                },
                new Employee
                {
                    Id                     = 004,
                    CheckedItems           = new List <ICheckable> {
                    },
                    CheckedItemHistory     = new List <ICheckable> {
                    },
                    EMailAddress           = "*****@*****.**",
                    MaximumSafetyClearance = SafetyLevel.D
                }
            };

            _context = Mock.Of <CheckoutContext>(m =>
                                                 m.Equipment == GetQueryableMockDbSet(equipmentData) &&
                                                 m.Employees == GetQueryableMockDbSet(employeeData));
        }
 public BasketService(CheckoutContext checkoutContext, ProductService productService)
 {
     _checkoutContext = checkoutContext;
     _productService  = productService;
 }
 public CountryRepository(CheckoutContext context)
 {
     this.context = context;
 }
예제 #21
0
        static void Main(string[] args)
        {
            bool loop = true;

            while (loop)
            {
                Console.WriteLine("Employee Equipment Checkout System v1.00 -- ecs h for help");
                Console.WriteLine("Please login using 'ecs lin' + your employee id.");

                var      userInput = Console.ReadLine().RemoveWhitespace();
                Employee user      = null;

                switch (userInput.RemoveDigits())
                {
                case "ecsh":
                case "ecshelp":
                    PrintAllCommands(user);
                    break;

                case "ecslin":
                case "ecslogin":
                    using (var context = new CheckoutContext())
                    {
                        var service = new CheckoutService(context);

                        try
                        {
                            if (int.TryParse(userInput.OnlyDigits(), out int employeeId))
                            {
                                user = service.GetEmployeeById(employeeId);
                            }
                        }
                        catch (ArgumentException)
                        {
                            Console.WriteLine("Error: Employee Id given is either invalid or does not exist.");
                        }
                    }
                    break;

                case "ecslout":
                case "ecslogout":
                    user = null;
                    break;

                case "ecsout":
                case "ecscheckout":
                    using (var context = new CheckoutContext())
                    {
                        var service = new CheckoutService(context);

                        try
                        {
                            if (int.TryParse(userInput.OnlyDigits(), out int itemSerial))
                            {
                                service.Checkout(user.Id, itemSerial);
                            }
                        }
                        catch (ArgumentException)
                        {
                            Console.WriteLine("Error: Item serial given is either invalid or does not exist.");
                        }
                    }
                    break;

                case "ecsin":
                case "ecscheckin":
                    using (var context = new CheckoutContext())
                    {
                        var service = new CheckoutService(context);

                        try
                        {
                            if (int.TryParse(userInput.OnlyDigits(), out int itemSerial))
                            {
                                service.CheckIn(user.Id, itemSerial);
                            }
                        }
                        catch (ArgumentException)     // TODO: Several fail states here, include more detailed error messages
                        {
                            Console.WriteLine("Error: Item serial given is either invalid or does not exist.");
                        }
                    }
                    break;

                case "ecsexit":
                    loop = false;
                    break;

                default:
                    break;
                }
            }
        }
예제 #22
0
 public ProductRepository(CheckoutContext context) : base(context)
 {
 }