コード例 #1
0
        private async void BtnNext_OnClick(object sender, RoutedEventArgs e)
        {
            CreateParameters parameters = new CreateParameters();
            Posts            post       = new Posts();
            List <Tag>       listTags   = new List <Tag>();
            Tag tag = new Tag();

            post.title       = txtTitlePost.Text;
            post.content     = txtContent.Text;
            post.Traveler_id = CurrentUser.currentUser.id;

            string[] spit = txtTags.Text.Split(new[] { "," }, StringSplitOptions.None);
            for (int i = 0; i < spit.Length; i++)
            {
                tag.tag_name = spit[i].Trim();
                listTags.Add(tag);
            }

            parameters.Post = post;
            parameters.Tag  = listTags;

            var content = ApiHandle.AddPost(parameters);

            if (content.Result.IsSuccessStatusCode)
            {
                txtError.Foreground = new SolidColorBrush(Colors.Green);
                txtError.Text       = "Add Post Success!!!! Next Step";
                await Task.Delay(1000);

                var rootFrame = Window.Current.Content as Frame;
                rootFrame.Navigate(typeof(ImagePost));
            }
            else
            {
                txtError.Foreground = new SolidColorBrush(Colors.Red);
                txtError.Text       = "Add Post Failed!!!!";
            }
        }