예제 #1
0
        private QuoteUser Add(QuoteUser quoteUser)
        {
            Func <QuoteUser, bool> predicate = (q) => q.QuoteId == quoteUser.QuoteId;

            if (QuotesUser.Any(predicate))
            {
                var quoteU = QuotesUser.First(predicate);
                quoteU.Number += quoteUser.Number;
                return(quoteU);
            }
            else
            {
                QuotesUser.Add(quoteUser);
                return(quoteUser);
            }
        }
예제 #2
0
        public QuoteUser Buy(Quote quote, int number)
        {
            CheckNumber(number);

            var value = quote.Value * number;

            Account.DrawOut(value);

            var quoteUser = new QuoteUser()
            {
                Id      = Guid.NewGuid().ToString(),
                QuoteId = quote.Id,
                UserId  = Id,
                Number  = number
            };

            return(Add(quoteUser));
        }