private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            editInnerAccountViewModel info = new editInnerAccountViewModel();

            info.Name        = na.Text;
            info.Email       = em.Text;
            info.PhoneNumber = ph.Text;
            string token;

            using (StreamReader reader = new StreamReader(Environment.CurrentDirectory + @"\ForTokens.txt"))
            {
                token = reader.ReadLine();
            }
            HttpWebRequest httpWebRequest = WebRequest.CreateHttp("http://localhost:2202/api/UserAccount/EditAccount");

            httpWebRequest.Method      = "PUT";
            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Headers.Add(HttpRequestHeader.Authorization, $"Bearer {token}");
            using (StreamWriter Writer = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                Writer.Write(JsonConvert.SerializeObject(info));
            }
            WebResponse response = httpWebRequest.GetResponse();

            MessageBox.Show("Successfuly changed");
        }
        public EditWindow2()
        {
            InitializeComponent();
            try
            {
                List <PostModel> list;
                string           token;
                using (StreamReader reader = new StreamReader(Environment.CurrentDirectory + @"\ForTokens.txt"))
                {
                    token = reader.ReadLine();
                }
                HttpWebRequest httpWebRequest = WebRequest.CreateHttp("http://localhost:2202/api/post/get");
                httpWebRequest.Method      = "GET";
                httpWebRequest.ContentType = "application/json";
                httpWebRequest.Headers.Add(HttpRequestHeader.Authorization, $"Bearer {token}");

                WebResponse response = httpWebRequest.GetResponse();
                using (StreamReader reader = new StreamReader(response.GetResponseStream()))
                {
                    string json = reader.ReadToEnd();
                    list = JsonConvert.DeserializeObject <List <PostModel> >(json);
                    foreach (var item in list)
                    {
                        item.File = "http://localhost:2202/api/content/ProductImages/" + item.File;
                    }
                }
                AllPosts.ItemsSource = list;
                //////////////////////////////////////////////
                HttpWebRequest httpWebRequest2 = WebRequest.CreateHttp("http://localhost:2202/api/UserAccount/OutputAccount");
                httpWebRequest2.Method      = "GET";
                httpWebRequest2.ContentType = "application/json";
                httpWebRequest2.Headers.Add(HttpRequestHeader.Authorization, $"Bearer {token}");

                WebResponse response2 = httpWebRequest2.GetResponse();

                using (StreamReader reader = new StreamReader(response2.GetResponseStream()))
                {
                    string json = reader.ReadToEnd();
                    editInnerAccountViewModel Me = JsonConvert.DeserializeObject <editInnerAccountViewModel>(json);
                    Me.Image      = "http://localhost:2202/api/content/ProductImages/" + Me.Image;
                    MainName.Text = Me.Name;
                    if (Me.Image != null)
                    {
                        Me.Image = "Assets / NoImage.png";
                    }
                    MainName.Text      = Me.Login;
                    MyIcon.DataContext = Me.Image;
                    em.Text            = Me.Email;
                    ph.Text            = Me.PhoneNumber;
                    na.Text            = Me.Name;
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
        }
        public async Task <IActionResult> EditLoginAccount([FromBody] editInnerAccountViewModel model)
        {
            UserAccount user = await _userManager.FindByNameAsync(this.User.Identity.Name);

            var userAccount = _context.Users.FirstOrDefault(t => (t.Id) == user.Id);

            if (model.Image != null)
            {
                try
                {
                    string nameOfImage = string.Empty;
                    if (model.Image != null)
                    {
                        string directory  = _env.ContentRootPath;
                        string path       = Path.Combine(directory, "Content", _configuration["ProductImages"]);
                        byte[] imageBytes = Convert.FromBase64String(model.Image);
                        using (MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length))
                        {
                            var image = Image.FromStream(ms);
                            nameOfImage = Path.GetRandomFileName() + ".jpg";
                            string pathToFile = Path.Combine(path, nameOfImage);
                            image.Save(pathToFile, ImageFormat.Jpeg);
                        }
                        user.Image       = nameOfImage;
                        user.Name        = model.Name;
                        user.Description = model.Description;
                        user.Email       = model.Email;
                        user.UserName    = model.Login;
                        user.PhoneNumber = model.PhoneNumber;
                        _context.SaveChanges();
                        return(Ok());
                    }
                }
                catch (Exception ex)
                {
                    return(BadRequest(ex.Message));
                }
            }

            if (userAccount != null)
            {
                userAccount.Name         = model.Name;
                userAccount.UserName     = model.Name;
                userAccount.PasswordHash = model.Name;
                userAccount.Image        = model.Image;
                userAccount.PhoneNumber  = model.PhoneNumber;
                userAccount.Email        = model.Email;

                _context.SaveChanges();
                return(Content("Completed"));
            }
            return(Content("Error"));
        }
        public async Task <IActionResult> GetAccount()
        {
            UserAccount user = await _userManager.FindByNameAsync(this.User.Identity.Name);

            editInnerAccountViewModel resault = new editInnerAccountViewModel();

            resault.Image       = user.Image;
            resault.Name        = user.UserName;
            resault.Email       = user.Email;
            resault.PhoneNumber = user.PhoneNumber;
            resault.Description = user.Description;
            string json = JsonConvert.SerializeObject(resault);

            return(Content(json, "application/json"));
        }