コード例 #1
0
        public async Task <Unit> Handle(FreezeAccount command, CancellationToken token = default)
        {
            await _repository.UpdateAsync(
                new AccountId(command.AccountId),
                account => account.Freeze(),
                token);

            return(Unit.Value);
        }
コード例 #2
0
        public static Validation <FrozeAccount> Freeze
            (this AccountState @this, FreezeAccount cmd)
        {
            if (@this.Status == AccountStatus.Frozen)
            {
                return(Errors.AccountNotActive);
            }

            return(cmd.ToEvent());
        }
コード例 #3
0
        public async Task <IActionResult> Freeze(
            [FromHeader(Name = Headers.RequestId)] Guid requestId, Guid id, CancellationToken token)
        {
            RequestContext.RequestId     = requestId;
            RequestContext.CausationId   = requestId;
            RequestContext.CorrelationId = requestId;

            var command = new FreezeAccount(id);
            await _mediator.Send(command, token);

            return(Ok());
        }
コード例 #4
0
        public static Validation <(Event Event, AccountState NewState)> Freeze
            (this AccountState @this, FreezeAccount cmd)
        {
            if (@this.Status == AccountStatus.Frozen)
            {
                return(Errors.AccountNotActive);
            }

            var evt      = cmd.ToEvent();
            var newState = @this.Apply(evt);

            return(evt as Event, newState);
        }
コード例 #5
0
        public IHttpActionResult FreezeAccount([FromBody] FreezeAccount freezeAccount)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest("Invalid data."));
                }

                string freezeAccountReq = App.GetRedboxFreezeAccountPayload(freezeAccount);

                string freezeAccountRes = App.CallRedbox(freezeAccountReq);

                LogWorker logworker = new LogWorker("FreezeAccountController", "FreezeAccount", "Ok");

                return(Ok(freezeAccountRes));
            }
            catch (Exception ex)
            {
                LogWorker logworker = new LogWorker("FreezeAccountController", "FreezeAccount", ex.ToString());
                return(InternalServerError());
            }
        }
コード例 #6
0
ファイル: App.cs プロジェクト: solomond6/BotServices
        public static string GetRedboxFreezeAccountPayload(FreezeAccount freezeAccount)
        {
            string channel   = ConfigurationManager.AppSettings["channel"];
            string payload   = "";
            Random reqTranId = new Random();

            try
            {
                payload = "<soapenv:Envelope xmlns: soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns: soap =\"http://soap.request.manager.redbox.stanbic.com/\">" +
                          "<soapenv:Header/>" +
                          "<soapenv:Body>" +
                          "<soap:request>" +
                          "<channel>" + channel + "</channel>" +
                          "<type>FREEZE_ACCOUNT</type>" +
                          "<customerId>" + freezeAccount.CustomerId + "</customerId>" +
                          "<customerIdType>" + freezeAccount.CustomerIdType + "</customerIdType>" +
                          "<submissionTime>" + freezeAccount.SubmissionTime + "</submissionTime>" +
                          "<reqTranId>" + reqTranId.Next(100000, 999999) + "</reqTranId>" +
                          "<body>" +
                          "<![CDATA[" +
                          "<otherRequestDetails>" +
                          "<passId>" + freezeAccount.PassId + "</passId>" +
                          "<passIdType>" + freezeAccount.PassIdType + "</passIdType>" +
                          "<passCodeType>" + freezeAccount.PassCodeType + "</passCodeType>" +
                          "<passCode>" + freezeAccount.PassCode + "</passCode>" +
                          "</otherRequestDetails>" +
                          "]]>" +
                          "</body>" +
                          "</soap:request>" +
                          "</soapenv:Body>";
            }
            catch
            {
                throw;
            }
            return(payload);
        }