private ShareFileClient() { Apps = new AppsEntity(this); Favorites = new FavoritesEntity(this); WebhookClients = new WebhookClientsEntity(this); WebhookSubscriptions = new WebhookSubscriptionsEntity(this); Workflows = new WorkflowsEntity(this); Policies = new PoliciesEntity(this); ConnectorGroups = new ConnectorGroupsEntity(this); EncryptedEmails = new EncryptedEmailsEntity(this); FileLock = new FileLockEntity(this); RemoteUploads = new RemoteUploadsEntity(this); Reports = new ReportsEntity(this); FolderTemplates = new FolderTemplatesEntity(this); AccessControls = new AccessControlsEntity(this); Accounts = new AccountsEntity(this); AsyncOperations = new AsyncOperationsEntity(this); Capabilities = new CapabilitiesEntity(this); Devices = new DevicesEntity(this); FavoriteFolders = new FavoriteFoldersEntity(this); Groups = new GroupsEntity(this); Items = new ItemsEntity(this); Metadata = new MetadataEntity(this); Sessions = new SessionsEntity(this); Shares = new SharesEntity(this); StorageCenters = new StorageCentersEntity(this); Users = new UsersEntity(this); Zones = new ZonesEntity(this); SamlMetadata = new SamlMetadataEntity(this); }
public SharesEntity Add(SharesEntity shares) { SharesTableRepository sharesTableRepository = new SharesTableRepository(dbContext); sharesTableRepository.Add(shares); return(shares); }
public void RunTradingSimulation() { TradingSimulation tradingSimulation = new TradingSimulation(dbContext); UserEntity seller = tradingSimulation.ChooseARandomUser(); UserEntity customer = tradingSimulation.ChooseARandomUser(); while (seller.Equals(customer)) { customer = tradingSimulation.ChooseARandomUser(); } UserAndSharesEntity sellerSharesToThUserEntity = tradingSimulation.SelectSharesAndUser(seller); SharesEntity sellerShares = tradingSimulation.ChooseShareskValue(sellerSharesToThUserEntity); UserAndSharesEntity customerSharesToThUserEntity = tradingSimulation.SelectStocksForUserObjectParameters(customer, sellerShares); int Price = tradingSimulation.RandomNumberGenerator((int)sellerShares.Price); int NumberOfShares = tradingSimulation.RandomNumberGenerator(sellerSharesToThUserEntity.AmountStocks); tradingSimulation.StockPurchaseTransaction(seller, customer, Price, NumberOfShares, sellerSharesToThUserEntity, customerSharesToThUserEntity); TransactionHistoryEntity transactionHistoryEntity = new TransactionHistoryEntity() { DateTimeBay = DateTime.Now, SellerId = seller.Id, CustomerId = customer.Id, AmountShare = NumberOfShares, Cost = Price }; TransactionService transactionService = new TransactionService(dbContext); transactionService.RegisterNewTransactionHistory(transactionHistoryEntity); }
public void Remove(SharesEntity sharesInfo) { if (!sharesTableRepository.Contains(sharesInfo)) { throw new ArgumentException("This shares type doesn't exist"); } var shareToRemove = sharesTableRepository.GetById(sharesInfo.Id); sharesTableRepository.Remove(shareToRemove); sharesTableRepository.SaveChanges(); }
public async Task <IHttpActionResult> Post([FromBody] SharesEntity share) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Shares.Add(share); await db.SaveChangesAsync(); return(Created(share)); }
public void ShouldNotAddNewSharesWithWrongData() { //Arrange SharesEntity shares = new SharesEntity() { SharesType = "a", Price = 100 }; //Act sharesService.Add(shares); //Assert }
public void ShouldnotRemoveSharesThatDontExist() { //Arrange SharesEntity shares = new SharesEntity() { Id = 1, SharesType = "AAA", Price = 100 }; sharesTableRepository.Contains(shares).Returns(false); //Act sharesService.Remove(shares); }
public ActionResult <string> Remove([FromBody] SharesEntity sharesToRemove) { try { sharesService.Remove(sharesToRemove); return(Ok("Shares successfully removed")); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public ActionResult <string> Update([FromBody] SharesEntity sharesToAdd) { try { sharesService.Update(sharesToAdd); return(Ok("Shares successfully updated")); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public SharesEntity Add(SharesEntity shares) { try { dbContext.Shares.Add(shares); dbContext.SaveChanges(); return(shares); } catch (Exception) { throw; } }
public void ShouldNotAddNewSharesThatExists() { //Arrange SharesEntity shares = new SharesEntity() { SharesType = "AAA", Price = 100 }; sharesTableRepository.Contains(shares).Returns(true); //Act sharesService.Add(shares); //Assert }
public SharesEntity Put(SharesEntity shares) { try { dbContext.Update(shares); dbContext.SaveChanges(); return(shares); } catch (Exception) { throw; } }
public SharesEntity Delete(int id) { try { SharesEntity shares = dbContext.Shares.FirstOrDefault(x => x.Id == id); dbContext.Shares.Remove(shares); dbContext.SaveChanges(); return(shares); } catch (System.ArgumentNullException) { throw; } }
public void Add(SharesEntity sharesToAdd) { if (sharesToAdd.Price <= 0 || sharesToAdd.SharesType.Length < 2) { throw new ArgumentException("Wrong data"); } if (sharesTableRepository.Contains(sharesToAdd)) { throw new ArgumentException("This shares type is already exists"); } sharesTableRepository.Add(sharesToAdd); sharesTableRepository.SaveChanges(); }
public void Run() { Console.WriteLine("#################################"); Console.WriteLine("Welcome to the: Trading Simulator"); Console.WriteLine("#################################"); Console.WriteLine(@"The database already contains some values necessary to run the application!"); Console.WriteLine("-----------------------------------------------------------------------------"); Console.WriteLine("press '1' to start bidding!"); int userSelectedNumber = int.Parse(Console.ReadLine()); Console.Clear(); Console.WriteLine("Bidding start:"); while (true) { if (userSelectedNumber == 1) { Thread.Sleep(5000); UserEntity seller = tradingSimulation.ChooseARandomUser(); UserEntity customer = tradingSimulation.ChooseARandomUser(); while (seller.Equals(customer)) { customer = tradingSimulation.ChooseARandomUser(); } AddingSharesToThUserEntity sellerSharesToThUserEntity = tradingSimulation.SelectSharesAndUser(seller); SharesEntity sellerShares = tradingSimulation.ChooseShareskValue(sellerSharesToThUserEntity); AddingSharesToThUserEntity customerSharesToThUserEntity = tradingSimulation.SelectStocksForUserObjectParameters(customer, sellerShares); int Price = tradingSimulation.RandomNumberGenerator((int)sellerShares.Price); int NumberOfShares = tradingSimulation.RandomNumberGenerator(sellerSharesToThUserEntity.AmountStocks); tradingSimulation.StockPurchaseTransaction(seller, customer, Price, NumberOfShares, sellerSharesToThUserEntity, customerSharesToThUserEntity); TransactionHistoryEntity transactionHistoryEntity = new TransactionHistoryEntity() { DateTimeBay = DateTime.Now, SellerId = seller.Id, CustomerId = customer.Id, AmountShare = NumberOfShares, Cost = Price }; transactionService.RegisterNewTransactionHistory(transactionHistoryEntity); } } }
public void ShouldAddNewShares() { //Arrange SharesEntity shares = new SharesEntity() { SharesType = "AAA", Price = 100 }; //Act sharesService.Add(shares); //Assert sharesTableRepository.Received(1).Add(Arg.Is <SharesEntity>(s => s.SharesType == shares.SharesType && s.Price == shares.Price)); sharesTableRepository.Received(1).SaveChanges(); }
public int RegisterNewShares(SharesRegistrationInfo args) { var entityToAdd = new SharesEntity() { Name = args.Name, Price = args.Price }; if (this.sharesTableRepository.Contains(entityToAdd)) { throw new ArgumentException("This shares has been registered. Can't continue"); } this.sharesTableRepository.Add(entityToAdd); this.sharesTableRepository.SaveChanges(); return(entityToAdd.Id); }
public void ShouldRemoveShares() { //Arrange SharesEntity shares = new SharesEntity() { Id = 1, SharesType = "AAA", Price = 100 }; sharesTableRepository.Contains(shares).Returns(true); sharesTableRepository.GetById(shares.Id).Returns(shares); //Act sharesService.Remove(shares); //Assert sharesTableRepository.Received(1).Remove(Arg.Is <SharesEntity>(s => s.SharesType == shares.SharesType && s.Price == shares.Price)); sharesTableRepository.Received(1).SaveChanges(); }
public void Update(SharesEntity sharesInfo) { if (sharesInfo.Price <= 0 || sharesInfo.SharesType.Length < 2 || sharesInfo.Id == 0) { throw new ArgumentException("Wrong data"); } if (!sharesTableRepository.Contains(sharesInfo)) { throw new ArgumentException("This shares type doesn't exist"); } var shareToUpdate = sharesTableRepository.GetById(sharesInfo.Id); shareToUpdate.SharesType = sharesInfo.SharesType; shareToUpdate.Price = sharesInfo.Price; sharesTableRepository.Update(shareToUpdate); sharesTableRepository.SaveChanges(); }
private ShareFileClient() { ConnectorGroups = new ConnectorGroupsEntity(this); FolderTemplates = new FolderTemplatesEntity(this); AccessControls = new AccessControlsEntity(this); Accounts = new AccountsEntity(this); AsyncOperations = new AsyncOperationsEntity(this); Capabilities = new CapabilitiesEntity(this); FavoriteFolders = new FavoriteFoldersEntity(this); Groups = new GroupsEntity(this); Items = new ItemsEntity(this); Metadata = new MetadataEntity(this); Sessions = new SessionsEntity(this); Shares = new SharesEntity(this); StorageCenters = new StorageCentersEntity(this); Users = new UsersEntity(this); Zones = new ZonesEntity(this); }
public bool Contains(SharesEntity shares) { return(this.dbContext.Shares.Any(s => s.SharesType == shares.SharesType || s.Id == shares.Id)); }
public void Add(SharesEntity sharesToAdd) { this.dbContext.Shares.Add(sharesToAdd); }
public AddingSharesToThUserEntity SelectStocksForUserObjectParameters(UserEntity userEntity, SharesEntity sharesEntity) { var usersAndShare = transactionService.SelectStocksForUserObjectParameters(userEntity, sharesEntity); int count = usersAndShare.Count; try { return(usersAndShare[0]); } catch (System.ArgumentOutOfRangeException) { AddingSharesToThUserEntity addingSharesToThUserEntity = new AddingSharesToThUserEntity(); return(addingSharesToThUserEntity); } }
public List <AddingSharesToThUserEntity> GetUserAndShareParameters(UserEntity userEntity, SharesEntity sharesEntity) { int idUser = userEntity.Id; int idShare = sharesEntity.Id; var userAndShare = dbContext.UsersAndShares.Where(q => q.UserId == idUser && q.ShareId == idShare).ToList(); return(userAndShare); }
public void Remove(SharesEntity sharesToRemove) { this.dbContext.Shares.Remove(sharesToRemove); }
public IActionResult Post([FromBody] SharesEntity shares) { SharesService sharesService = new SharesService(db); return(Ok(sharesService.Add(shares))); }
public void Update(SharesEntity sharesToAdd) { this.dbContext.Entry(sharesToAdd).State = EntityState.Modified; }
public bool Contains(SharesEntity sharesEntity) { return(this.dbContext.Shares.Any(f => f.Name == sharesEntity.Name && f.Price == sharesEntity.Price)); }
protected override void Seed(TradesEmulatorDbContext context) { var client1 = new ClientEntity { Name = "Aaron Wolf", Phone = "(812) 904 33 10", Balance = 10000M, RegistationDateTime = DateTime.Now }; var client2 = new ClientEntity { Name = "Betany Stutoff", Phone = "(954) 404 13 11", Balance = 9030M, RegistationDateTime = DateTime.Now }; var client3 = new ClientEntity { Name = "Anton Zaycev", Balance = 1076M, RegistationDateTime = DateTime.Now }; var client4 = new ClientEntity { Name = "Paul Beat", Phone = "(383) 01 21 312 ", Balance = 51003M, RegistationDateTime = DateTime.Now }; var client5 = new ClientEntity { Name = "Victor Powers", Balance = 19200M, RegistationDateTime = DateTime.Now }; var client6 = new ClientEntity { Name = "Liam Piam", Phone = "(800) 2000 501", Balance = 22120M, RegistationDateTime = DateTime.Now }; var client7 = new ClientEntity { Name = "Varian Wrynn", Balance = 20000M, RegistationDateTime = DateTime.Now }; var client8 = new ClientEntity { Name = "Alexander Bely", Balance = 8100M, RegistationDateTime = DateTime.Now }; context.Clients.Add(client1); context.Clients.Add(client2); context.Clients.Add(client3); context.Clients.Add(client4); context.Clients.Add(client5); context.Clients.Add(client6); context.Clients.Add(client7); context.Clients.Add(client8); var shares1 = new SharesEntity { SharesType = "Sbeerbank", Price = 836M }; var shares2 = new SharesEntity { SharesType = "MMM", Price = 2874M }; var shares3 = new SharesEntity { SharesType = "Motherland", Price = 282M }; context.Shares.Add(shares1); context.Shares.Add(shares2); context.Shares.Add(shares3); var clientShares1 = new ClientSharesEntity { Shares = shares1, Quantity = 43, Client = client1 }; var clientShares2 = new ClientSharesEntity { Shares = shares1, Quantity = 30, Client = client2 }; var clientShares3 = new ClientSharesEntity { Shares = shares1, Quantity = 12, Client = client3 }; var clientShares4 = new ClientSharesEntity { Shares = shares1, Quantity = 2, Client = client4 }; var clientShares5 = new ClientSharesEntity { Shares = shares1, Quantity = 92, Client = client5 }; var clientShares6 = new ClientSharesEntity { Shares = shares1, Quantity = 122, Client = client6 }; var clientShares7 = new ClientSharesEntity { Shares = shares1, Quantity = 0, Client = client7 }; var clientShares8 = new ClientSharesEntity { Shares = shares1, Quantity = 0, Client = client8 }; var clientShares9 = new ClientSharesEntity { Shares = shares2, Quantity = 2, Client = client1 }; var clientShares10 = new ClientSharesEntity { Shares = shares2, Quantity = 24, Client = client2 }; var clientShares11 = new ClientSharesEntity { Shares = shares2, Quantity = 43, Client = client3 }; var clientShares12 = new ClientSharesEntity { Shares = shares2, Quantity = 21, Client = client4 }; var clientShares13 = new ClientSharesEntity { Shares = shares2, Quantity = 24, Client = client5 }; var clientShares14 = new ClientSharesEntity { Shares = shares2, Quantity = 36, Client = client6 }; var clientShares15 = new ClientSharesEntity { Shares = shares2, Quantity = 1, Client = client7 }; var clientShares16 = new ClientSharesEntity { Shares = shares2, Quantity = 0, Client = client8 }; var clientShares17 = new ClientSharesEntity { Shares = shares3, Quantity = 87, Client = client1 }; var clientShares18 = new ClientSharesEntity { Shares = shares3, Quantity = 11, Client = client2 }; var clientShares19 = new ClientSharesEntity { Shares = shares3, Quantity = 39, Client = client3 }; var clientShares20 = new ClientSharesEntity { Shares = shares3, Quantity = 48, Client = client4 }; var clientShares21 = new ClientSharesEntity { Shares = shares3, Quantity = 101, Client = client5 }; var clientShares22 = new ClientSharesEntity { Shares = shares3, Quantity = 98, Client = client6 }; var clientShares23 = new ClientSharesEntity { Shares = shares3, Quantity = 2, Client = client7 }; var clientShares24 = new ClientSharesEntity { Shares = shares3, Quantity = 34, Client = client8 }; context.ClientShares.Add(clientShares1); context.ClientShares.Add(clientShares2); context.ClientShares.Add(clientShares3); context.ClientShares.Add(clientShares4); context.ClientShares.Add(clientShares5); context.ClientShares.Add(clientShares6); context.ClientShares.Add(clientShares7); context.ClientShares.Add(clientShares8); context.ClientShares.Add(clientShares9); context.ClientShares.Add(clientShares10); context.ClientShares.Add(clientShares11); context.ClientShares.Add(clientShares12); context.ClientShares.Add(clientShares13); context.ClientShares.Add(clientShares14); context.ClientShares.Add(clientShares15); context.ClientShares.Add(clientShares16); context.ClientShares.Add(clientShares17); context.ClientShares.Add(clientShares18); context.ClientShares.Add(clientShares19); context.ClientShares.Add(clientShares20); context.ClientShares.Add(clientShares21); context.ClientShares.Add(clientShares22); context.ClientShares.Add(clientShares23); context.ClientShares.Add(clientShares24); context.SaveChanges(); }
public List <UserAndSharesEntity> SelectStocksForUserObjectParameters(UserEntity userEntity, SharesEntity sharesEntity) { TransactionRepositories transactionRepositories = new TransactionRepositories(dbContext); var usersAndShare = transactionRepositories.GetUserAndShareParameters(userEntity, sharesEntity); return(usersAndShare); }