private void RemoveCounterparty(string counterpartyUniqueName, IList <ICounterparty> counterparties)
        {
            ICounterparty counterparty = counterparties.FirstOrDefault(x => x.Name == counterpartyUniqueName);

            counterparties.Remove(counterparty);
            writer.Write($"{counterpartyUniqueName} removed successfully!");
        }
        public void ExecuteThisCommand(string[] commandParameters)
        {
            this.coreValidator.EitherOrParameterLength(commandParameters, 6, 8);

            string    employeeFirstName = commandParameters[1];
            IEmployee employee;

            if (commandParameters.Length == 8)
            {
                employee = this.coreValidator.EmployeeUnique(this.database.Employees, employeeFirstName, commandParameters[6], commandParameters[7]);
            }
            else
            {
                employee = this.coreValidator.EmployeeUnique(this.database.Employees, employeeFirstName, null, null);
            }

            string supplierUniqueName = commandParameters[2];

            this.coreValidator.CounterpartyNotRegistered(this.database.Suppliers, supplierUniqueName, "supplier");

            ICounterparty supplier = this.database.Suppliers.FirstOrDefault(x => x.Name == supplierUniqueName);

            string stockName = commandParameters[3];

            string stockUniqueNumber = commandParameters[4];

            decimal purchasePrice = this.coreValidator.DecimalFromString(commandParameters[5], "purchasePrice");

            IAsset stock = this.autoServiceFactory.CreateStock(stockName, employee, stockUniqueNumber, purchasePrice, supplier);

            this.OrderStockFromSupplier((IStock)stock);
        }
Beispiel #3
0
 public Trade(int id, DateTime tradeTime, ICounterparty counterparty, ITransferable itemTraded, int quantityTraded, double itemPrice, TradeState state)
 {
     Id = id;
     TradeTime = tradeTime;
     Counterparty = counterparty;
     ItemTraded = itemTraded;
     QuantityTraded = quantityTraded;
     ItemPrice = itemPrice;
     State = state;
 }
 public static IOrder BuildSellOrder(
     string orderRef,
     DateTime createdTime,
     ICounterparty createdBy,
     ITransferable item,
     int unitCount,
     Money unitPrice)
 {
     IOrder order = new Order(orderRef, createdTime, createdBy, OrderDirection.Sell, OrderType.LimitOrder, TimeInForce.GoodTillCancelled, item, unitCount, unitPrice);
     return order;
 }
Beispiel #5
0
        public static IInvoice InvoiceExists(IList <ICounterparty> clients, ICounterparty client, string invoiceNum)
        {
            ICounterparty clientFound = clients.FirstOrDefault(fd => fd.UniqueNumber == client.UniqueNumber);
            IInvoice      invoice     = clientFound.Invoices.FirstOrDefault(fd => fd.Number == invoiceNum);

            if (invoice == null)
            {
                throw new ArgumentException("Invoice does not exist!");
            }
            return(invoice);
        }
Beispiel #6
0
        private void AddSupplier(string name, string address, string uniqueNumber)
        {
            ICounterparty supplier = this.factory.CreateSupplier(name, address, uniqueNumber);

            if (suppliers.FirstOrDefault(x => x.UniqueNumber == uniqueNumber) != null)
            {
                throw new ArgumentException(
                          "Supplier with the same unique number already exist. Please check the number and try again!");
            }
            this.suppliers.Add(supplier);
            Console.WriteLine(supplier);
            //Console.WriteLine($"Supplier {name} added successfully with Id {this.suppliers.Count}!");
        }
        private void AddSupplier(string name, string address, string uniqueNumber, bool interfaceIsAvailable = false)
        {
            ICounterparty supplier = this.factory.CreateSupplier(name, address, uniqueNumber, interfaceIsAvailable);

            var sameSupplierFound = this.database.Suppliers.FirstOrDefault(x => x.UniqueNumber == uniqueNumber);

            if (sameSupplierFound != null)
            {
                throw new ArgumentException(
                          "Supplier with the same unique number already exist. Please check the number and try again!");
            }
            this.database.Suppliers.Add(supplier);

            this.writer.Write($"Supplier {name} added successfully with Id {this.database.Suppliers.Count}!");
        }
Beispiel #8
0
        private void AddClient(string name, string address, string uniqueNumber)
        {
            if (clients.Any(x => x.UniqueNumber == uniqueNumber))
            {
                var clientExisting = this.clients.First(f => f.UniqueNumber == uniqueNumber);
                throw new ArgumentException(
                          $"Client with the same unique number {clientExisting.Name} already exists. Please check the number and try again!");
            }

            ICounterparty client = this.factory.CreateClient(name, address, uniqueNumber);

            this.clients.Add(client);
            Console.WriteLine(client);
            //Console.WriteLine($"Client {name} added successfully with Id {this.clients.Count}!");
        }
Beispiel #9
0
        public Stock(string name, IEmployee responsibleEmployee, string uniqueNumber, decimal purchasePrice, ICounterparty supplier) : base(name, responsibleEmployee, uniqueNumber)
        {
            if (purchasePrice < 0 || purchasePrice > 1000000)
            {
                throw new ArgumentException("Purchase price cannot be negative or greater than 1mln!");
            }
            this.purchasePrice = purchasePrice;
            if (supplier == null)
            {
                throw new ArgumentException("Null ");
            }
            this.supplier = supplier;

            if (UniqueNumber.Length < minLen || UniqueNumber.Length > maxLen)
            {
                throw new ArgumentException($"The stock unique number bust be between {minLen} and {maxLen} characters long!");
            }
        }
Beispiel #10
0
 protected Order(IEmployee responsibleEmployee, ICounterparty supplier, IValidateModel modelValidator)
     : base(responsibleEmployee, TypeOfWork.Ordering, modelValidator)
 {
     modelValidator.CheckNullObject(supplier);
     this.supplier = supplier;
 }
Beispiel #11
0
 public OrderStock(IEmployee responsibleEmployee, ICounterparty supplier, IStock stock, IValidateModel modelValidator)
     : base(responsibleEmployee, supplier, modelValidator)
 {
     modelValidator.CheckNullObject(stock);
     this.stock = stock;
 }
 public OrderStock(IEmployee responsibleEmployee, ICounterparty supplier, IStock stock)
     : base(responsibleEmployee, supplier)
 {
     Validate.CheckNullObject(stock);
     this.stock = stock;
 }
Beispiel #13
0
        public static IQueryable <IContact> GetContactsByName(string name, string personShortName, ICounterparty counterparty)
        {
            var nonBreakingSpace = new string('\u00A0', 1);
            var space            = new string('\u0020', 1);

            name = name.ToLower().Replace(nonBreakingSpace, space).Replace(". ", ".");

            var contacts = Contacts.GetAll()
                           .Where(x => (x.Name.ToLower().Replace(nonBreakingSpace, space).Replace(". ", ".") == name) ||
                                  (x.Person != null && string.Equals(x.Person.ShortName, personShortName, StringComparison.InvariantCultureIgnoreCase)));

            if (counterparty != null)
            {
                return(contacts.Where(c => c.Company.Equals(counterparty)));
            }

            return(contacts);
        }
Beispiel #14
0
 public IAsset CreateStock(string name, IEmployee responsibleEmployee, string uniqueNumber, decimal purchasePrice, ICounterparty supplier)
 {
     return(new Stock(name, responsibleEmployee, uniqueNumber, purchasePrice, supplier));
 }
Beispiel #15
0
 protected Order(IEmployee responsibleEmployee, ICounterparty supplier)
     : base(responsibleEmployee, TypeOfWork.Ordering)
 {
     Validate.CheckNullObject(supplier);
     this.supplier = supplier;
 }
Beispiel #16
0
 public IOrderStock CreateOrderStock(IEmployee responsibleEmployee, ICounterparty supplier, IStock stock, IValidateModel modelValidator)
 {
     return(new OrderStock(responsibleEmployee, supplier, stock, modelValidator));
 }
Beispiel #17
0
 public IOrderStock CreateOrderStock(IEmployee responsibleEmployee, ICounterparty supplier, IStock stock)
 {
     return(new OrderStock(responsibleEmployee, supplier, stock));
 }
Beispiel #18
0
        public Order(
            string orderRef,
            DateTime createdTime,
            ICounterparty createdBy,
            OrderDirection orderDirection,
            OrderType type,
            TimeInForce timeInForce,
            ITransferable item,
            int unitCount,
            Money unitPrice)
        {
            OrderRef = orderRef;
            CreatedTime = createdTime;
            CreatedBy = createdBy;
            Direction = orderDirection;
            Type = type;
            TimeInForce = timeInForce;
            Item = item;
            Size = unitCount;
            Price = unitPrice;

            FilledSize = 0;
            Status = OrderStatus.Created;

            Trades = new List<Trade>();
        }