Beispiel #1
0
    void CreateUser()
    {
        RequestCreateUser param = new RequestCreateUser();

        param.user_name = inputName.text;
        ApiClient.Instance.RequestCreateUser(param);
    }
Beispiel #2
0
        public async Task <User> CreateUser(RequestCreateUser user)
        {
            var existingUser = await userRepository.GetUser(user.Email);

            if (existingUser == null)
            {
                try
                {
                    var createdUser = new User
                    {
                        Email     = user.Email,
                        Password  = user.Password,
                        FirstName = user.FirstName,
                        LastName  = user.LastName
                    };
                    await userRepository.CreateSync(createdUser);

                    return(createdUser);
                }
                catch (Exception ex)
                {
                    throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)
                    {
                        Content      = new StringContent("Error occurred on - CreateUser (UserController)"),
                        ReasonPhrase = ex.Message
                    });
                }
            }
            throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.BadRequest)
            {
                Content      = new StringContent("Existing user"),
                ReasonPhrase = "User with the same email address already exist."
            });
        }
Beispiel #3
0
 public ResponseCreateUser CreateUser(RequestCreateUser r)
 {
     try
     {
         _roleRepository.CreateDefaultRoles();
         var isCreated = _userRepository.Create(r.UserId, r.email, r.password);
         if (isCreated)
         {
             var user = GetUser(new RequestGetUser()
             {
                 UserId = r.UserId
             });
             return(new ResponseCreateUser()
             {
                 message = $"User \"{r.UserId}\" been created succesfully",
                 status = ResponseStatus.Success,
                 User = user.User
             });
         }
         return(new ResponseCreateUser()
         {
             message = $"User \"{r.UserId}\" cannot be created due to unknown problem.",
             status = ResponseStatus.Error
         });
     }
     catch (Exception ex)
     {
         return(new ResponseCreateUser()
         {
             message = $"User \"{r.UserId}\" cannot be created.",
             exception = ex,
             status = ResponseStatus.Error
         });
     }
 }
Beispiel #4
0
        /// <summary>
        /// 新規ユーザーを作成のリクエスト処理
        /// </summary>
        /// <param name="param"></param>
        public void RequestCreateUser(RequestCreateUser param)
        {
            Dictionary <string, string> data = new Dictionary <string, string>();

            data.Add(NetWorkKey.REQUEST_STATUS, NetWorkKey.CREATE_USER);
            data.Add(NetWorkKey.USER_NAME, param.user_name);
            StartCoroutine(requester.RequestPost(ip, data));
        }
Beispiel #5
0
    public void CreateNewUser()
    {
        ApiClient.Instance.SetIpAddress(this.ip.text);
        PlayerSession.ip = this.ip.text;

        RequestCreateUser param = new RequestCreateUser();

        param.name     = name_field.text;
        param.password = password_field.text;

        ApiClient.Instance.ResponseCreateUser = ResponseCreateUser;
        ApiClient.Instance.RequestCreateUser(param);
    }
Beispiel #6
0
    // ----------------------------------------------------
    // 新規ユーザ登録
    // ----------------------------------------------------
    public void CreateNewUser()
    {
        // 通信先を指定
        ApiClient.Instance.SetIpAddress("http://" + server_field.text);

        // 各情報を格納
        var user = new RequestCreateUser();

        user.name     = username_field.text;
        user.password = passwd_field.text;

        // 登録
        ApiClient.Instance.ResponseCreateUser = ResponseCreateUser;
        ApiClient.Instance.RequestCreateUser(user);
    }
Beispiel #7
0
    // Use this for initialization
    void Start()
    {
//		PlayerPrefs.DeleteAll ();
        if (!PlayerPrefs.HasKey("id"))
        {
            RequestCreateUser param = new RequestCreateUser();
            param.user_name = "hoge";
            ApiClient.Instance.RequestCreateUser(param);
        }
        else
        {
            Debug.Log("a");
            Debug.Log(PlayerPrefs.GetString("id"));
            Debug.Log(PlayerPrefs.GetString("name"));
        }
    }
        /// <summary>
        ///     RequestCreateUser
        ///     /api/usersへPOSTでリクエストを行なう
        /// </summary>
        public void RequestCreateUser(RequestCreateUser param)
        {
            var url = ipAddr + "/api/users";

            requester.Post(url, param, ResponseCreateUser);
        }