public CloseAccountCommandHandler(
     IRepository <ClearanceRoot> clearanceRepository,
     IClearanceDtoRepository clearanceDtoRepository,
     IMediator mediator,
     IAccountDtoService accountDtoService)
     : base(clearanceRepository, mediator)
 {
     this.accountDtoRepository   = accountDtoService;
     this.clearanceDtoRepository = clearanceDtoRepository;
 }
 public OpenClearanceCommandHandler(
     IRepository <ClearanceRoot> clearanceRepository,
     IMediator mediator,
     IUserSettingsService userSettingsService,
     IClearanceDtoRepository clearanceDtoRepository)
     : base(clearanceRepository, mediator)
 {
     this.userSettingsService    = userSettingsService;
     this.clearanceDtoRepository = clearanceDtoRepository;
 }
Exemple #3
0
        }                                                                        //only for 2 persons, normally this should be a list

        public async static Task <ClearanceRoot> Open(
            ClearanceId clearanceId,
            UserId userId,
            AccountId accountId,
            Period period,
            IUserSettingsService userSettingsService,
            IClearanceDtoRepository clearanceDtoRepository)
        {
            //Does this accountId already have a clearance?
            var clearanceIdAccountAlreadyExist = await clearanceDtoRepository.GetClearanceIdByAccountId(accountId.Value);

            if (clearanceIdAccountAlreadyExist != null)
            {
                throw new InvalidOperationException("Only one clearance can be created per account");
            }

            //Check if for the user is already a clearance on this period
            var clearanceDto = await clearanceDtoRepository.GetClearanceIdForUserOnPeriod(userId.Value, period.StartDate, period.EndDate);

            if (clearanceDto != null)
            {
                throw new InvalidOperationException("A clearance for this group already created. Try adding user accountId to existing clearance.");
            }

            //Get all the users of the group where the user is belonging to, remove this user
            var users = (await userSettingsService.GetUserGroupByUserId(userId)).Except(new List <Guid> {
                userId
            });

            //Build the dictionary for each user an account
            var userAccounts = new Dictionary <Guid, Guid?>();

            userAccounts.Add(userId.Value, accountId);

            foreach (var user in users)
            {
                userAccounts.Add(user, null);
            }

            var clearance = new ClearanceRoot();

            clearance.Apply(new V1.ClearanceCreated(clearanceId.Value, userAccounts, period.StartDate, period.EndDate));

            return(clearance);
        }
 public ClearanceFinalizedNotification(IClearanceDtoRepository clearanceDtoRepository)
 {
     this.clearanceDtoRepository = clearanceDtoRepository;
 }
 public AccountClosedNotification(IClearanceDtoRepository clearanceDtoRepository)
 {
     this.clearanceDtoRepository = clearanceDtoRepository;
 }
 public ClearanceCreatedNotification(IClearanceDtoRepository clearanceDtoRepository)
 {
     this.clearanceDtoRepository = clearanceDtoRepository;
 }