Example #1
0
        public async Task CreateAsync(Guid settlementId, Guid userId, string name, string description = null, int settleType = 0)
        {
            var settlement = await _settlementRepository.GetAsync(settlementId);

            if (settlement != null)
            {
                throw new Exception($"Settlement with id: '{settlementId}' already exist.");
            }
            settlement = new Settlement(settlementId, userId, name, description, settleType);
            await _settlementRepository.AddAsync(settlement);

            var user = await _userRepository.GetAsync(userId);

            user.AddSettlement(settlementId);
            manager.Settle(settlement);
        }