예제 #1
0
        private void FillRepo()
        {
            var memberService = new SimpleMemberService(this.MainRepository);
            var service = new AuctionService(this.MainRepository, memberService);

            if (service.GetAll().Any())
                return;

            var me = memberService.GetCurrentMember();

            service.Save(new Auction
            {
                Title = "My asdf Auction",
                StartDateTimeUtc = DateTime.UtcNow.AddSeconds(10),
                EndDateTimeUtc = DateTime.UtcNow.AddDays(14),
                StartPrice = 123,
                Seller = me,
                IsRunning = true,
                IsClosed = false
            });

            service.Save(new Auction
            {
                Title = "My Second Auction",
                StartDateTimeUtc = DateTime.UtcNow.AddSeconds(30),
                EndDateTimeUtc = DateTime.UtcNow.AddDays(24),
                StartPrice = 22,
                Seller = me,
                IsRunning = false,
                IsClosed = true
            });
        }
예제 #2
0
        public App()
        {
            var ensureDLLIsCopied = SqlProviderServices.Instance;
            Database.SetInitializer(new MigrateDatabaseToLatestVersion<MainDbContext, Configuration>());

            // this.MainRepository = new FileSystemMainRepository("appdata.json");
            this.MainRepository = new EFMainRepository();
            this.MainRepository.SaveChanges();

            var memberService = new SimpleMemberService(this.MainRepository);
            var service = new AuctionService(this.MainRepository, memberService);

            // Dummy Data
            if (!service.GetAll().Any())
            {
                var me = memberService.GetCurrentMember();
                service.Save(new Auction
                {
                    Title = "My First Auction",
                    StartDateTimeUtc = DateTime.UtcNow.AddSeconds(10),
                    EndDateTimeUtc = DateTime.UtcNow.AddDays(14),
                    StartPrice = 72,
                    Seller = me
                });
            }

            this.AuctionRunner = new AuctionRunner(this.MainRepository);
            this.AuctionRunner.Start();
        }
예제 #3
0
        public static void Main()
        {
            Console.WriteLine("DotNetBay Commandline");

            AuctionRunner auctionRunner = null;

            try
            {
                var store = new FileSystemMainRepository("store.json");
                var auctionService = new AuctionService(store, new SimpleMemberService(store));

                auctionRunner = new AuctionRunner(store);

                Console.WriteLine("Started AuctionRunner");
                auctionRunner.Start();

                var allAuctions = auctionService.GetAll();

                Console.WriteLine("Found {0} auctions returned by the service.", allAuctions.Count());

                Console.Write("Press enter to quit");
                Console.ReadLine();
            }
            finally
            {
                if (auctionRunner != null)
                {
                    auctionRunner.Dispose();
                }
            }

            Environment.Exit(0);
        }
예제 #4
0
 public MainWindow()
 {
     if ((Application.Current as App) != null)
     {
         var service = new AuctionService(((App)Application.Current).MainRepository, new SimpleMemberService(((App)Application.Current).MainRepository));
         foreach (var auction in service.GetAll())
         {
             this.Auctions.Add(auction);
         }
     }
     this.DataContext = this;
     this.InitializeComponent();
 }
예제 #5
0
        public void GivenAProperService_SavesAValidAuction_ShouldReturnSameFromAuctionList()
        {
            var repo = new InMemoryMainRepository();
            var userService = new SimpleMemberService(repo);
            var service = new AuctionService(repo, userService);

            var auction = CreateGeneratedAuction();

            auction.Seller = userService.Add("Seller", "*****@*****.**");

            service.Save(auction);

            var auctionFromService = service.GetAll().First();
            Assert.AreEqual(auctionFromService, auction);
        }
예제 #6
0
        public static void Main(string[] args)
        {
            var ensureDLLIsCopied = System.Data.Entity.SqlServer.SqlProviderServices.Instance;

            Console.WriteLine("DotNetBay Commandline");

            var store = new FileSystemMainRepository("store.json");

            var auctionService = new AuctionService(store, new SimpleMemberService(store));
            var auctionRunner = new AuctionRunner(store);

            Console.WriteLine("Started AuctionRunner");
            auctionRunner.Start();

            var allAuctions = auctionService.GetAll();

            Console.WriteLine("Found {0} auctions returned by the service.", allAuctions.Count());

            Console.Write("Press enter to quit");
            Console.ReadLine();

            Environment.Exit(0);
        }