コード例 #1
0
        public JObject RegisterMobile()
        {
            try
            {
                var request = _httpContextProxy.GetRequestBody <MobileAuthRegisterRequest>();
                request.device_address = _httpContextProxy.GetHeader("device_address");
                request.app_version    = _httpContextProxy.GetHeader("app_version");
                request.x_auth_token   = _httpContextProxy.GetHeader("x_auth_token");

                var results = new Dictionary <string, string>();
                if (request.IsValidModel(out results))
                {
                    // TO DO : Send mobile validation OTP
                    MobileAuthRegisterResponse mobileAuthRegisterResponse = _ZNxtUserService.RegisterMobile(request);

                    if (mobileAuthRegisterResponse.code == CommonConst._1_SUCCESS)
                    {
                        if (_userNotifierService.SendMobileAuthRegistrationOTPAsync(mobileAuthRegisterResponse).GetAwaiter().GetResult() || MOBILE_AUTH_IGNORE_OTP_VALIDATION)
                        {
                            return(_responseBuilder.Success(null, mobileAuthRegisterResponse.ToJObject()));
                        }
                        else
                        {
                            return(_responseBuilder.ServerError("Error sending SMS OTP"));
                        }
                    }
                    else
                    {
                        return(_responseBuilder.CreateReponseWithError(mobileAuthRegisterResponse.code, mobileAuthRegisterResponse.errors));
                    }
                }
                else
                {
                    _logger.Debug("Model validation fail");
                    JObject errors = new JObject();
                    foreach (var error in results)
                    {
                        errors[error.Key] = error.Value;
                    }
                    return(_responseBuilder.BadRequest(errors));
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message, ex);
                return(_responseBuilder.ServerError());
            }
        }