public void AccountCreateAccountRequestToJson() { CreateAccountRequest request = new CreateAccountRequest(Zencoder.BaseUrl) { AffiliateCode = "asdf1234", Email = "*****@*****.**", Newsletter = true, Password = "******", TermsOfService = true }; Assert.AreEqual( @"{""affiliate_code"":""asdf1234"",""email"":""*****@*****.**"",""newsletter"":""1"",""password"":""1234"",""terms_of_service"":""1""}", request.ToJson()); }
public HttpResponseMessage CreateAccount([FromUri] CreateAccountRequest request) { logInfo.Info(string.Format("创建账号接口请求串:{0}", request.ToJson())); var viewModel = new SmsAccountViewModel(); if (!ModelState.IsValid) { viewModel.BusinessStatus = -10000; string msg = ModelState.Values.Where(item => item.Errors.Count == 1).Aggregate(string.Empty, (current, item) => current + (item.Errors[0].ErrorMessage + "; ")); viewModel.StatusMessage = "输入参数错误," + msg; return(viewModel.ResponseToJson()); } var response = _smsService.CreateAccount(request, Request.GetQueryNameValuePairs()); logInfo.Info("创建账号接口返回值" + response.ToJson()); if (response.ErrCode == -2) { viewModel.BusinessStatus = -10003; viewModel.StatusMessage = response.ErrMsg;//账号已存在 return(viewModel.ResponseToJson()); } if (response.Status == HttpStatusCode.BadRequest || response.Status == HttpStatusCode.Forbidden) { viewModel.BusinessStatus = -10001; viewModel.StatusMessage = "参数校验错误,请检查您的校验码"; return(viewModel.ResponseToJson()); } if (response.Status == HttpStatusCode.ExpectationFailed) { viewModel.BusinessStatus = -10002; viewModel.StatusMessage = response.ErrMsg; return(viewModel.ResponseToJson()); } if (response.Status == HttpStatusCode.OK) { viewModel.BusinessStatus = 1; viewModel.SmsAccount = response.SmsAccount.ConverToViewModel(); } else { viewModel.BusinessStatus = -10002; viewModel.StatusMessage = response.ErrMsg; } return(viewModel.ResponseToJson()); }
public async Task <IActionResult> Create([FromBody][NotNull] CreateAccountRequest request) { try { var account = await Convert( _accountManagementService.CreateAsync( request.ClientId.RequiredNotNullOrWhiteSpace(nameof(request.ClientId)), request.AccountId.RequiredNotNullOrWhiteSpace(nameof(request.AccountId)), request.TradingConditionId, request.BaseAssetId.RequiredNotNullOrWhiteSpace(nameof(request.BaseAssetId)), request.AccountName, request.UserId)); return(StatusCode((int)HttpStatusCode.Created, account)); } catch (NotSupportedException e) { _logger.WriteError("Account creation", request.ToJson(), e); return(Conflict()); } }
public void AccountCreateAccountRequestToJson() { CreateAccountRequest request = new CreateAccountRequest(Zencoder.BaseUrl) { AffiliateCode = "asdf1234", Email = "*****@*****.**", Newsletter = true, Password = "******", TermsOfService = true }; Assert.AreEqual( @"{""affiliate_code"":""asdf1234"",""email"":""*****@*****.**"",""newsletter"":""1"",""password"":""1234"",""terms_of_service"":""1""}", request.ToJson()); }