private async void SendRequest(object sender, RoutedEventArgs e)
        {
            SendButton.IsEnabled = false;

            try
            {
                var post = new Post
                {
                    Title = TitleTextBox.Text,
                    ShortDescription = DescriptionTextBox.Text,
                    IsPublished = true,
                    LastUpdateDate = DateTime.Now,
                    Chapters =
                        new List<Chapter>
                        {
                            new Chapter()
                            {
                                Content = Chapter1DescriptionTextBox.Text,
                                Title = Chapter1DescriptionTextBox.Text,
                                OrderNumber = 1
                            },
                            new Chapter()
                            {
                                Content = Chapter2DescriptionTextBox.Text,
                                Title = Chapter2DescriptionTextBox.Text,
                                OrderNumber = 2
                            }
                        },
                    Tags = new List<Tag>(),
                    UserId = "d3e00cd2-a222-4c80-acfd-529126977683"
                };
                foreach (var tag in TagsTextBox.Text.Split(new char[] {',', ' '}))
                {
                    post.Tags.Add(new Tag() {Content = tag});
                }
                var response = await client.PostAsJsonAsync("api/postapi", post);
                response.EnsureSuccessStatusCode();
            }
            catch (HttpRequestException ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                this.Close();
            }
        }
 private int CountVotes(Post post)
 {
     return post.Votes.Sum(vote => vote.Value);
 }
 private bool CheckVote(Post post, String userId)
 {
     return post.UserId != userId && post.Votes.All(vote => vote.UserId != userId);
 }
 private void AddVote(Post post, String userId, int value)
 {
     post.Votes.Add(new Vote { UserId = userId, PostId = post.Id, Value = value });
     UnitOfWork.Save();
 }
 void IPostService.Create(Post post)
 {
     post.CreationDate = DateTime.Now;
     UnitOfWork.PostRepository.Create(post);
     UnitOfWork.Save();
 }
 int IPostService.CountVotes(Post post)
 {
     return post.Votes.Sum(vote => vote.Value);
 }
 void IPostService.Update(Post updPost)
 {
     var post = UnitOfWork.PostRepository.ReadById(updPost.Id);
     post.LastUpdateDate = DateTime.Now;
     post.Title = updPost.Title;
     post.ShortDescription = updPost.ShortDescription;
     post.IsPublished = true;
     for (int i = 0; i < updPost.Chapters.Count; i++)
     {
         var chapter = CheckChapterOnExistance(updPost.Chapters.ToList()[i]);
         if (!post.Chapters.Contains(chapter))
         {
             post.Chapters.Add(chapter);
         }
     }
     for (int i = 0; i < updPost.Tags.Count; i++)
     {
         if (!post.Tags.Contains(updPost.Tags.ToList()[i]))
         {
             post.Tags.Add(updPost.Tags.ToList()[i]);
         }
     }
     for (int i = 0; i < post.Tags.Count; i++)
     {
         if (!updPost.Tags.Contains(post.Tags.ToList()[i]))
         {
             post.Tags.Remove(post.Tags.ToList()[i]);
         }
     }
     UnitOfWork.PostRepository.Update(post);
     UnitOfWork.Save();
 }