Example #1
0
        public NoteActionResponse NoteAction(NoteActionRequest request, Guid userID)
        {
            AccountDto userAccount    = _baseService.GetAccountById(userID, true);
            Guid       accountToScann = userID;
            //if (userAccount.Role == "Admin")
            //    accountToScann = request.AccountId;

            AccountDto     account    = _baseService.GetAccountById(accountToScann, true);
            List <NoteDto> savedNotes = _baseService.FindUserNotes(userID);

            if (StaticConfiguration.GetAcrionByProfile(userAccount.Role) == null)
            {
                throw new Exception("Invalid Profile");
            }
            else
            {
                ApplicationAction actions = StaticConfiguration.GetAcrionByProfile(userAccount.Role).Find(x => x.Id == request.ActionId);
                if (actions == null)
                {
                    throw new Exception("Invalid Action");
                }
                Func <List <NoteDto>, NoteDto, AccountDto, NoteActionRequest, NoteActionResponse> func;
                if (!this.ActionIdToFunction.TryGetValue(request.ActionId, out func))
                {
                    throw new Exception("Δεν βρέθηκε ενέργεια για το Id: " + request.ActionId);
                }
                return(func(savedNotes, request.Note, account, request));
            }
        }
        public PasswordActionResponse PasswordAction(PasswordActionRequest request, Guid userID)
        {
            AccountDto userAccount    = _baseService.GetAccountById(userID, true);
            Guid       accountToScann = userID;

            if (userAccount.Role == "Admin")
            {
                accountToScann = request.AccountId;
            }

            AccountDto  account       = _baseService.GetAccountById(accountToScann, true);
            PasswordDto savedPassword = _baseService.GetPasswords(request, account).FirstOrDefault();

            if (StaticConfiguration.GetAcrionByProfile(userAccount.Role) == null)
            {
                throw new Exception("Invalid Profile");
            }
            else
            {
                ApplicationAction actions = StaticConfiguration.GetAcrionByProfile(userAccount.Role).Find(x => x.Id == request.ActionId);
                if (actions == null)
                {
                    throw new Exception("Invalid Action");
                }
                Func <PasswordDto, PasswordDto, AccountDto, PasswordActionRequest, PasswordActionResponse> func;
                if (!this.ActionIdToFunction.TryGetValue(request.ActionId, out func))
                {
                    throw new Exception("Δεν βρέθηκε ενέργεια για το Id: " + request.ActionId);
                }
                return(func(savedPassword, request.Password, account, request));
            }
        }
        public AccountActionResponse ExecuteAction(AccountActionRequest request, Guid userID)
        {
            AccountDto userAccount = _baseService.GetAccountById(userID, false);

            if (request.AccountId == null || request.AccountId == Guid.Empty)
            {
                request.AccountId = userID;
            }
            AccountDto savedAccount = _baseService.GetAccountById(request.AccountId, false);

            if (request.Account == null)
            {
                request.Account = savedAccount;
            }

            if (StaticConfiguration.GetAcrionByProfile(userAccount.Role) == null)
            {
                throw new Exception("Invalid Profile");
            }
            else
            {
                ApplicationAction actions = StaticConfiguration.GetAcrionByProfile(userAccount.Role).Find(x => x.Id == request.ActionId);
                if (actions == null)
                {
                    throw new Exception("Invalid Action");
                }
                Func <AccountDto, AccountDto, AccountActionRequest, string, AccountActionResponse> func;
                if (!this.ActionIdToFunction.TryGetValue(request.ActionId, out func))
                {
                    throw new Exception("Δεν βρέθηκε ενέργεια για το Id: " + request.ActionId);
                }

                return(func(savedAccount, request.Account, request, userAccount.Role));
            }
        }