Пример #1
0
        public override void GenerateCode(GeneratedMethod method, ISourceWriter writer)
        {
            if (CommentText.IsNotEmpty())
            {
                writer.WriteComment(CommentText);
            }

            var invokeMethod = InvocationCode(method);

            if (shouldWriteInUsingBlock(method))
            {
                writer.UsingBlock($"{returnActionCode(method)}{invokeMethod}", w => Next?.GenerateCode(method, writer));
            }
            else
            {
                writer.Write($"{returnActionCode(method)}{invokeMethod};");

                // This is just to make the generated code a little
                // easier to read
                if (CommentText.IsNotEmpty())
                {
                    writer.BlankLine();
                }

                Next?.GenerateCode(method, writer);
            }
        }
Пример #2
0
        public async Task Should_Load_All_Details_For_A_Post()
        {
            PostModel result;
            var       author  = new User((Nickname)"author7", (FullName)"author seven", Password.Create("password").Value, (Email)"*****@*****.**", "my bio");
            var       reader  = new User((Nickname)"reader1", (FullName)"reader one", Password.Create("password").Value, (Email)"*****@*****.**", "my bio");
            var       post    = new Post(author, (Picture)Convert.FromBase64String(DatabaseFixture.GetTestPictureBase64()), (PostText)"test post");
            var       comment = new Comment(post, reader, CommentText.Create("My comment").Value);

            using (var session = _testFixture.OpenSession(_output))
            {
                post.AddComment(comment);
                post.PutLikeBy(reader);
                await session.SaveAsync(reader);

                await session.SaveAsync(author);

                await session.SaveAsync(post);
            }

            var query = new PostDetailQuery(post.ID, reader.ID);

            using (var session = _testFixture.OpenSession(_output))
            {
                var sut = new PostDetailQueryHandler(session, Log.Logger);
                result = await sut.Handle(query, default);
            }

            using (new AssertionScope())
            {
                result.Should().NotBeNull();
                result.LikesCount.Should().Be(1);
                result.Comments.Length.Should().Be(1);
                result.IsLikedByCurrentUser.Should().BeTrue();
            }
        }
Пример #3
0
        public void Should_Convert_Comment_Text_To_String()
        {
            var    text = "this is my text";
            string sut  = CommentText.Create(text).Value;

            sut.Should().Be(text);
        }
Пример #4
0
        /// <summary>
        /// Form a DocumentFormat.OpenXml.Spreadsheet.CommentText class from this SLRstType class.
        /// </summary>
        /// <returns>A DocumentFormat.OpenXml.Spreadsheet.CommentText class.</returns>
        public CommentText ToCommentText()
        {
            CommentText ct = new CommentText();

            ct.InnerXml = SLTool.RemoveNamespaceDeclaration(this.istrReal.InnerXml);
            return(ct);
        }
Пример #5
0
        public async Task Should_Find_One_Comment_For_Post()
        {
            CommentModel[] comments;
            var            author  = new User((Nickname)"author7", (FullName)"author seven", Password.Create("password").Value, (Email)"*****@*****.**", "my bio");
            var            post    = new Post(author, (Picture)Convert.FromBase64String(DatabaseFixture.GetTestPictureBase64()), (PostText)"test post");
            var            comment = new Comment(post, author, CommentText.Create("First comment").Value);

            using (var session = _testFixture.OpenSession(_output))
            {
                post.AddComment(comment);
                await session.SaveAsync(author);

                await session.SaveAsync(post);
            }

            var query = new PostCommentsQuery(post.ID);

            using (var session = _testFixture.OpenSession(_output))
            {
                var sut = new PostCommentsQueryHandler(session, Log.Logger);
                comments = await sut.Handle(query, default);
            }

            comments.Length.Should().Be(1);
        }
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Id;
         hashCode = (hashCode * 397) ^ (CommentText != null ? CommentText.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Date.GetHashCode();
         return(hashCode);
     }
 }
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Id != null ? Id.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ThreadId != null ? ThreadId.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (CommentText != null ? CommentText.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Sender != null ? Sender.GetHashCode() : 0);
         return(hashCode);
     }
 }
Пример #8
0
        public void Same_String_Should_Create_The_Same_Comment_Text()
        {
            var text1 = CommentText.Create("this is my text").Value;
            var text2 = CommentText.Create("this is my text").Value;

            using (new AssertionScope())
            {
                text1.Should().Be(text2);
                text1.GetHashCode().Equals(text2.GetHashCode()).Should().BeTrue();
            }
        }
Пример #9
0
        public void Different_Strings_Should_Create_Different_Comment_Texts()
        {
            var text1 = CommentText.Create("this is my text").Value;
            var text2 = CommentText.Create("this is my other text").Value;

            using (new AssertionScope())
            {
                text1.Should().NotBe(text2);
                text1.GetHashCode().Equals(text2.GetHashCode()).Should().BeFalse();
            }
        }
Пример #10
0
        public override void GenerateCode(GeneratedMethod method, ISourceWriter writer)
        {
            if (CommentText.IsNotEmpty())
            {
                writer.WriteComment(CommentText);
            }

            var invokeMethod = invocationCode();

            var returnValue = "";

            if (IsAsync)
            {
                #if NET461 || NET48
                if (method.AsyncMode == AsyncMode.AsyncTask)
                {
                    invokeMethod = invokeMethod + ".ConfigureAwait(false)";
                }
#endif
                returnValue = method.AsyncMode == AsyncMode.ReturnFromLastNode ? "return " : "await ";
            }

            var isDisposable = false;
            if (shouldAssignVariableToReturnValue(method))
            {
#if !NET4x
                returnValue = ReturnVariable.VariableType.IsValueTuple() ? $"{ReturnVariable.Usage} = {returnValue}" : $"{ReturnVariable.AssignmentUsage} = {returnValue}";
                #else
                returnValue = $"{ReturnVariable.AssignmentUsage} = {returnValue}";
#endif


                isDisposable = ReturnVariable.VariableType.CanBeCastTo <IDisposable>();
            }

            if (isDisposable && DisposalMode == DisposalMode.UsingBlock)
            {
                writer.UsingBlock($"{returnValue}{invokeMethod}", w => Next?.GenerateCode(method, writer));
            }
            else
            {
                writer.Write($"{returnValue}{invokeMethod};");

                // This is just to make the generated code a little
                // easier to read
                if (CommentText.IsNotEmpty())
                {
                    writer.BlankLine();
                }

                Next?.GenerateCode(method, writer);
            }
        }
Пример #11
0
    public static void AddCommentToChat(string nome, string comentario)
    {
        GameObject  cmt = (GameObject)Instantiate(commentPrefab, content.transform);
        CommentText txt = cmt.GetComponent <CommentText> ();

        txt.userName = nome;
        txt.textBody = comentario;

        commentList.Add(cmt);

        atualiza = 2;
    }
Пример #12
0
        private void UserControl_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                e.Handled = true;

                if (e.ClickCount > 1)
                {
                    Holder.Visibility = Visibility.Collapsed;

                    CommentText.SelectAll();
                    Keyboard.Focus(CommentText);
                }
                else
                {
                    Focus();
                    Keyboard.Focus(this);

                    //cache contained nodes
                    //except other comment nodes
                    //if we don't filter out other comment nodes
                    //it then will create a stack overflow
                    //if two or more comment nodes are on top of each other
                    //and you try to move one of them
                    //ignore nodes that may already be selected as part of multiselect
                    contained = Graph.GraphNodes.FindAll(m => !(m is UICommentNode) && m.IsInRect(this.Bounds) && !Graph.SelectedIds.Contains(m.Id));

                    if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                    {
                        Graph.ToggleMultiSelect(this);
                        return;
                    }

                    mouseDown = true;

                    start = e.GetPosition(Graph);

                    bool selected = Graph.SelectedNodes.Contains(this);

                    if (selected && Graph.SelectedNodes.Count > 1)
                    {
                        return;
                    }
                    else if (selected && Graph.SelectedNodes.Count == 1)
                    {
                        return;
                    }

                    Graph.ClearMultiSelect();
                    Graph.ToggleMultiSelect(this);
                }
            }
        }
Пример #13
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Id;
         hashCode = (hashCode * 397) ^ GymId;
         hashCode = (hashCode * 397) ^ (UserId != null ? UserId.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (CommentText != null ? CommentText.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Rate;
         hashCode = (hashCode * 397) ^ PublicationDate.GetHashCode();
         return(hashCode);
     }
 }
Пример #14
0
        public CommentBoad()
        {
            this.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(50, GridUnitType.Pixel)
            });
            this.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(1, GridUnitType.Star)
            });
            this.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(50, GridUnitType.Pixel)
            });

            // Game Info
            Players     = "Player 1 (Black) vs Player 2 (White)";
            PlayersText = new TextBlock()
            {
                Text                = Players,
                FontSize            = 20,
                HorizontalAlignment = System.Windows.HorizontalAlignment.Center,
                Margin              = new Thickness(10, 5, 5, 10),
            };
            this.Children.Add(PlayersText);

            docContainer = new FlowDocumentScrollViewer()
            {
                VerticalScrollBarVisibility   = ScrollBarVisibility.Auto,
                HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden,
            };

            Text = new CommentText();
            docContainer.Document = Text;

            this.Children.Add(docContainer);

            CloseButton = new Button()
            {
                Content    = "Hide", HorizontalAlignment = System.Windows.HorizontalAlignment.Right,
                Width      = 100, Height = 25, Margin = new Thickness(5, 5, 5, 5),
                Visibility = System.Windows.Visibility.Collapsed
            };
            CloseButton.Click += CloseButton_Click;
            this.Children.Add(CloseButton);

            //
            Grid.SetRow(PlayersText, 0);
            Grid.SetRow(docContainer, 1);
            Grid.SetRow(CloseButton, 2);
        }
Пример #15
0
 private void ReplyButtonClick(object sender, RoutedEventArgs e)
 {
     try
     {
         if (sender is HyperlinkButton btn && btn != null)
         {
             if (btn.DataContext is RecentActivityFeed data && data != null)
             {
                 ActivitiesVM.CommentFeed = data;
                 ShowComments();
                 CommentText.PlaceholderText = $"Reply to @{data.ProfileName ?? string.Empty}'s comment";
                 CommentText.Text            = $"@{data.ProfileName ?? string.Empty} ";
                 CommentText.Focus(FocusState.Keyboard);
             }
         }
     }
     catch { }
 }
Пример #16
0
        private async void CommentButtonClick(object sender, RoutedEventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(CommentText.Text))
                {
                    CommentText.Focus(FocusState.Keyboard);
                    return;
                }
                var feed = ActivitiesVM.CommentFeed;
                if (feed == null)
                {
                    HideComments();
                    return;
                }

                var result = await Helper.InstaApi.CommentProcessor.ReplyCommentMediaAsync(feed.Medias[0].Id, feed.CommentId.ToString(), CommentText.Text);

                HideComments();
                ActivitiesVM.CommentFeed = null;
                if (result.Succeeded)
                {
                    Helper.ShowNotify("Comment sent successfully.");
                    CommentText.Text = "";
                }
                else
                {
                    switch (result.Info.ResponseType)
                    {
                    case ResponseType.RequestsLimit:
                    case ResponseType.SentryBlock:
                        Helper.ShowNotify(result.Info.Message);
                        break;

                    case ResponseType.ActionBlocked:
                        Helper.ShowNotify("Action blocked.\r\nPlease try again 5 or 10 minutes later");
                        break;
                    }
                }
            }
            catch { }
        }
Пример #17
0
        public override void GenerateCode(GeneratedMethod method, ISourceWriter writer)
        {
            if (CommentText.IsNotEmpty())
            {
                writer.WriteComment(CommentText);
            }

            var invokeMethod = invocationCode();

            var returnValue = "";

            if (IsAsync)
            {
                returnValue = method.AsyncMode == AsyncMode.ReturnFromLastNode ? "return " : "await ";
            }

            var isDisposable = false;

            if (shouldAssignVariableToReturnValue(method))
            {
#if !NET4x
                returnValue = ReturnVariable.VariableType.IsValueTuple() ? $"{ReturnVariable.Usage} = {returnValue}" : $"var {ReturnVariable.Usage} = {returnValue}";
                #else
                returnValue = $"var {ReturnVariable.Usage} = {returnValue}";
#endif


                isDisposable = ReturnVariable.VariableType.CanBeCastTo <IDisposable>();
            }

            if (isDisposable && DisposalMode == DisposalMode.UsingBlock)
            {
                writer.UsingBlock($"{returnValue}{invokeMethod}", w => Next?.GenerateCode(method, writer));
            }
            else
            {
                writer.Write($"{returnValue}{invokeMethod};");

                Next?.GenerateCode(method, writer);
            }
        }
        public async void CommentButtonClicked(object sender, UIButtonEventArgs e)
        {
            UIAlertView parent_alert = (UIAlertView)sender;

            if (e.ButtonIndex == 1)
            {
                CommentText.SetTitle(parent_alert.GetTextField(0).Text, UIControlState.Normal);
                timeLogEntry.Comment = parent_alert.GetTextField(0).Text;

                if (!isAddingMode)
                {
                    try
                    {
                        await PDashAPI.Controller.UpdateTimeLog(timeLogEntry.Id.ToString(), timeLogEntry.Comment, null, timeLogEntry.Task.Id, null, null, false);
                    }
                    catch (Exception ex)
                    {
                        ViewControllerHelper.ShowAlert(this, "Change Comment", ex.Message + " Please try again later.");
                    }
                }
            }
        }
Пример #19
0
        public ArticlesCommentAdapterViewHolder(View itemView, string themeColor) : base(itemView)
        {
            try
            {
                MainView = itemView;

                BubbleLayout = MainView.FindViewById <LinearLayout>(Resource.Id.bubble_layout);
                Image        = MainView.FindViewById <CircleImageView>(Resource.Id.card_pro_pic);
                CommentText  = MainView.FindViewById <SuperTextView>(Resource.Id.active);
                CommentText?.SetTextInfo(CommentText);
                UserName      = MainView.FindViewById <TextView>(Resource.Id.username);
                TimeTextView  = MainView.FindViewById <TextView>(Resource.Id.time);
                ReplyTextView = MainView.FindViewById <TextView>(Resource.Id.reply);
                LikeTextView  = MainView.FindViewById <TextView>(Resource.Id.Like);

                var font = Typeface.CreateFromAsset(MainView.Context.Resources?.Assets, "ionicons.ttf");
                UserName.SetTypeface(font, TypefaceStyle.Normal);

                if (AppSettings.FlowDirectionRightToLeft)
                {
                    BubbleLayout.SetBackgroundResource(Resource.Drawable.comment_rounded_right_layout);
                }

                if (themeColor != "Dark")
                {
                    return;
                }

                ReplyTextView.SetTextColor(Color.White);
                LikeTextView.SetTextColor(Color.White);
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
Пример #20
0
        public CommentBoad()
        {
            this.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(50, GridUnitType.Pixel) });
            this.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) });
            this.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(50, GridUnitType.Pixel) });

            // Game Info
            Players = "Player 1 (Black) vs Player 2 (White)";
            PlayersText = new TextBlock()
            {
                Text = Players,
                FontSize = 20,
                HorizontalAlignment = System.Windows.HorizontalAlignment.Center,
                Margin = new Thickness(10, 5, 5, 10),
            };
            this.Children.Add(PlayersText);

            docContainer = new FlowDocumentScrollViewer()
            {
                VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
                HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden,

            };

            Text = new CommentText();
            docContainer.Document = Text;

            this.Children.Add(docContainer);

            CloseButton = new Button()
            {
                Content = "Hide", HorizontalAlignment = System.Windows.HorizontalAlignment.Right,
                Width=100, Height=25, Margin = new Thickness(5,5,5,5),
                Visibility = System.Windows.Visibility.Collapsed
            };
            CloseButton.Click += CloseButton_Click;
            this.Children.Add(CloseButton);

            //
            Grid.SetRow(PlayersText, 0);
            Grid.SetRow(docContainer, 1);
            Grid.SetRow(CloseButton, 2);
        }
Пример #21
0
        public void Comment_Text_From_String_Too_Long_Is_Not_Valid()
        {
            var sut = new string('x', 1000);

            CommentText.Create(sut).IsFailure.Should().BeTrue();
        }
Пример #22
0
 public void Empty_Comment_Text_Is_Not_Valid()
 {
     CommentText.Create(string.Empty).IsFailure.Should().BeTrue();
 }
Пример #23
0
 public void Should_Create_A_Valid_Text_For_A_Comment()
 {
     CommentText.Create("this is my text").IsSuccess.Should().BeTrue();
 }
Пример #24
0
 public void SetContent(CommentText content)
 {
     Content = content;
 }
        private static void GenerateWorksheetCommentsPartContent(WorksheetCommentsPart worksheetCommentsPart,
            XLWorksheet xlWorksheet)
        {
            var comments = new Comments();
            var commentList = new CommentList();
            var authorsDict = new Dictionary<String, Int32>();
            foreach (var c in xlWorksheet.Internals.CellsCollection.GetCells(c => c.HasComment))
            {
                var comment = new Comment {Reference = c.Address.ToStringRelative()};
                var authorName = c.Comment.Author;

                Int32 authorId;
                if (!authorsDict.TryGetValue(authorName, out authorId))
                {
                    authorId = authorsDict.Count;
                    authorsDict.Add(authorName, authorId);
                }
                comment.AuthorId = (UInt32)authorId;

                var commentText = new CommentText();
                foreach (var rt in c.Comment)
                {
                    commentText.Append(GetRun(rt));
                }

                comment.Append(commentText);
                commentList.Append(comment);
            }

            var authors = new Authors();
            foreach (var author in authorsDict.Select(a => new Author {Text = a.Key}))
            {
                authors.Append(author);
            }
            comments.Append(authors);
            comments.Append(commentList);

            worksheetCommentsPart.Comments = comments;
        }
        void ReleaseDesignerOutlets()
        {
            if (CommentLabel != null)
            {
                CommentLabel.Dispose();
                CommentLabel = null;
            }

            if (CommentText != null)
            {
                CommentText.Dispose();
                CommentText = null;
            }

            if (DeltaLabel != null)
            {
                DeltaLabel.Dispose();
                DeltaLabel = null;
            }

            if (DeltaText != null)
            {
                DeltaText.Dispose();
                DeltaText = null;
            }

            if (IntLabel != null)
            {
                IntLabel.Dispose();
                IntLabel = null;
            }

            if (IntText != null)
            {
                IntText.Dispose();
                IntText = null;
            }

            if (ProjectNameLabel != null)
            {
                ProjectNameLabel.Dispose();
                ProjectNameLabel = null;
            }

            if (StartTimeLabel != null)
            {
                StartTimeLabel.Dispose();
                StartTimeLabel = null;
            }

            if (StartTimeText != null)
            {
                StartTimeText.Dispose();
                StartTimeText = null;
            }

            if (TaskNameLabel != null)
            {
                TaskNameLabel.Dispose();
                TaskNameLabel = null;
            }
        }
Пример #27
0
 /// <summary>
 /// Form a DocumentFormat.OpenXml.Spreadsheet.CommentText class from this SLRstType class.
 /// </summary>
 /// <returns>A DocumentFormat.OpenXml.Spreadsheet.CommentText class.</returns>
 public CommentText ToCommentText()
 {
     CommentText ct = new CommentText();
     ct.InnerXml = SLTool.RemoveNamespaceDeclaration(this.istrReal.InnerXml);
     return ct;
 }
Пример #28
0
        partial void InitConstruction()
        {
            this.InitializeComponent();

            var param = CSParam as CommentConstructParam;

            this.Width  = param.Width;
            this.Height = param.Height;

            CommentText.SetBinding(TextBlock.TextProperty, new Binding("Comment")
            {
                Source = param
            });
            ContentGrid.SetBinding(Grid.BackgroundProperty, new Binding("BlendBrush")
            {
                Source = this
            });

            this.BlendBrush = new SolidColorBrush(Color.FromArgb(param.Color.A, param.Color.R, param.Color.G, param.Color.B));

            int deepestZIndex = -10;

            if (HostNodesContainer != null && !HostNodesContainer.IsLoading)
            {
                bool   has = false;
                double left = double.MaxValue, right = double.MinValue, top = double.MaxValue, bottom = double.MinValue;
                // 创建时包围所有选中的节点
                for (int i = 0; i < HostNodesContainer.CtrlNodeList.Count; i++)
                {
                    var node = HostNodesContainer.CtrlNodeList[i];
                    if (!node.Selected)
                    {
                        continue;
                    }
                    var loc     = node.GetLocation();
                    var nRight  = loc.X + node.GetWidth();
                    var nBottom = loc.Y + node.GetHeight();

                    var zIndex = Canvas.GetZIndex(node);
                    if (deepestZIndex > zIndex)
                    {
                        deepestZIndex = zIndex;
                    }

                    if (left > loc.X)
                    {
                        left = loc.X;
                    }
                    if (top > loc.Y)
                    {
                        top = loc.Y;
                    }
                    if (right < nRight)
                    {
                        right = nRight;
                    }
                    if (bottom < nBottom)
                    {
                        bottom = nBottom;
                    }

                    has = true;
                }

                if (has)
                {
                    mCreateX     = left - 50;
                    mCreateY     = top - 100;
                    this.Width   = right + 50 - mCreateX;
                    this.Height  = bottom + 50 - mCreateY;
                    param.Width  = this.Width;
                    param.Height = this.Height;
                }
            }
            Canvas.SetZIndex(this, deepestZIndex - 1);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            activityView                  = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.WhiteLarge);
            activityView.Frame            = View.Frame;
            activityView.BackgroundColor  = UIColor.FromRGBA(0, 0, 0, 0.6f);
            activityView.Center           = View.Center;
            activityView.HidesWhenStopped = true;
            View.AddSubview(activityView);

            tlc = TimeLoggingController.GetInstance();

            if (timeLogEntry == null)
            {
                throw new ArgumentException("timeLogEntry is null.");
            }

            if (isAddingMode)
            {
                barBtnItem = new UIBarButtonItem(UIBarButtonSystemItem.Save, async(s, e) =>
                {
                    activityView.StartAnimating();
                    try
                    {
                        await PDashAPI.Controller.AddATimeLog(timeLogEntry.Comment, timeLogEntry.StartDate, timeLogEntry.Task.Id, timeLogEntry.LoggedTime, timeLogEntry.InterruptTime, false);
                        activityView.StopAnimating();
                        NavigationController.PopViewController(true);
                    }
                    catch (Exception ex)
                    {
                        activityView.StopAnimating();
                        ViewControllerHelper.ShowAlert(this, "Add Time Log", ex.Message + " Please try again later.");
                    }
                });
            }
            else
            {
                barBtnItem = new UIBarButtonItem(UIBarButtonSystemItem.Trash, (s, e) =>
                {
                    UIAlertController actionSheetAlert = UIAlertController.Create(null, "This time log will be deleted", UIAlertControllerStyle.ActionSheet);

                    actionSheetAlert.AddAction(UIAlertAction.Create("Delete", UIAlertActionStyle.Destructive, async(action) =>
                    {
                        if (isActiveTimeLog())
                        {
                            ViewControllerHelper.ShowAlert(this, "Oops", "You are currently logging time to this time log. Please stop the timmer first.");
                        }
                        else
                        {
                            activityView.StartAnimating();
                            try
                            {
                                await PDashAPI.Controller.DeleteTimeLog(timeLogEntry.Id.ToString());
                                activityView.StopAnimating();
                                NavigationController.PopViewController(true);
                            }
                            catch (Exception ex)
                            {
                                activityView.StopAnimating();
                                ViewControllerHelper.ShowAlert(this, "Delete Time Log", ex.Message + " Please try again later.");
                            }
                        }
                    }));

                    actionSheetAlert.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, (action) => Console.WriteLine("Cancel button pressed.")));

                    UIPopoverPresentationController presentationPopover = actionSheetAlert.PopoverPresentationController;
                    if (presentationPopover != null)
                    {
                        presentationPopover.SourceView = this.View;
                        presentationPopover.PermittedArrowDirections = UIPopoverArrowDirection.Up;
                    }

                    // Display the alertg
                    this.PresentViewController(actionSheetAlert, true, null);
                });
            }

            NavigationItem.RightBarButtonItem = barBtnItem;

            ProjectNameLabel.Text = timeLogEntry.Task.Project.Name;
            TaskNameLabel.Text    = timeLogEntry.Task.FullName;
            StartTimeText.Text    = Util.GetInstance().GetLocalTime(timeLogEntry.StartDate).ToString("g");

            // set up start time customized UIpicker

            StartTimePicker = new UIDatePicker(new CoreGraphics.CGRect(10f, this.View.Frame.Height - 250, this.View.Frame.Width - 20, 200f));
            StartTimePicker.BackgroundColor = UIColor.FromRGB(220, 220, 220);

            StartTimePicker.UserInteractionEnabled = true;
            StartTimePicker.Mode        = UIDatePickerMode.DateAndTime;
            StartTimePicker.MaximumDate = ViewControllerHelper.DateTimeUtcToNSDate(DateTime.UtcNow);

            startTimeSelectedDate = Util.GetInstance().GetServerTime(timeLogEntry.StartDate);

            StartTimePicker.ValueChanged += (Object sender, EventArgs e) =>
            {
                startTimeSelectedDate = ViewControllerHelper.NSDateToDateTimeUtc((sender as UIDatePicker).Date);
            };

            StartTimePicker.BackgroundColor = UIColor.White;
            StartTimePicker.SetDate(ViewControllerHelper.DateTimeUtcToNSDate(Util.GetInstance().GetServerTime(timeLogEntry.StartDate)), true);

            //Setup the toolbar
            toolbar                 = new UIToolbar();
            toolbar.BarStyle        = UIBarStyle.Default;
            toolbar.BackgroundColor = UIColor.FromRGB(220, 220, 220);
            toolbar.Translucent     = true;
            toolbar.SizeToFit();

            // Create a 'done' button for the toolbar and add it to the toolbar

            saveButton = new UIBarButtonItem("Save", UIBarButtonItemStyle.Bordered, null);

            saveButton.Clicked += async(s, e) =>
            {
                this.StartTimeText.Text = Util.GetInstance().GetLocalTime(startTimeSelectedDate).ToString();
                timeLogEntry.StartDate  = startTimeSelectedDate;
                this.StartTimeText.ResignFirstResponder();

                if (!isAddingMode)
                {
                    try
                    {
                        await PDashAPI.Controller.UpdateTimeLog(timeLogEntry.Id.ToString(), null, timeLogEntry.StartDate, timeLogEntry.Task.Id, null, null, false);
                    }
                    catch (Exception ex)
                    {
                        ViewControllerHelper.ShowAlert(this, "Change Start Time", ex.Message + " Please try again later.");
                    }
                }
            };

            var spacer = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace)
            {
                Width = 50
            };

            cancelButton = new UIBarButtonItem("Cancel", UIBarButtonItemStyle.Bordered,
                                               (s, e) =>
            {
                this.StartTimeText.ResignFirstResponder();
            });

            toolbar.SetItems(new UIBarButtonItem[] { cancelButton, spacer, saveButton }, true);

            this.StartTimeText.InputView          = StartTimePicker;
            this.StartTimeText.InputAccessoryView = toolbar;

            DeltaText.Text = TimeSpan.FromMinutes(timeLogEntry.LoggedTime).ToString(@"hh\:mm");

            IntText.Text = TimeSpan.FromMinutes(timeLogEntry.InterruptTime).ToString(@"hh\:mm");

            CommentText.SetTitle(timeLogEntry.Comment ?? "No Comment", UIControlState.Normal);

            CommentText.TouchUpInside += (sender, e) =>
            {
                UIAlertView alert = new UIAlertView();
                alert.Title = "Comment";
                alert.AddButton("Cancel");
                alert.AddButton("Save");
                alert.Message        = "Please enter new Comment";
                alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput;
                UITextField textField = alert.GetTextField(0);
                textField.Placeholder = timeLogEntry.Comment ?? "No Comment";
                alert.Clicked        += CommentButtonClicked;
                alert.Show();
            };

            /////Delta Picker
            DeltaPicker = new UIPickerView(new CoreGraphics.CGRect(10f, this.View.Frame.Height - 250, this.View.Frame.Width - 20, 200f));
            DeltaPicker.BackgroundColor = UIColor.FromRGB(220, 220, 220);

            DeltaPicker.UserInteractionEnabled = true;
            DeltaPicker.ShowSelectionIndicator = true;

            string[] hours   = new string[24];
            string[] minutes = new string[60];

            for (int i = 0; i < hours.Length; i++)
            {
                hours[i] = i.ToString();
            }
            for (int i = 0; i < minutes.Length; i++)
            {
                minutes[i] = i.ToString("00");
            }

            StatusPickerViewModel deltaModel = new StatusPickerViewModel(hours, minutes);

            int h = (int)timeLogEntry.LoggedTime / 60;
            int m = (int)timeLogEntry.LoggedTime % 60;

            this.deltaSelectedHour   = h.ToString();
            this.deltaSelectedMinute = m.ToString("00");

            deltaModel.NumberSelected += (Object sender, EventArgs e) =>
            {
                this.deltaSelectedHour   = deltaModel.selectedHour;
                this.deltaSelectedMinute = deltaModel.selectedMinute;
            };

            DeltaPicker.Model           = deltaModel;
            DeltaPicker.BackgroundColor = UIColor.White;
            DeltaPicker.Select(h, 0, true);
            DeltaPicker.Select(m, 1, true);

            //Setup the toolbar
            toolbar                 = new UIToolbar();
            toolbar.BarStyle        = UIBarStyle.Default;
            toolbar.BackgroundColor = UIColor.FromRGB(220, 220, 220);
            toolbar.Translucent     = true;
            toolbar.SizeToFit();

            // Create a 'done' button for the toolbar and add it to the toolbar
            saveButton = new UIBarButtonItem("Save", UIBarButtonItemStyle.Bordered, null);

            saveButton.Clicked += async(s, e) =>
            {
                this.DeltaText.Text = this.deltaSelectedHour + ":" + this.deltaSelectedMinute;
                double oldLoggedTime = timeLogEntry.LoggedTime;
                timeLogEntry.LoggedTime = int.Parse(this.deltaSelectedHour) * 60 + int.Parse(this.deltaSelectedMinute);
                this.DeltaText.ResignFirstResponder();

                if (!isAddingMode)
                {
                    if (isActiveTimeLog())
                    {
                        tlc.SetLoggedTime((int)timeLogEntry.LoggedTime);
                    }
                    else
                    {
                        try
                        {
                            await PDashAPI.Controller.UpdateTimeLog(timeLogEntry.Id.ToString(), null, null, timeLogEntry.Task.Id, timeLogEntry.LoggedTime - oldLoggedTime, null, false);
                        }
                        catch (Exception ex)
                        {
                            ViewControllerHelper.ShowAlert(this, "Change Logged Time", ex.Message + " Please try again later.");
                        }
                    }
                }
            };

            cancelButton = new UIBarButtonItem("Cancel", UIBarButtonItemStyle.Bordered,
                                               (s, e) =>
            {
                this.DeltaText.ResignFirstResponder();
            });

            toolbar.SetItems(new UIBarButtonItem[] { cancelButton, spacer, saveButton }, true);

            this.DeltaText.InputView          = DeltaPicker;
            this.DeltaText.InputAccessoryView = toolbar;

            ////// Int Picker
            IntPicker = new UIPickerView(new CoreGraphics.CGRect(10f, this.View.Frame.Height - 200, this.View.Frame.Width - 20, 200f));
            IntPicker.BackgroundColor = UIColor.FromRGB(220, 220, 220);

            IntPicker.UserInteractionEnabled = true;
            IntPicker.ShowSelectionIndicator = true;
            IntPicker.BackgroundColor        = UIColor.White;

            IntPicker.Select(0, 0, true);

            StatusPickerViewModel intModel = new StatusPickerViewModel(hours, minutes);

            intModel.NumberSelected += (Object sender, EventArgs e) =>
            {
                this.intSelectedHour   = intModel.selectedHour;
                this.intSelectedMinute = intModel.selectedMinute;
            };

            IntPicker.Model = intModel;

            IntPicker.Select((int)timeLogEntry.InterruptTime / 60, 0, true);
            IntPicker.Select((int)timeLogEntry.InterruptTime % 60, 1, true);

            //Setup the toolbar
            toolbar                 = new UIToolbar();
            toolbar.BarStyle        = UIBarStyle.Default;
            toolbar.BackgroundColor = UIColor.FromRGB(220, 220, 220);
            toolbar.Translucent     = true;
            toolbar.SizeToFit();

            saveButton = new UIBarButtonItem("Save", UIBarButtonItemStyle.Bordered, null);

            saveButton.Clicked += async(s, e) =>
            {
                this.IntText.Text          = this.intSelectedHour + ":" + this.intSelectedMinute;
                timeLogEntry.InterruptTime = int.Parse(this.intSelectedHour) * 60 + int.Parse(this.intSelectedMinute);
                this.IntText.ResignFirstResponder();

                if (!isAddingMode)
                {
                    if (isActiveTimeLog())
                    {
                        tlc.SetInterruptTime((int)timeLogEntry.InterruptTime);
                    }
                    else
                    {
                        try
                        {
                            await PDashAPI.Controller.UpdateTimeLog(timeLogEntry.Id.ToString(), null, null, timeLogEntry.Task.Id, null, timeLogEntry.InterruptTime, false);
                        }
                        catch (Exception ex)
                        {
                            ViewControllerHelper.ShowAlert(this, "Change Interrupt Time", ex.Message + " Please try again later.");
                        }
                    }
                }
            };

            cancelButton = new UIBarButtonItem("Cancel", UIBarButtonItemStyle.Bordered,
                                               (s, e) =>
            {
                this.IntText.ResignFirstResponder();
            });

            toolbar.SetItems(new UIBarButtonItem[] { cancelButton, spacer, saveButton }, true);

            this.IntText.InputView          = IntPicker;
            this.IntText.InputAccessoryView = toolbar;
        }
        // Generates content of worksheetCommentsPart1.
        private void GenerateWorksheetCommentsPart1Content(WorksheetCommentsPart worksheetCommentsPart1)
        {
            Comments comments1 = new Comments();

            Authors authors1 = new Authors();
            Author author1 = new Author();
            author1.Text = "Author";

            authors1.Append(author1);

            CommentList commentList1 = new CommentList();

            Comment comment1 = new Comment() { Reference = "V10", AuthorId = (UInt32Value)0U, ShapeId = (UInt32Value)0U };

            CommentText commentText1 = new CommentText();

            Run run14 = new Run();

            RunProperties runProperties14 = new RunProperties();
            Bold bold1 = new Bold();
            FontSize fontSize1 = new FontSize() { Val = 9D };
            Color color1 = new Color() { Indexed = (UInt32Value)81U };
            RunFont runFont1 = new RunFont() { Val = "Tahoma" };
            RunPropertyCharSet runPropertyCharSet1 = new RunPropertyCharSet() { Val = 1 };

            runProperties14.Append(bold1);
            runProperties14.Append(fontSize1);
            runProperties14.Append(color1);
            runProperties14.Append(runFont1);
            runProperties14.Append(runPropertyCharSet1);
            Text text14 = new Text();
            text14.Text = "Author:";

            run14.Append(runProperties14);
            run14.Append(text14);

            Run run15 = new Run();

            RunProperties runProperties15 = new RunProperties();
            FontSize fontSize2 = new FontSize() { Val = 9D };
            Color color2 = new Color() { Indexed = (UInt32Value)81U };
            RunFont runFont2 = new RunFont() { Val = "Tahoma" };
            RunPropertyCharSet runPropertyCharSet2 = new RunPropertyCharSet() { Val = 1 };

            runProperties15.Append(fontSize2);
            runProperties15.Append(color2);
            runProperties15.Append(runFont2);
            runProperties15.Append(runPropertyCharSet2);
            Text text15 = new Text() { Space = SpaceProcessingModeValues.Preserve };
            text15.Text = "\nThis is a comment";

            run15.Append(runProperties15);
            run15.Append(text15);

            commentText1.Append(run14);
            commentText1.Append(run15);

            comment1.Append(commentText1);

            commentList1.Append(comment1);

            comments1.Append(authors1);
            comments1.Append(commentList1);

            worksheetCommentsPart1.Comments = comments1;
        }
        //Comment
        public CommentAdapterViewHolder(View itemView, CommentAdapter commentAdapter, CommentClickListener postClickListener, string typeClass = "Comment") : base(itemView)
        {
            try
            {
                MainView = itemView;

                CommentAdapter    = commentAdapter;
                PostClickListener = postClickListener;
                TypeClass         = typeClass;

                MainCommentLayout = MainView.FindViewById <RelativeLayout>(Resource.Id.mainComment);
                BubbleLayout      = MainView.FindViewById <LinearLayout>(Resource.Id.bubble_layout);
                Image             = MainView.FindViewById <CircleImageView>(Resource.Id.card_pro_pic);
                CommentText       = MainView.FindViewById <SuperTextView>(Resource.Id.active);
                CommentText?.SetTextInfo(CommentText);

                UserName                    = MainView.FindViewById <TextView>(Resource.Id.username);
                TimeTextView                = MainView.FindViewById <TextView>(Resource.Id.time);
                ReplyTextView               = MainView.FindViewById <TextView>(Resource.Id.reply);
                LikeTextView                = MainView.FindViewById <TextView>(Resource.Id.Like);
                DislikeTextView             = MainView.FindViewById <TextView>(Resource.Id.dislike);
                CommentImage                = MainView.FindViewById <ImageView>(Resource.Id.image);
                CountLikeSection            = MainView.FindViewById <LinearLayout>(Resource.Id.countLikeSection);
                CountLike                   = MainView.FindViewById <TextView>(Resource.Id.countLike);
                ImageCountLike              = MainView.FindViewById <ImageView>(Resource.Id.ImagecountLike);
                CountLikeSection.Visibility = ViewStates.Gone;
                try
                {
                    VoiceLayout   = MainView.FindViewById <LinearLayout>(Resource.Id.voiceLayout);
                    PlayButton    = MainView.FindViewById <CircleButton>(Resource.Id.playButton);
                    DurationVoice = MainView.FindViewById <TextView>(Resource.Id.Duration);
                    TimeVoice     = MainView.FindViewById <TextView>(Resource.Id.timeVoice);

                    PlayButton?.SetOnClickListener(this);
                }
                catch (Exception e)
                {
                    Methods.DisplayReportResultTrack(e);
                }

                var font = Typeface.CreateFromAsset(MainView.Context.Resources?.Assets, "ionicons.ttf");
                UserName.SetTypeface(font, TypefaceStyle.Normal);

                switch (AppSettings.FlowDirectionRightToLeft)
                {
                case true:
                    BubbleLayout.SetBackgroundResource(Resource.Drawable.comment_rounded_right_layout);
                    break;
                }

                switch (AppSettings.PostButton)
                {
                case PostButtonSystem.DisLike:
                case PostButtonSystem.Wonder:
                    DislikeTextView.Visibility = ViewStates.Visible;
                    break;
                }

                /*ReplyTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);
                 * LikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);
                 * DislikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);*/
                ReplyTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.ParseColor("#888888"));
                LikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.ParseColor("#888888"));
                DislikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.ParseColor("#888888"));

                MainView.SetOnLongClickListener(this);
                Image.SetOnClickListener(this);
                LikeTextView.SetOnClickListener(this);
                DislikeTextView.SetOnClickListener(this);
                ReplyTextView.SetOnClickListener(this);
                CommentImage?.SetOnClickListener(this);
                CountLikeSection?.SetOnClickListener(this);
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
Пример #32
0
 /// <summary>
 /// Form an SLRstType from DocumentFormat.OpenXml.Spreadsheet.CommentText class.
 /// </summary>
 /// <param name="Comment">A source DocumentFormat.OpenXml.Spreadsheet.CommentText class.</param>
 public void FromCommentText(CommentText Comment)
 {
     this.istrReal.InnerXml = Comment.InnerXml;
 }
Пример #33
0
 /// <summary>
 /// Form an SLRstType from DocumentFormat.OpenXml.Spreadsheet.CommentText class.
 /// </summary>
 /// <param name="Comment">A source DocumentFormat.OpenXml.Spreadsheet.CommentText class.</param>
 public void FromCommentText(CommentText Comment)
 {
     this.istrReal.InnerXml = Comment.InnerXml;
 }
Пример #34
0
        //Reply
        public CommentAdapterViewHolder(View itemView, ReplyCommentAdapter commentAdapter, CommentClickListener postClickListener, CommentObjectExtra commentObject = null) : base(itemView)
        {
            try
            {
                MainView = itemView;

                if (commentObject != null)
                {
                    ReplyCommentObject = commentObject;
                }
                ReplyCommentAdapter = commentAdapter;
                PostClickListener   = postClickListener;
                TypeClass           = "Reply";

                MainCommentLayout = MainView.FindViewById <RelativeLayout>(Resource.Id.mainComment);
                BubbleLayout      = MainView.FindViewById <LinearLayout>(Resource.Id.bubble_layout);
                Image             = MainView.FindViewById <CircleImageView>(Resource.Id.card_pro_pic);
                CommentText       = MainView.FindViewById <SuperTextView>(Resource.Id.active);
                CommentText?.SetTextInfo(CommentText);

                UserName                    = MainView.FindViewById <TextView>(Resource.Id.username);
                TimeTextView                = MainView.FindViewById <TextView>(Resource.Id.time);
                ReplyTextView               = MainView.FindViewById <TextView>(Resource.Id.reply);
                LikeTextView                = MainView.FindViewById <TextView>(Resource.Id.Like);
                DislikeTextView             = MainView.FindViewById <TextView>(Resource.Id.dislike);
                CommentImage                = MainView.FindViewById <ImageView>(Resource.Id.image);
                CountLikeSection            = MainView.FindViewById <LinearLayout>(Resource.Id.countLikeSection);
                CountLike                   = MainView.FindViewById <TextView>(Resource.Id.countLike);
                ImageCountLike              = MainView.FindViewById <ImageView>(Resource.Id.ImagecountLike);
                CountLikeSection.Visibility = ViewStates.Gone;
                RatingBar                   = itemView.FindViewById <RatingBar>(Resource.Id.RatingBar);
                RatingText                  = itemView.FindViewById <Button>(Resource.Id.RatingText);
                RatingLinearLayout          = itemView.FindViewById <LinearLayout>(Resource.Id.RatingLinearLayout);
                CountRating                 = MainView.FindViewById <TextView>(Resource.Id.countRating);
                try
                {
                    VoiceLayout   = MainView.FindViewById <LinearLayout>(Resource.Id.voiceLayout);
                    PlayButton    = MainView.FindViewById <CircleButton>(Resource.Id.playButton);
                    DurationVoice = MainView.FindViewById <TextView>(Resource.Id.Duration);
                    TimeVoice     = MainView.FindViewById <TextView>(Resource.Id.timeVoice);

                    PlayButton?.SetOnClickListener(this);
                }
                catch (Exception e)
                {
                    Methods.DisplayReportResultTrack(e);
                }

                var font = Typeface.CreateFromAsset(MainView.Context.Resources?.Assets, "ionicons.ttf");
                UserName.SetTypeface(font, TypefaceStyle.Normal);

                if (AppSettings.FlowDirectionRightToLeft)
                {
                    BubbleLayout.SetBackgroundResource(Resource.Drawable.comment_rounded_right_layout);
                }

                if (AppSettings.PostButton == PostButtonSystem.DisLike || AppSettings.PostButton == PostButtonSystem.Wonder)
                {
                    DislikeTextView.Visibility = ViewStates.Visible;
                }

                ReplyTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);
                LikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);
                DislikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);

                MainView.SetOnLongClickListener(this);
                Image.SetOnClickListener(this);
                LikeTextView.SetOnClickListener(this);
                DislikeTextView.SetOnClickListener(this);
                ReplyTextView.SetOnClickListener(this);
                CommentImage?.SetOnClickListener(this);
                CountLikeSection?.SetOnClickListener(this);
                RatingLinearLayout?.SetOnClickListener(this);
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
Пример #35
0
        public static void Seed(LibraryContext context)
        {
            if (!context.Articles.Any())
            {
                Article a1 = new Article {
                    Title = "Winter colds and small amounts", Date = new DateTime(2021, 2, 10), Text = "Winter colds and small amounts of sunshine make feel us weak. The stores of vitamins in the body are significantly reduced during the winter. Weather shifts can affect immunity. As a result, a lot of people feel unwell with the start of spring. The sun is shining, flowers blossom, temperatures are rising and nature awakens from winter sleep. Spring is a beautiful time, isn’t it? Along with positive changes, it’s also the time when our body lacks vitamins, that is so-called avitaminosis."
                };
                Article a2 = new Article {
                    Title = "Self-discipline", Date = new DateTime(2021, 2, 11), Text = "Just understand that time is not your enemy but your friend. You can do so many things if you have goals and opportunities. The main thing is to organize yourself and your time correctly. It refers not only to work but also to other aspects of your life. Self-discipline is a key to success. A person who can’t control his life and be organized, so he can’t achieve the desired success. If you can’t achieve anything, it may cause stress, reduce productivity and disorganization. You get caught in a vicious circle!"
                };
                Article a3 = new Article {
                    Title = "Emotions", Date = new DateTime(2021, 2, 11), Text = "Psychologists refer fear as a basic “emotion” that we experience it daily at work, at school, in the street, at home, everywhere. Fear mainly arises from 2 sources:  your personality and uncertainty. Many people are afraid of different things: water, height, pain, failure, death. They may have the same fear, but their behavior is shown in absolutely different ways: some people start to panic, other can’t control their emotions, etc. In this article we will talk about a common phobia called “stage fright”."
                };

                Article a4 = new Article {
                    Title = "Winter colds and small amounts 2", Date = new DateTime(2021, 2, 12), Text = "Winter colds and small amounts of sunshine make feel us weak. The stores of vitamins in the body are significantly reduced during the winter. Weather shifts can affect immunity. As a result, a lot of people feel unwell with the start of spring. The sun is shining, flowers blossom, temperatures are rising and nature awakens from winter sleep. Spring is a beautiful time, isn’t it? Along with positive changes, it’s also the time when our body lacks vitamins, that is so-called avitaminosis."
                };
                Article a5 = new Article {
                    Title = "Self-discipline 2", Date = new DateTime(2021, 2, 12), Text = "Just understand that time is not your enemy but your friend. You can do so many things if you have goals and opportunities. The main thing is to organize yourself and your time correctly. It refers not only to work but also to other aspects of your life. Self-discipline is a key to success. A person who can’t control his life and be organized, so he can’t achieve the desired success. If you can’t achieve anything, it may cause stress, reduce productivity and disorganization. You get caught in a vicious circle!"
                };
                Article a6 = new Article {
                    Title = "Emotions 2", Date = new DateTime(2021, 2, 13), Text = "Psychologists refer fear as a basic “emotion” that we experience it daily at work, at school, in the street, at home, everywhere. Fear mainly arises from 2 sources:  your personality and uncertainty. Many people are afraid of different things: water, height, pain, failure, death. They may have the same fear, but their behavior is shown in absolutely different ways: some people start to panic, other can’t control their emotions, etc. In this article we will talk about a common phobia called “stage fright”."
                };

                Article a7 = new Article {
                    Title = "Winter colds and small amounts 3", Date = new DateTime(2021, 2, 14), Text = "Winter colds and small amounts of sunshine make feel us weak. The stores of vitamins in the body are significantly reduced during the winter. Weather shifts can affect immunity. As a result, a lot of people feel unwell with the start of spring. The sun is shining, flowers blossom, temperatures are rising and nature awakens from winter sleep. Spring is a beautiful time, isn’t it? Along with positive changes, it’s also the time when our body lacks vitamins, that is so-called avitaminosis."
                };
                Article a8 = new Article {
                    Title = "Self-discipline 3", Date = new DateTime(2021, 2, 14), Text = "Just understand that time is not your enemy but your friend. You can do so many things if you have goals and opportunities. The main thing is to organize yourself and your time correctly. It refers not only to work but also to other aspects of your life. Self-discipline is a key to success. A person who can’t control his life and be organized, so he can’t achieve the desired success. If you can’t achieve anything, it may cause stress, reduce productivity and disorganization. You get caught in a vicious circle!"
                };
                Article a9 = new Article {
                    Title = "Emotions 3", Date = new DateTime(2021, 2, 14), Text = "Psychologists refer fear as a basic “emotion” that we experience it daily at work, at school, in the street, at home, everywhere. Fear mainly arises from 2 sources:  your personality and uncertainty. Many people are afraid of different things: water, height, pain, failure, death. They may have the same fear, but their behavior is shown in absolutely different ways: some people start to panic, other can’t control their emotions, etc. In this article we will talk about a common phobia called “stage fright”."
                };

                Comment c1 = new Comment {
                    Name = "Pavlo Kalenyk", Date = new DateTime(2021, 2, 10)
                };
                Comment c2 = new Comment {
                    Name = "Pavlo Kalenyk", Date = new DateTime(2021, 2, 11)
                };
                Comment c3 = new Comment {
                    Name = "Pavlo Kalenyk", Date = new DateTime(2021, 2, 12)
                };

                Comment c4 = new Comment {
                    Name = "Pavlo Kalenyk", Date = new DateTime(2021, 2, 13)
                };
                Comment c5 = new Comment {
                    Name = "Pavlo Kalenyk", Date = new DateTime(2021, 2, 14)
                };
                Comment c6 = new Comment {
                    Name = "Pavlo Kalenyk", Date = new DateTime(2021, 2, 14)
                };

                Comment c7 = new Comment {
                    Name = "Pavlo Kalenyk", Date = new DateTime(2021, 2, 15)
                };
                Comment c8 = new Comment {
                    Name = "Pavlo Kalenyk", Date = new DateTime(2021, 2, 15)
                };
                Comment c9 = new Comment {
                    Name = "Pavlo Kalenyk", Date = new DateTime(2021, 2, 15)
                };

                CommentText commentText = new CommentText {
                    Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", Comment = c1
                };
                CommentText commentText1 = new CommentText {
                    Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", Comment = c2
                };
                CommentText commentText2 = new CommentText {
                    Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", Comment = c3
                };
                CommentText commentText3 = new CommentText {
                    Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", Comment = c4
                };
                CommentText commentText4 = new CommentText {
                    Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", Comment = c5
                };
                CommentText commentText5 = new CommentText {
                    Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", Comment = c6
                };
                CommentText commentText6 = new CommentText {
                    Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", Comment = c7
                };
                CommentText commentText7 = new CommentText {
                    Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", Comment = c8
                };
                CommentText commentText8 = new CommentText {
                    Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", Comment = c9
                };

                Questionnaire questionnaire = new Questionnaire();

                questionnaire.FirstName = "Pavlo";
                questionnaire.LastName  = "Kalenyk";

                QuestionnaireAnswer questionnaireAnswer = new QuestionnaireAnswer();

                questionnaireAnswer.Answer = "Fantastic";

                QuestionnaireAnswer questionnaireAnswer2 = new QuestionnaireAnswer();

                questionnaireAnswer2.Answer = "English";

                QuestionnaireAnswer questionnaireAnswer3 = new QuestionnaireAnswer();

                questionnaireAnswer3.Answer = "Yes";

                questionnaire.QuestionnaireAnswers.Add(questionnaireAnswer);
                questionnaire.QuestionnaireAnswers.Add(questionnaireAnswer2);
                questionnaire.QuestionnaireAnswers.Add(questionnaireAnswer3);

                Tag t1 = new Tag {
                    Name = "news"
                };
                Tag t2 = new Tag {
                    Name = "2020"
                };
                Tag t3 = new Tag {
                    Name = "cool"
                };

                t1.Articles = new List <Article> {
                    a1, a2, a7, a8, a9
                };
                t2.Articles = new List <Article> {
                    a2, a4, a5, a6
                };
                t3.Articles = new List <Article> {
                    a3, a4, a5, a6
                };

                context.Articles.AddRange(a1, a2, a3, a4, a5, a6, a7, a8, a9);

                context.Comments.AddRange(c1, c2, c3, c4, c5, c6, c7, c8, c9);

                context.CommentText.AddRange(commentText, commentText1, commentText2, commentText3, commentText4, commentText5, commentText6, commentText7, commentText8);

                context.Tags.Add(t1);
                context.Tags.Add(t2);
                context.Tags.Add(t3);

                context.Questionnaires.Add(questionnaire);

                context.SaveChanges();
            }
        }