private void RaiseRejectRequest() { InnerItem.AccountState = (int)AccountState.Rejected; ApproveCommand.RaiseCanExecuteChanged(); RejectCommand.RaiseCanExecuteChanged(); }
private CreditRequestViewModel GetRequest(ApproveCommand command) { var getRequestQuery = new ModelQuery() { Id = command.CreditRequestId }; return(_creditRequestService.GetModel(getRequestQuery).Value); }
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)); }
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)); }
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); }
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)); }