private void RaiseRejectRequest()
        {
            InnerItem.AccountState = (int)AccountState.Rejected;

            ApproveCommand.RaiseCanExecuteChanged();
            RejectCommand.RaiseCanExecuteChanged();
        }
Example #2
0
        private CreditRequestViewModel GetRequest(ApproveCommand command)
        {
            var getRequestQuery = new ModelQuery()
            {
                Id = command.CreditRequestId
            };

            return(_creditRequestService.GetModel(getRequestQuery).Value);
        }
Example #3
0
        private async Task <CommandResult> UpdateCreditRequestAsync(ApproveCommand command, CreditRequestDto request)
        {
            var updateRes = await _creditRequestService.UpdateModelAsync(request);

            if (updateRes.IsFailed)
            {
                return(new CommandResult(command, false).From(updateRes));
            }
            var signRes = await SignApproveAsync(command, request);

            if (signRes.IsFailed)
            {
                //Well this is not good
            }
            return(new CommandResult(command, true));
        }
Example #4
0
        private CommandResult UpdateCreditRequest(ApproveCommand command, CreditRequestDto request)
        {
            var updateRes = _creditRequestService.UpdateModel(request);

            if (updateRes.IsFailed)
            {
                return(new CommandResult(command, false).From(updateRes));
            }
            var signRes = SignApprove(command, request);

            if (signRes.IsFailed)
            {
                //Well this is not good
            }
            return(new CommandResult(command, true));
        }
Example #5
0
        private string GetApproveSignature(RequestActionDto action, ApproveCommand command)
        {
            var data = new
            {
                action.Timestamp,
                action.ActionType,
                command.Approved,
                command.Comments,
                EmployeeId      = action.Employee.Id,
                CreditRequestId = action.CreditRequest.Id,
                Duration        = action.CreditRequest.MonthDuration,
                Sum             = action.CreditRequest.CreditSum.Value,
                SumCurrencyId   = action.CreditRequest.CreditSum.Currency.Id,
                CreditTypeId    = action.CreditRequest.CreditType.Id
            };
            var json = JsonConvert.SerializeObject(data);

            return(_signatureService.Sign(json, action.Employee.User.Key).Value);
        }
Example #6
0
        private async Task <CommandResult> SignApproveAsync(ApproveCommand command, CreditRequestDto request)
        {
            var employeeRes = await GetEmployeeAsync(command.EmployeeId);

            if (employeeRes.IsFailed)
            {
                return(new CommandResult(command, false).From(employeeRes));
            }
            if (employeeRes.Value == null || request == null)
            {
                return(new CommandResult(command, false).Error("Invalid command"));
            }
            var action = new RequestActionDto
            {
                Timestamp     = DateTime.Now,
                Employee      = employeeRes.Value,
                CreditRequest = request,
                ActionType    = GetActionType(command.GetType().Name)
            };

            action.Signature = GetApproveSignature(action, command);
            return(await _requestActionService.CreateModelAsync(action));
        }