Exemple #1
0
        public async Task <ActionResult> Register(AccountModel.RegisterModel registerModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(registerModel));
            }
            UserApi userApi = new UserApi();

            //hash password
            AccountModel.RegisterModel sd = new AccountModel.RegisterModel();
            ViewBag.hasPassword = sd.setPassword(registerModel.PassWord);
            ViewBag.verify      = sd.verify(registerModel.PassWord, ViewBag.hasPassword);

            //model for user
            registerModel = new AccountModel.RegisterModel()
            {
                UserName = registerModel.UserName,
                PassWord = sd.setPassword(registerModel.PassWord).TrimEnd(),
            };

            //getting api result
            var res = userApi.Insert(registerModel);

            ViewBag.result = res;
            return(View());
        }
Exemple #2
0
        public string Insert(AccountModel.RegisterModel accountModel)
        {
            Uri    uri       = new Uri(string.Format(apilist.appDict["insert"]));
            string jsonData  = JsonConvert.SerializeObject(accountModel);
            string remBraket = jsonData.Replace('[', ' ');

            using (var client = new WebClient())
            {
                client.Headers.Add("content-type", "application/json");
                return(Encoding.ASCII.GetString(client.UploadData(uri, "POST", Encoding.UTF8.GetBytes(remBraket.Replace(']', ' ')))));
            }
        }