Exemple #1
0
        public async Task <AccountSet> CreateAccountSet(Account account, IEnumerable <Account> accounts)
        {
            accounts = accounts.Where(a => a != null).Distinct();//normalize

            using (this._scopeableFactory.Create())
            {
                var accountSet = new AccountSet {
                    AccountId = account.Id
                };
                if (accounts.Any())
                {
                    await this._repositoryAccountSet.Add(accountSet);

                    foreach (var acc in accounts)
                    {
                        if (!acc.IsTransient())
                        {
                            await this._repositoryAccountSetAccounts.Add(new AccountSetAccounts
                            {
                                AccountId    = acc.Id,
                                AccountSetId = accountSet.Id
                            });
                        }
                    }
                }
                return(accountSet);
            }
        }
Exemple #2
0
        public async Task <Event> CreateEvent(
            Account account,
            AccountSet arbiterAccountSet,
            AccountSet participantsAccountSet,
            EventCondition eventCondition,
            EventRelationType eventRelationType,
            EventBetCondition eventBetCondition,
            string title,
            DateTime startDate,
            DateTime endDate)
        {
            using (this._scopeableFactory.Create())
            {
                var @event = new Event
                {
                    AccountId                = account.Id,
                    Title                    = title,
                    StartDate                = startDate == default(DateTime) ? DateTime.Now : startDate,
                    EndDate                  = endDate,
                    EventRelationTypeId      = eventRelationType.Id,
                    ArbiterAccountSetId      = arbiterAccountSet.GetIdentifier(),
                    ParticipantsAccountSetId = participantsAccountSet.GetIdentifier(),
                    ExpectedEventConditionId = eventCondition.Id,
                    EventBetConditionId      = eventBetCondition.Id
                };

                await this._repositoryEvent.Add(@event);

                return(@event);
            }
        }