Beispiel #1
0
 public InventoryReport(HoldingService holdingService, IClassificationService classificationService, BranchService branchService)
 {
     this.holdingService        = holdingService;
     this.classificationService = classificationService;
     this.branchService         = branchService;
     congress = new LibraryOfCongress();
 }
        public void AddNewBook()
        {
            var holding = new HoldingService().Retrieve(barcode1);

            Assert.That(holding.Barcode, Is.EqualTo("QA123:1"));
            Assert.That(holding.BranchId, Is.EqualTo(Branch1Id));
        }
Beispiel #3
0
        private HoldingService CreateHoldingService()
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new HoldingService(userId);

            return(service);
        }
        public IHttpActionResult Post(HoldingTransactionCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var userId = Guid.Parse(User.Identity.GetUserId());

            var holdingservice = new HoldingService(userId);
            var walletService  = new WalletService(userId);
            var service        = CreateHoldingTransactionService();

            var usdValue = model.CryptoTransactionAmount * model.MarketValue;

            if (walletService.GetWallet().WalletBalance - usdValue < 0)
            {
                return(BadRequest());
            }

            if (!service.CreateHoldingTransaction(model))
            {
                return(InternalServerError());
            }

            walletService.UpdateWalletBalance(-usdValue);

            holdingservice.UpdateHoldingBalance(model.HoldingId, model.CryptoTransactionAmount);

            return(Ok());
        }
Beispiel #5
0
 public void Initialize()
 {
     service = new HoldingService
     {
         ClassificationService = new DummyClassificationService()
     };
     service.DeleteAllHoldings();
 }
Beispiel #6
0
        public async Task <IHttpActionResult> Register(RegisterBindingModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var user = new ApplicationUser()
            {
                UserName = model.Email, Email = model.Email
            };

            IdentityResult result = await UserManager.CreateAsync(user, model.Password);

            if (!result.Succeeded)
            {
                return(GetErrorResult(result));
            }

            var accountservice = new AccountService();
            var userId         = Guid.Parse(accountservice.GetGuid(user.Email));
            var walletService  = new WalletService(userId);

            var wallet = new WalletCreate
            {
                WalletBalance = 50000
            };

            if (!walletService.CreateWallet(wallet))
            {
                return(InternalServerError(new Exception("Error creating Wallet.")));
            }

            var currencyService = new CurrencyService();
            var currencies      = currencyService.GetCurrencies();

            foreach (var currency in currencies)
            {
                var holdingService = new HoldingService(userId);

                var holding =
                    new HoldingCreate()
                {
                    CryptoHoldingBalance = 0,
                    CurrencyId           = currency.CurrencyId,
                    WalletId             = walletService.GetWalletId()
                };

                if (!holdingService.CreateHolding(holding))
                {
                    return(InternalServerError(new Exception($"Error creating entry for Holding: {holding.CurrencyId}")));
                }
            }

            return(Ok());
        }
Beispiel #7
0
        public void PersistHoldings()
        {
            var secondService = new HoldingService();

            Assert.IsNull(secondService.Retrieve(book1Barcode));

            service.Add(Book1Classification, Branch1Id);
            var holding = secondService.Retrieve(book1Barcode);

            Assert.That(holding.Barcode, Is.EqualTo(book1Barcode));
        }
        public void Initialize()
        {
            classificationService = new StubClassificationService();
            classificationService.AddBook(Classification1, "T1", "A1", "2001");
            classificationService.AddBook(Classification2, "T2", "A2", "2002");

            scanner = new ScanStation(Branch1Id, classificationService);

            holdingService = new HoldingService();
            holdingService.DeleteAllHoldings();

            patronService = new PatronService();
            PatronService.DeleteAllPatrons();

            patronId1 = patronService.Add("Joe");
            patronId2 = patronService.Add("Jane");

            var holding = scanner.AddNewMaterial(Isbn1);

            Assert.That(holding.Barcode, Is.EqualTo(barcode1));
        }
        public void AddData()
        {
            branchService = new BranchService();
            var east = branchService.Add("East");
            var west = branchService.Add("West");

            classificationService = new MasterClassificationService();
            classificationService.DeleteAllBooks();
            classificationService.AddBook("1", "Trial, The", "Kafka, Franz", "1925");
            classificationService.AddBook("2", "Castle, The", "Kafka, Frank", "1926");
            classificationService.AddBook("3", "Catch-22", "Heller, Joseph", "1961");
            classificationService.AddBook("4", "Pale Fire", "Nabokov, Vladimir", "1962");
            classificationService.AddBook("5", "Lolita", "Nabokov, Vladimir", "1955");

            holdingService = new HoldingService();
            holdingService.DeleteAllHoldings();
            holdingService.ClassificationService = classificationService;
            holdingService.Add("1", east);
            holdingService.Add("2", west);
            holdingService.Add("3", east);
            holdingService.Add("4", east);
            holdingService.Add("5", west);
        }