示例#1
0
    protected void shrani_Click(object sender, EventArgs e)
    {
        try
        {
            naziv.Text    = naziv.Text.Trim();
            iso_code.Text = iso_code.Text.Trim();
            code.Text     = code.Text.Trim();

            if (string.IsNullOrWhiteSpace(naziv.Text))
            {
                throw new Exception("Polje Naziv ne sme biti prazno!");
            }
            if (string.IsNullOrWhiteSpace(iso_code.Text))
            {
                throw new Exception("Polje ISO koda ne sme biti prazno!");
            }
            if (string.IsNullOrWhiteSpace(code.Text))
            {
                throw new Exception("Polje Koda ne sme biti prazno!");
            }
            if (string.IsNullOrWhiteSpace(drzava.Text))
            {
                throw new Exception("Polje Država ne sme biti prazno!");
            }

            if (_id == 0)
            {
                var lData = new Posts.Post(0,
                                           Posts.Get_MaxID() + 1,
                                           Convert.ToInt32(drzava.SelectedValue),
                                           naziv.Text,
                                           iso_code.Text,
                                           code.Text,
                                           DateTime.Now,
                                           Master.Uporabnik.Id,
                                           0);

                Posts.Insert(lData);
                _id = lData.anPostID;
            }
            else
            {
                var lData = Posts.Get(0, _id)[0];
                lData.acTitle            = naziv.Text;
                lData.acCode             = code.Text;
                lData.acISOCode          = iso_code.Text;
                lData.anCountryID        = Convert.ToInt32(drzava.SelectedValue);
                lData.adModificationDate = DateTime.Now;
                lData.anUserMod          = Master.Uporabnik.Id;

                Posts.Update(lData);
            }

            Response.Redirect("Post.aspx?id=" + _id + "&msg=" + HttpUtility.UrlEncode("Podatki shranjeni"));
        }
        catch (Exception er)
        {
            Master.SetMessage(er.Message);
        }
    }
示例#2
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session.  The state will be null the first time a page is visited.</param>
        private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            post = await Posts.GetActivity(e.NavigationParameter as string);

            this.DefaultViewModel["Group"] = post;
            this.DefaultViewModel["Items"] = post.comments;
            // TODO: Assign a bindable group to this.DefaultViewModel["Group"]
            // TODO: Assign a collection of bindable items to this.DefaultViewModel["Items"]
        }
示例#3
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session.  The state will be null the first time a page is visited.</param>
        private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            // TODO: Create an appropriate data model for your problem domain to replace the sample data
            //var item = await SampleDataSource.GetItemAsync((string)e.NavigationParameter);
            string parameter = e.NavigationParameter as string;

            post = await Posts.GetActivity(parameter);

            this.DefaultViewModel["Item"] = post;
        }
示例#4
0
        private async void AppBarButton_Click(object sender, RoutedEventArgs e)
        {
            int result = await Comments.PostComment(commentTextBox.Text, post.postID, Other.info.userID);

            if (result == 0)
            {
                post = await Posts.GetActivity(post.postID);

                this.DefaultViewModel["Item"] = post;
            }
        }
示例#5
0
    private void StoreCaption()
    {
        Posts.Post postViewed = m_posts.GetPostFromID(m_postId);

        CommentResult newCommentResult = new CommentResult();

        newCommentResult.commentId  = m_postId;
        newCommentResult.text       = postViewed.caption;
        newCommentResult.edited     = postViewed.edited;
        newCommentResult.userId     = postViewed.userId;
        newCommentResult.userHandle = postViewed.userHandle;

        m_commentResults.Add(newCommentResult);
    }
示例#6
0
        private async void AppBarButton_Click_2(object sender, RoutedEventArgs e)
        {
            StackPanel panel = new StackPanel();
            TextBox    box   = new TextBox()
            {
                //Margin = new Thickness(0, 14, 0, -2)
                Text = post.content
            };
            TextBlock block = new TextBlock()
            {
                Text         = "Tap OK to continue.",
                TextWrapping = TextWrapping.Wrap
            };

            panel.Children.Add(block);
            panel.Children.Add(box);
            var dlg = new ContentDialog()
            {
                Title               = "Edit post",
                Content             = panel,
                PrimaryButtonText   = "ok",
                SecondaryButtonText = "cancel"
            };

            var dlgResult = await dlg.ShowAsync();

            if (dlgResult == ContentDialogResult.Primary)
            {
                int result = await PostManagement.EditActivity(post.postID, box.Text);

                if (result == 0)
                {
                    post = await Posts.GetActivity(post.postID);

                    this.DefaultViewModel["Item"] = post;
                }
            }
        }
示例#7
0
        private async void MenuFlyoutItem_Click(object sender, RoutedEventArgs e)
        {
            MenuFlyoutItem item = sender as MenuFlyoutItem;

            //int result;
            if (item != null)
            {
                Posts.Post.Comment comment = item.DataContext as Posts.Post.Comment;

                if (comment != null)
                {
                    /*
                     *                                             <MenuFlyoutItem Text="+1" Tag="+1"
                     *  DataContext="{Binding}" Click="MenuFlyoutItem_Click" />
                     *                      <MenuFlyoutItem Text="reply" Tag="reply"
                     *  DataContext="{Binding}" Click="MenuFlyoutItem_Click"/>
                     *                      <MenuFlyoutItem Text="edit" Tag="edit"
                     *  DataContext="{Binding}" Click="MenuFlyoutItem_Click" />
                     *                      <MenuFlyoutItem Text="remove" Tag="remove"
                     *  DataContext="{Binding}" Click="MenuFlyoutItem_Click"/>
                     */
                    if (item.Tag.ToString() == "+1")
                    {
                        int result = await Comments.PlusOne(comment.commentID, !comment.isPlusonedByViewer);

                        if (result == 0)
                        {
                            post = await Posts.GetActivity(post.postID);

                            this.DefaultViewModel["Item"] = post;
                            //to potem się recznie zrobi
                        }
                    }
                    else if (item.Tag.ToString() == "reply")
                    {
                        commentTextBox.Text += "@" + comment.userID;
                    }
                    else if (item.Tag.ToString() == "edit")
                    {
                        StackPanel panel = new StackPanel();
                        TextBox    box   = new TextBox()
                        {
                            //Margin = new Thickness(0, 14, 0, -2)
                            Text = comment.originalText
                        };
                        TextBlock block = new TextBlock()
                        {
                            Text = "Tap OK to continue."
                        };

                        panel.Children.Add(block);
                        panel.Children.Add(box);
                        var dlg = new ContentDialog()
                        {
                            Title               = "Edit comment",
                            Content             = panel,
                            PrimaryButtonText   = "ok",
                            SecondaryButtonText = "cancel"
                        };

                        var dlgResult = await dlg.ShowAsync();

                        if (dlgResult == ContentDialogResult.Primary)
                        {
                            int result = await Comments.EditComment(box.Text, comment.commentID, post.postID);

                            if (result == 0)
                            {
                                post = await Posts.GetActivity(post.postID);

                                this.DefaultViewModel["Item"] = post;
                            }
                        }
                    }
                    else if (item.Tag.ToString() == "remove")
                    {
                        var dialog = new MessageDialog("", "");
                        var dlg    = new ContentDialog()
                        {
                            Title               = "Warning",
                            Content             = "Do you really want to delete this comment?",
                            PrimaryButtonText   = "yes",
                            SecondaryButtonText = "no"
                        };
                        var dlgResult = await dlg.ShowAsync();

                        if (dlgResult == ContentDialogResult.Primary)
                        {
                            int result = await Comments.DeleteComment(comment.commentID);

                            if (result == 0)
                            {
                                //post = await Posts.GetActivity(post.postID); //
                                post.comments.Remove(comment);
                                this.DefaultViewModel["Item"] = post;
                            }
                        }
                    }
                    //else img.Stretch = Stretch.Uniform;
                }
            }
        }