public async Task <Unit> Handle(FreezeAccount command, CancellationToken token = default) { await _repository.UpdateAsync( new AccountId(command.AccountId), account => account.Freeze(), token); return(Unit.Value); }
public static Validation <FrozeAccount> Freeze (this AccountState @this, FreezeAccount cmd) { if (@this.Status == AccountStatus.Frozen) { return(Errors.AccountNotActive); } return(cmd.ToEvent()); }
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()); }
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); }
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()); } }
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); }