Exemplo n.º 1
0
        public static bool UpdateUserPassword(NewUserRegisterModel changeUserpasswordRequest)
        {
            bool   returnresponse = false;
            string NewuserAddUri  = System.Configuration.ConfigurationManager.AppSettings["rooturi"] + "api/account/UpdatePassword";
            string token          = System.Web.HttpContext.Current.Session["BearerToken"].ToString();

            try
            {
                using (var client = new HttpClient())
                {
                    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
                    var resp = client.PostAsJsonAsync(NewuserAddUri, changeUserpasswordRequest);
                    resp.Wait(TimeSpan.FromSeconds(10));
                    if (resp.IsCompleted)
                    {
                        if (resp.Result.StatusCode == HttpStatusCode.Unauthorized)
                        {
                            Console.WriteLine("Authorization failed. Token expired or invalid.");
                        }
                        else
                        {
                            var response = resp.Result.Content.ReadAsStringAsync().Result;
                            returnresponse = JsonConvert.DeserializeObject <bool>(response);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                returnresponse = false;
            }
            return(returnresponse);
        }
        public ActionResult UpdateUserPassword()
        {
            var newUserAddRequest = new NewUserRegisterModel();

            return(View(newUserAddRequest));
        }
        public ActionResult CreateNewUser()
        {
            var newUserAddRequest = new NewUserRegisterModel();

            return(View(newUserAddRequest));
        }