示例#1
0
        public ActionResult Edit(int id, PostView NewPostView)
        {
            Post pNewPost = new Post();

            try
            {
                // TODO: Add insert logic here
                pNewPost.Avatar      = NewPostView.Avatar;
                pNewPost.PostContent = NewPostView.pContent;
                pNewPost.TopicID     = new TopicModel().GetIdByName(NewPostView.pNameTopic);
                pNewPost.Descrip     = NewPostView.pDescrip;
                pNewPost.IsActive    = true;
                var check = new PostModel().Edit(id, pNewPost);
                if (check)
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(View(NewPostView));
                }
            }
            catch
            {
                return(View(NewPostView));
            }
        }
示例#2
0
        public ActionResult Create(PostView NewPostView)
        {
            Post pNewPost = new Post();

            try
            {
                // TODO: Add insert logic here
                pNewPost.Avatar      = NewPostView.Avatar;
                pNewPost.AccountID   = account.Id;
                pNewPost.PostContent = NewPostView.pContent;
                pNewPost.TopicID     = new TopicModel().GetIdByName(NewPostView.pNameTopic);
                pNewPost.Like        = 0;
                pNewPost.Dislike     = 0;
                pNewPost.Descrip     = NewPostView.pDescrip;
                pNewPost.PostDate    = DateTime.Now;
                pNewPost.IsActive    = true;
                pNewPost.LangId      = 0;
                var check = new PostModel().Create(pNewPost);
                if (check == true)
                {
                    return(RedirectToAction("Index"));
                }
                return(View(NewPostView));
            }
            catch
            {
                return(View(NewPostView));
            }
        }
        public static PostView Build(Post i_Post)
        {
            PostView postResult = new PostView(i_Post);

            postResult.Dock    = DockStyle.Top;
            postResult.Padding = new Padding(0, 15, 0, 0);
            PostDetails details = new PostDetails();
            PostBody    body    = new PostBody();
            PostActions actions = new PostActions();

            actions.Init(i_Post);
            body.Init(i_Post);
            details.Init(i_Post);

            details.Dock = DockStyle.Top;
            body.Dock    = DockStyle.Top;
            actions.Dock = DockStyle.Top;

            postResult.Controls.Add(actions);
            postResult.Controls.Add(body);
            postResult.Controls.Add(details);

            details.UserClicked += postResult.OnUserClicked;

            return(postResult);
        }
示例#4
0
        public ActionResult CreatePost(int id /*parent id*/)
        {
            Post parentPost = db.Posts.Find(id);

            Post post = new Post();

            post.Content      = "";
            post.Tags         = "";
            post.CreationDate = DateTime.Now;
            post.UserId       = OnlineUsers.CurrentUser.Id;
            if (parentPost != null)
            {
                post.ParentPostId = id;
                post.Title        = "Réponse à " + parentPost.User.FullName;
            }
            else
            {
                post.ParentPostId = 0;
                post.Title        = "";
            }
            PostView createdPost = db.AddPost(post.ToPostView());

            Session["EditingPostId"] = createdPost.Id;
            RefreshPostsLastRequest  = new DateTime(0);
            return(new JsonResult {
                Data = "CreatePost to post Id: " + id, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
示例#5
0
        public ActionResult PostDetails()
        {
            PostView postView = new PostView();
            int      parentId = getPost();

            if (parentId == 0)
            {
                return(RedirectToAction("Index", "Posts"));
            }

            postView.post = db.Posts.Find(parentId);
            List <Comment> justComments = new List <Comment>();

            foreach (var b in db.Comments)
            {
                if (b.ParentId == postView.post.Id)
                {
                    justComments.Add(b);
                }
            }
            foreach (var b in justComments)
            {
                b.AuthorId = getName(b.AuthorId);
            }
            postView.Comments = justComments;
            return(View(postView));
        }
示例#6
0
        public void SetConfig(IRepositoryPost repository, IRepositoryQc repositoryQc, INotificationCenter notification, PostOtherThemeStrings otherThemeStrings,
                              PostsViewController viewController, string id, int bodyWidth, int row, Action <int, nfloat> postHeightCounted, nfloat height)
        {
            var post = DataService.RepositoryController.RepositoryPost.GetOnePostById(id);

            _market = (EMarketTypes)Enum.Parse(typeof(EMarketTypes), post.ModelPost.Market);
            PostView.SetPostMarket(_market);

            Console.WriteLine(_market + "   " + post.ModelPost.Content);

            PostInteractor = new InteractorPost(id, new OnePostController(DataService.RepositoryController.RepositoryPost), notification, repository, repositoryQc);
            var presenter = new PresenterPost(
                view:               PostView,
                interactor:         PostInteractor,
                router:             new RouterPost(viewController),
                otherThemeStrings:  otherThemeStrings,
                headerStylesHolder: new PostHeaderStylesHolderIOS <GlobalControlsTheme>(iOS_DAL.ThemeParser),
                socialStylesHolder: new PostSocialStylesHolderIOS <GlobalControlsTheme>(iOS_DAL.ThemeParser),
                bodyStylesHolder:   new PostBodyStylesHolderIOS <GlobalControlsTheme>(iOS_DAL.ThemeParser),
                postLocale:         DataService.RepositoryController.RepositoryPost.LangPost,
                isPostDetailed:     false
                );

            SetCellWidth(bodyWidth);
            TransfareActionToView(postHeightCounted, row);

            PostInteractor.SendRequestForPosts();

            var fr = PostView.Frame;

            fr.Height      = height;
            PostView.Frame = fr;
        }
示例#7
0
        public ActionResult ConfirmDelete(PostView postView)
        {
            Post post = db.Posts.Find(postView.Id);

            db.Posts.Remove(post);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public static void GoToPost(Context context, PostView post)
        {
            var intent = new Intent(context, typeof(PostActivity));

            intent.PutExtra(Constants.KEY_POST_OBJECT, JsonConvert.SerializeObject(post));
            intent.PutExtra(Constants.KEY_FRAGMENT_TYPE, Constants.VALUE_TYPE_POST_FRAGMENT);
            context.StartActivity(intent);
        }
示例#9
0
        public ActionResult Tags(PostView postView)
        {
            string tags = postView.Tags != null?postView.Tags.ToString() : "";

            System.Web.HttpContext.Current.Session["Tags"] = tags;

            return(RedirectToAction("Index", "Posts"));
        }
示例#10
0
        public async Task <IViewComponentResult> InvokeAsync(PostView post)
        {
            List <Tag> tags = await this.tagService.GetTagsByPost(post);

            PostItemViewModel model = new PostItemViewModel(post, tags);

            return(View(model));
        }
示例#11
0
        public ActionResult Create()
        {
            var postView = new PostView
            {
                CurrentLang = CurrentLang.ID
            };

            return(View("Edit", postView));
        }
示例#12
0
        public async Task <PostView> GetAllPosts()
        {
            IEnumerable <Post> posts = await _postRepository.GetAll();

            IEnumerable <PostItem> postItems = _mapper.Map <IEnumerable <PostItem> >(posts);
            PostView view = new PostView(postItems);

            return(view);
        }
        public IViewComponentResult Invoke(PostView forPostView)
        {
            if (forPostView == null)
            {
                throw new ArgumentNullException(nameof(forPostView));
            }
            QuestionItemComponentModel model = new QuestionItemComponentModel(forPostView);

            return(View(model));
        }
示例#14
0
 protected void AddXPostItemsToView(int numberOfItems, PostView postView)
 {
     for (int i = 0; i < numberOfItems; i++)
     {
         var postCreatedEvent = new PostCreatedEvent("Title", "Content", "slug",
                                                     new List<string>() {"tag1", "tag2"}, "Excerpt",
                                                     DateTime.Now.AddDays(-1), Guid.NewGuid());
         postView.Handle(postCreatedEvent);
     }
 }
示例#15
0
 /// <summary>
 /// 获取帖子的标签
 /// </summary>
 public async Task <List <Tag> > GetTagsByPost(PostView post)
 {
     if (post == null)
     {
         throw new ArgumentNullException(nameof(post));
     }
     using (var work = this.dbFactory.StartWork())
     {
         return(await work.PostTag.GetTagsByPostAsync(post.Id));
     }
 }
示例#16
0
        public PostCore(PostView Publicacao, IMapper Mapper)
        {
            _mapper     = Mapper;
            _publicacao = _mapper.Map <PostView, Post>(Publicacao);

            RuleFor(p => p.Titulo).NotNull().Length(8, 250).WithMessage("O título deve ter entre 8 e 250 caracteres");
            RuleFor(p => p.Texto).NotNull().MinimumLength(50).WithMessage("O texto deve ter no mínimo 50 caracteres");

            _arm = Arquivo.Recuperar(_arm);
            _arm = _arm ?? new Armazenamento();
        }
示例#17
0
        public ActionResult Edit(int id)
        {
            Post     pNewPost     = new PostModel().GetPostById(id);
            PostView pNewPostView = new PostView();

            pNewPostView.pDescrip   = pNewPost.Descrip;
            pNewPostView.pNameTopic = new TopicModel().GetNameById(pNewPost.TopicID);
            pNewPostView.pContent   = pNewPost.PostContent;
            pNewPostView.Avatar     = pNewPost.Avatar;
            return(View(pNewPostView));
        }
示例#18
0
        public async Task <PostView> CreatePost(PostView postToCreate)
        {
            if (string.IsNullOrEmpty(postToCreate.PosterEmail))
            {
                throw new ArgumentNullException("Null Email");
            }
            var newPost = ViewModelFactory.CreateDomainModel(postToCreate);
            await _repository.CreateAsync(newPost);

            return(postToCreate);
        }
示例#19
0
        public ActionResult Edit(PostView postView)
        {
            if (ModelState.IsValid)
            {
                db.Entry(postView.ToPost()).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(postView));
        }
示例#20
0
        private void PostShow()
        {
            PostViewModel postViewModel = new PostViewModel();

            postViewModel.Description = "Почта";
            var postView = new PostView();

            postViewModel.View = postView;

            Workspace.This.Panels.Add(postViewModel);
            Workspace.This.ActiveDocument = postViewModel;
        }
 public ActionResult Delete(PostView post)
 {
     try
     {
         postService.Delete(post.Id);
         return(RedirectToAction("Index", new { authorId = post.AuthorId }));
     }
     catch
     {
         return(View("Error"));
     }
 }
示例#22
0
        private void PostView_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Right)
            {
                return;
            }

            PostViewNode node = PostView.GetNodeAt(e.Location) as PostViewNode;

            if (node == null)
            {
                return;
            }

            PostViewNode parent = node.ParentNode() as PostViewNode;

            OpPost replyTo = node.Post;

            if (parent != null)
            {
                replyTo = parent.Post;
            }

            ContextMenuStripEx menu = new ContextMenuStripEx();

            if (!replyTo.Header.Archived)
            {
                menu.Items.Add(new PostMenuItem("Reply", replyTo, (s, a) => ReplyPost(replyTo)));
            }

            if (node.Post.Header.SourceID == Core.UserID)
            {
                if (!replyTo.Header.Archived)
                {
                    menu.Items.Add(new PostMenuItem("Edit", node.Post, (s, a) => EditPost(node.Post)));
                    menu.Items.Add("-");
                }

                if (parent == null)
                {
                    if (node.Post.Header.Archived)
                    {
                        menu.Items.Add(new PostMenuItem("Restore", node.Post, (s, a) => Boards.Archive(node.Post, false)));
                    }
                    else
                    {
                        menu.Items.Add(new PostMenuItem("Archive", node.Post, (s, a) => Boards.Archive(node.Post, true)));
                    }
                }
            }

            menu.Show(PostView, e.Location);
        }
示例#23
0
 public static Post CreateDomainModel(PostView postToCreate)
 {
     return(new Post()
     {
         Subject = postToCreate.Subject,
         Text = postToCreate.Text,
         OwnerName = postToCreate.PosterName,
         OwnerEmail = postToCreate.PosterEmail,
         Open = true,
         Create = postToCreate.Create == DateTime.MinValue ? DateTime.Now : postToCreate.Create
     });
 }
示例#24
0
        public async void GetPostsAsync(PostCategory postCategory)
        {
            switch (postCategory)
            {
            case PostCategory.Hot:
                StartWorkIndication(ViewModelConstants.LOADING_HOT_MESSAGE);
                break;

            case PostCategory.Trending:
                StartWorkIndication(ViewModelConstants.LOADING_TRENDING_MESSAGE);
                break;

            case PostCategory.Vote:
                StartWorkIndication(ViewModelConstants.LOADING_FRESH_MESSAGE);
                break;
            }

            ArePostsLoading = true;

            await Task.Run(async() =>
            {
                var requestStatus = await _clientService.GetPostsAsync(postCategory, NUMBER_OF_POSTS);

                if (requestStatus != null && requestStatus.IsSuccessful)
                {
                    _currentCategory = postCategory;

                    Device.BeginInvokeOnMainThread(() =>
                    {
                        Posts.Clear();
                        Posts = new ObservableCollection <PostView>();

                        _clientService.Posts.ToList().ForEach(post =>
                                                              Posts.Add(PostViewFactory.CreatePostViewFromPost(post)));

                        CurrentPost = Posts.FirstOrDefault();
                    });

                    await Task.Delay(ViewModelConstants.GET_POSTS_DELAY);
                }
                else
                {
                    StopWorkIndication();
                    string message = requestStatus == null ? ViewModelConstants.REQUEST_FAILED_MESSAGE : requestStatus.Message;
                    await ShowMessage(message);
                }
            });

            ArePostsLoading = false;

            StopWorkIndication();
        }
示例#25
0
        public async Task <IViewComponentResult> InvokeAsync(PostView forPostView)
        {
            if (forPostView == null)
            {
                throw new ArgumentNullException(nameof(forPostView));
            }
            Post     post     = ObjectMapper.Map <PostView, Post>(forPostView);
            PostData postData = await this.postService.GetPostDataAsync(post);

            ArticleItemComponentModel model = new ArticleItemComponentModel(forPostView, postData);

            return(View(model));
        }
示例#26
0
 public ActionResult Edit([Bind(Include = "Id,Title,Content,Tags,CreationDate,UserId")] PostView postview)
 {
     if (ModelState.IsValid)
     {
         postview.Id           = (int)Session["editPostId"];
         postview.UserId       = (int)Session["editPostUserId"];
         postview.CreationDate = (DateTime)Session["editPostCreationDate"];
         postview.ParentPostId = (int)Session["editParentPostId"];
         db.UpdatePost(postview);
         return(RedirectToAction("Index"));
     }
     ViewBag.UserId = new SelectList(db.Users, "Id", "AvatarId", postview.UserId);
     return(View(postview));
 }
示例#27
0
        private void BoardView_Load(object sender, EventArgs e)
        {
            if (PostView.Nodes.Count > 0)
            {
                PostViewNode node = PostView.Nodes[0] as PostViewNode;

                PostView.Select(node);
                ShowMessage(node.Post, null);
            }
            else
            {
                ShowTips();
            }
        }
        public IActionResult AddBlog([FromBody] PostView postView)
        {
            var post = new Post
            {
                AuthorId         = GetUserId(),
                CreationTime     = DateTime.Now,
                Title            = postView.Title,
                ShortDescription = postView.ShortDescription,
                ImageId          = postView.ImageId,
                Text             = postView.Text
            };

            return(new ObjectResult(_blogService.SaveUserPost(post)));
        }
示例#29
0
        public ActionResult Create(PostView postView)
        {
            if (ModelState.IsValid)
            {
                UserView currentUser = OnlineUsers.GetSessionUser();
                postView.User   = currentUser;
                postView.UserId = currentUser.Id;
                db.Posts.Add(postView.ToPost());
                db.SaveChanges();
                return(RedirectToAction("Index", "Posts"));
            }

            return(View(postView));
        }
示例#30
0
 public PostGridItem from(PostView post)
 {
     return(new PostGridItem()
     {
         Id = post.id,
         Published = post.Published,
         Subtitle = post.Subtitle,
         Tags = string.Join(", ", post.Tags.Select(x => x.Name).ToArray()),
         Title = post.Title,
         Content = post.Content,
         Thumbnail = post.Thumbnail,
         Category = post.Category,
         Author = post.User
     });
 }
示例#31
0
        public async Task <IActionResult> GetPost(int id)
        {
            var post = _context.Posts.Include(p => p.Author)
                       .Include(p => p.Views)
                       .Include(p => p.Votes)
                       .FirstOrDefault(p => p.Id == id);

            if (post == null)
            {
                return(RedirectToAction(nameof(Index)));
            }

            var viewerId = User.FindFirst(ClaimTypes.Anonymous).Value;

            if (!post.Views.Any(p => p.ViewerId == viewerId))
            {
                var view = new PostView()
                {
                    PostId   = post.Id,
                    ViewerId = viewerId,
                    Date     = DateTime.Now
                };

                await _context.PostViews.AddAsync(view);

                await _context.SaveChangesAsync();
            }

            //if (!HttpContext.Session.Keys.Contains("History"))
            //{
            //    HttpContext.Session.SetObjectAsJson("History", new List<int>());
            //}
            //List<int> visited = HttpContext.Session.GetObjectFromJson<List<int>>("History");
            //if (!visited.Contains(id))
            //{
            //    var view = new PostView()
            //    {
            //        PostId = post.Id,
            //        Date = DateTime.Now
            //    };

            //    await _context.PostViews.AddAsync(view);
            //    await _context.SaveChangesAsync();
            //    visited.Add(id);
            //    HttpContext.Session.SetObjectAsJson("History", visited);
            //}
            return(View(post));
        }
示例#32
0
        public ActionResult Alliance(string id)
        {
            CompleteProfile myProfile = (CompleteProfile)Session["myProfile"];

            //"ACBCCE0E-7C9F-4386-98AA-1458F308E1B0"
            AllianceViewModel allianceRetrieved = AllianceService.GetAllianceByKey(id);
            AllianceView allianceView = new AllianceView();

            allianceView.Profile = new CompleteProfileView { BasicProfile = new BasicProfileView { ReferenceKey=allianceRetrieved.Profile.BasicProfile.ReferenceKey , AccountType= Domain._Base.Accounts.AccountType.Alliance  }, FullName=allianceRetrieved.Profile.FullName, Description1=allianceRetrieved.Profile.Description1  };

            allianceView.WallOfThisProfile  = new ContentStreamView();
            allianceView.WallOfThisProfile.Posts = new List<PostView>();

            var thisViewerKey = myProfile.BasicProfile.ReferenceKey.ToString();
            ContentStreamViewModel wallRetrieved = PublishingService.GetContentStreamByOwnerReferenceKey(id, thisViewerKey);

            allianceView.WallOfThisProfile = new ContentStreamView();
            allianceView.WallOfThisProfile.Posts = new List<PostView>();
            if (wallRetrieved.Posts.Count >0)
            {

                foreach (PostViewModel post in wallRetrieved.Posts)
                {
                    PostView thisPost = new PostView();
                    thisPost.Key = post.Key;
                    thisPost.Author = new CompleteProfileView { BasicProfile = new BasicProfileView { ReferenceKey=post.Author.BasicProfile.ReferenceKey  , AccountType= post.Author.BasicProfile.AccountType  }, FullName=post.Author.FullName, Description1= post.Author.Description1 , Description2= post.Author.Description2  };
                    thisPost.TimeStamp = post.TimeStamp.ToString();
                    thisPost.Text = post.Text;
                    thisPost.Likes = post.Likes;

                    thisPost.Comments = new List<CommentView>();
                    foreach (CommentViewModel comment in post.Comments)
                    {
                        CommentView thisComment = new CommentView();
                        thisComment.Key = comment.Key;
                        thisComment.Author = new CompleteProfileView { BasicProfile = new BasicProfileView { ReferenceKey = comment.Author.BasicProfile.ReferenceKey, AccountType = comment.Author.BasicProfile.AccountType }, FullName = comment.Author.FullName, Description1 = comment.Author.Description1, Description2 = comment.Author.Description2 };
                        thisComment.Text = comment.Text;
                        thisComment.TimeStamp = comment.TimeStamp.ToString();
                        thisComment.Likes = comment.Likes;
                        thisPost.Comments.Add(thisComment);
                    }
                    allianceView.WallOfThisProfile.Posts.Add(thisPost);
                }
            }

            //if (allianceRetrieved.Wall != null)
            //{
            //    allianceView.WallOfThisProfile = new ContentStreamView();

            //    if (allianceRetrieved.Wall.Posts != null)
            //    {
            //        allianceView.WallOfThisProfile.Posts = new List<PostView>();
            //        foreach (PostViewModel post in allianceRetrieved.Wall.Posts)
            //        {
            //            PostView thisPost = new PostView();

            //            thisPost.Author = new CompleteProfileView { BasicProfile = new BasicProfileView { ReferenceKey = post.Author.BasicProfile.ReferenceKey, AccountType = post.Author.BasicProfile.AccountType }, FullName = post.Author.FullName, Description1 = post.Author.Description1, Description2 = post.Author.Description2 };
            //            thisPost.Key = post.Key;

            //            thisPost.Text = post.Text;
            //            thisPost.TimeStamp = post.TimeStamp.ToString();
            //            thisPost.Comments = new List<CommentView>();
            //            foreach (CommentViewModel comment in post.Comments)
            //            {
            //                CommentView thisComment = new CommentView();

            //                thisComment.Author = new CompleteProfileView { BasicProfile = new BasicProfileView { ReferenceKey = comment.Author.BasicProfile.ReferenceKey, AccountType = comment.Author.BasicProfile.AccountType }, FullName = comment.Author.FullName, Description1 = comment.Author.Description1, Description2 = comment.Author.Description2 };
            //                thisComment.Key = comment.Key;
            //                thisComment.Text = comment.Text;
            //                thisComment.TimeStamp = comment.TimeStamp.ToString();
            //                thisPost.Comments.Add(thisComment);
            //            }
            //            allianceView.WallOfThisProfile.Posts.Add(thisPost);
            //        }
              //  }

              //  }

            allianceView.IsViewerAllowedToCollaborate = true;
            allianceView.Members = new List<CompleteProfileView>();
            foreach (CompleteProfileViewModel item in allianceRetrieved.Members)
            {
                allianceView.Members.Add(new CompleteProfileView { BasicProfile = new BasicProfileView { ReferenceKey = item.BasicProfile.ReferenceKey, AccountType = item.BasicProfile.AccountType }, FullName = item.FullName, Description1 = item.Description1 });
            }

            return View(allianceView);
        }
        public ActionResult Index()
        {
            CompleteProfile myProfile = (CompleteProfile) Session["myProfile"];

            //OrganizationServiceFacade organizationService = new OrganizationServiceFacade(new OrganizationServiceProxy());

            //Dictionary<String, String> organizationAccountsFound = _organizationAccountServiceFacade.GetAllOrganizationAccounts();

            //OrganizationAccountsView organizationAccountsView = new OrganizationAccountsView();

            //organizationAccountsView.OrganizationAccounts = organizationAccountsFound;

            //return View(organizationAccountsView);

            //OrganizationServiceFacade organizationService = new OrganizationServiceFacade(new OrganizationServiceProxy());
            //"BCBCCE0E-7C9F-4386-98AA-1458F308E1C3"
            OrganizationAccountViewModel organizationAccountRetrieved = OrganizationAccountService.GetOrganizationAccountByKey(myProfile.BasicProfile.ReferenceKey.ToString());

            OrganizationAccountView organizationAccountView = new OrganizationAccountView();
            CompleteProfileView completeProfile = new CompleteProfileView { BasicProfile = new BasicProfileView { ReferenceKey=myProfile.BasicProfile.ReferenceKey.ToString(), AccountType=myProfile.BasicProfile.ReferenceType  }, FullName=myProfile.FullName, Description1=myProfile.Description1  };

            organizationAccountView.Profile = completeProfile;

            organizationAccountView.Email = organizationAccountRetrieved.Email;

            organizationAccountView.IsThisMyOwnProfile = true;

            organizationAccountView.EmployeesOfThisProfile = Converters.ConvertFromViewModelToView(OrganizationAccountService.GetEmployeesOfOrganizationAccountByKey(organizationAccountRetrieved.Profile.BasicProfile.ReferenceKey));
            organizationAccountView.SisterDivisionsOfThisProfile = Converters.ConvertFromViewModelToView(OrganizationAccountService.GetSisterDivisionsOfOrganizationAccountByKey(organizationAccountRetrieved.Profile.BasicProfile.ReferenceKey));
            organizationAccountView.PartnersOfThisProfile = Converters.ConvertFromViewModelToView(OrganizationAccountService.GetPartnersOfOrganizationAccountByKey(organizationAccountRetrieved.Profile.BasicProfile.ReferenceKey));
            organizationAccountView.AlliancesOfThisProfile = Converters.ConvertFromViewModelToView(OrganizationAccountService.GetAlliancesOfOrganizationAccountByKey(organizationAccountRetrieved.Profile.BasicProfile.ReferenceKey));

            organizationAccountView.MyGeoLocation = new GeoLocationView { Latitude=organizationAccountRetrieved.Location.Latitude , Longitude=organizationAccountRetrieved.Location.Longitude  };

            organizationAccountView.WallOfThisProfile = new ContentStreamView();
            organizationAccountView.WallOfThisProfile.Posts = new List<PostView>();

            var thisViewerKey = myProfile.BasicProfile.ReferenceKey.ToString();
            ContentStreamViewModel wallRetrieved = PublishingService.GetContentStreamByOwnerReferenceKey(thisViewerKey, thisViewerKey);

            if (wallRetrieved.Posts.Count > 0)
            {

                foreach (PostViewModel post in wallRetrieved.Posts)
                {
                    PostView thisPost = new PostView();
                    thisPost.Key = post.Key;
                    thisPost.Author = new CompleteProfileView { BasicProfile = new BasicProfileView { ReferenceKey = post.Author.BasicProfile.ReferenceKey, AccountType = post.Author.BasicProfile.AccountType }, FullName = post.Author.FullName, Description1 = post.Author.Description1, Description2 = post.Author.Description2 };
                    thisPost.TimeStamp = post.TimeStamp.ToString();
                    thisPost.Text = post.Text;
                    thisPost.Likes = post.Likes;
                    thisPost.ILikedIt = post.ILikedIt;

                    thisPost.Comments = new List<CommentView>();
                    foreach (CommentViewModel comment in post.Comments)
                    {
                        CommentView thisComment = new CommentView();
                        thisComment.Key = comment.Key;
                        thisComment.Author = new CompleteProfileView { BasicProfile = new BasicProfileView { ReferenceKey = comment.Author.BasicProfile.ReferenceKey, AccountType = comment.Author.BasicProfile.AccountType }, FullName = comment.Author.FullName, Description1 = comment.Author.Description1, Description2 = comment.Author.Description2 };
                        thisComment.Text = comment.Text;
                        thisComment.ILikedIt = comment.ILikedIt;
                        thisComment.TimeStamp = comment.TimeStamp.ToString();
                        thisComment.Likes = comment.Likes;
                        thisPost.Comments.Add(thisComment);
                    }
                    organizationAccountView.WallOfThisProfile.Posts.Add(thisPost);
                }
            }

            Dictionary<string, string> coordinates = new Dictionary<string, string>();
            coordinates.Add("Partner1", "47.548807,7.587820");
            coordinates.Add("Partner2", "46.948432,7.440461");
            coordinates.Add("Partner3", "46.519595,6.632335");

            return View("OrganizationAccount",organizationAccountView);
        }
        public ActionResult OrganizationAccount(string id)
        {
            CompleteProfile myProfile = (CompleteProfile) Session["myProfile"];

            OrganizationAccountViewModel organizationAccountRetrieved = OrganizationAccountService.GetOrganizationAccountByKey(id);

            OrganizationAccountView organizationAccountView = new OrganizationAccountView();
            organizationAccountView.Profile = new CompleteProfileView { BasicProfile = new BasicProfileView { ReferenceKey=organizationAccountRetrieved.Profile.BasicProfile.ReferenceKey , AccountType= AccountType.OrganizationAccount  }, FullName=organizationAccountRetrieved.Profile.FullName, Description1= organizationAccountRetrieved.Profile.Description1 , Description2=organizationAccountRetrieved.Profile.Description2  };

            organizationAccountView.Email = organizationAccountRetrieved.Email;

            //organizationAccountView.SisterDivisionsOfThisProfile = new List<CompleteProfileView>();
            //organizationAccountView.EmployeesOfThisProfile = Converters.ConvertFromViewModelToView(organizationAccountRetrieved.Employees);
            //organizationAccountView.PartnersOfThisProfile = Converters.ConvertFromViewModelToView(organizationAccountRetrieved.Partners);
            //organizationAccountView.AlliancesOfThisProfile = Converters.ConvertFromViewModelToView(organizationAccountRetrieved.Alliances);

            organizationAccountView.MyGeoLocation = new GeoLocationView() { Latitude=organizationAccountRetrieved.Location.Latitude , Longitude=organizationAccountRetrieved.Location.Longitude };

            organizationAccountView.WallOfThisProfile = new ContentStreamView();
            organizationAccountView.WallOfThisProfile.Posts = new List<PostView>();

            Dictionary<string, string> coordinates = new Dictionary<string, string>();
            coordinates.Add("Partner1", "47.548807,7.587820");
            coordinates.Add("Partner2", "46.948432,7.440461");
            coordinates.Add("Partner3", "46.519595,6.632335");

            organizationAccountView.MyGeoLocation = new GeoLocationView { Latitude = organizationAccountRetrieved.Location.Latitude, Longitude = organizationAccountRetrieved.Location.Longitude };

            organizationAccountView.WallOfThisProfile = new ContentStreamView();
            organizationAccountView.WallOfThisProfile.Posts = new List<PostView>();

            if (User.Identity.Name == organizationAccountRetrieved.Email)
            {
                organizationAccountView.IsThisMyOwnProfile = true;
            }
            else
            {
                PartnershipStateInfoViewModel partnership = OrganizationAccountService.GetPartnershipBetweenOrganizationAccountsByKeys(myProfile.BasicProfile.ReferenceKey.ToString(), organizationAccountRetrieved.Profile.BasicProfile.ReferenceKey );

                switch (partnership.PartnershipAction)
                {
                    case PartnershipAction.Accept:
                        organizationAccountView.ShowPartnershipButtonForThisProfile = true;
                        organizationAccountView.EnablePartnershipButtonForThisProfile = true;
                        organizationAccountView.IsThisProfileAPartnerOfMine = true;
                        organizationAccountView.PartnershipButtonActionNameForThisProfile = "CancelPartnershipWith";
                        organizationAccountView.PartnershipButtonControllerNameForThisProfile = "OrganizationAccounts";
                        organizationAccountView.PartnershipButtonCaptionForThisProfile = "Cancel Partnership";
                        break;

                    case PartnershipAction.Request:

                        if (partnership.Sender.BasicProfile.ReferenceKey  == myProfile.BasicProfile.ReferenceKey.ToString())
                        {
                            //if the viewer is the one that sent the request
                            organizationAccountView.ShowPartnershipButtonForThisProfile = true;
                            organizationAccountView.EnablePartnershipButtonForThisProfile = false;
                            organizationAccountView.isWaitingForPartnershipResponse = true;
                            organizationAccountView.PartnershipButtonActionNameForThisProfile = "CancelRequestTo";
                            organizationAccountView.PartnershipButtonControllerNameForThisProfile = "OrganizationAccounts";
                            organizationAccountView.PartnershipButtonCaptionForThisProfile = "Cancel Request";
                        }
                        else
                        {
                            //if the viewer is the one that received the request
                            organizationAccountView.ShowPartnershipButtonForThisProfile = true;
                            organizationAccountView.EnablePartnershipButtonForThisProfile = false;
                            organizationAccountView.PartnershipButtonActionNameForThisProfile = "Null";
                            organizationAccountView.PartnershipButtonControllerNameForThisProfile = "Null";
                            organizationAccountView.PartnershipButtonCaptionForThisProfile = "Request Received";
                        }

                        break;

                    //case Domain.Friendships.States.FriendshipAction.New :
                    //case Domain.Friendships.States.FriendshipAction.Cancel :
                    //case Domain.Friendships.States.FriendshipAction.Reject :
                    default:
                        organizationAccountView.ShowPartnershipButtonForThisProfile = true;
                        organizationAccountView.EnablePartnershipButtonForThisProfile = true;
                        organizationAccountView.PartnershipButtonActionNameForThisProfile = "RequestPartnershipTo";
                        organizationAccountView.PartnershipButtonControllerNameForThisProfile = "OrganizationAccounts";
                        organizationAccountView.PartnershipButtonCaptionForThisProfile = "Send Request";
                        break;

                }
            }

            var thisViewerKey = myProfile.BasicProfile.ReferenceKey.ToString();

             ContentStreamViewModel wallRetrieved = PublishingService.GetContentStreamByOwnerReferenceKey(id,thisViewerKey);

             if (wallRetrieved.Posts.Count > 0)
             {
                 if (wallRetrieved.Posts != null)
                 {
                     organizationAccountView.WallOfThisProfile.Posts = new List<PostView>();
                     foreach (PostViewModel post in wallRetrieved.Posts)
                     {
                         PostView thisPost = new PostView();
                         thisPost.Key = post.Key;
                         thisPost.Author = new CompleteProfileView { BasicProfile = new BasicProfileView { ReferenceKey = post.Author.BasicProfile.ReferenceKey, AccountType = post.Author.BasicProfile.AccountType }, FullName = post.Author.FullName, Description1 = post.Author.Description1, Description2 = post.Author.Description2 };

                         thisPost.Text = post.Text;
                         thisPost.TimeStamp = post.TimeStamp.ToString();
                         thisPost.Likes = post.Likes;
                         thisPost.Comments = new List<CommentView>();
                         foreach (CommentViewModel comment in post.Comments)
                         {
                             CommentView thisComment = new CommentView();
                             thisComment.Key = comment.Key;
                             thisComment.Author = new CompleteProfileView { BasicProfile = new BasicProfileView { ReferenceKey = comment.Author.BasicProfile.ReferenceKey, AccountType = comment.Author.BasicProfile.AccountType }, FullName = comment.Author.FullName, Description1 = comment.Author.Description1, Description2 = comment.Author.Description2 };

                             thisComment.Text = comment.Text;
                             thisComment.TimeStamp = comment.TimeStamp.ToString();
                             thisComment.Likes = comment.Likes;
                             thisPost.Comments.Add(thisComment);
                         }
                         organizationAccountView.WallOfThisProfile.Posts.Add(thisPost);
                     }
                 }

             }
             else
             {
                 organizationAccountView.WallOfThisProfile = new ContentStreamView();
                 organizationAccountView.WallOfThisProfile.Posts = new List<PostView>();
             }

            organizationAccountView.EmployeesOfThisProfile = Converters.ConvertFromViewModelToView(OrganizationAccountService.GetEmployeesOfOrganizationAccountByKey( organizationAccountRetrieved.Profile.BasicProfile.ReferenceKey));
            organizationAccountView.SisterDivisionsOfThisProfile = Converters.ConvertFromViewModelToView(OrganizationAccountService.GetSisterDivisionsOfOrganizationAccountByKey(organizationAccountRetrieved.Profile.BasicProfile.ReferenceKey ));
            organizationAccountView.PartnersOfThisProfile = Converters.ConvertFromViewModelToView(OrganizationAccountService.GetPartnersOfOrganizationAccountByKey(organizationAccountRetrieved.Profile.BasicProfile.ReferenceKey));
            organizationAccountView.AlliancesOfThisProfile = Converters.ConvertFromViewModelToView(OrganizationAccountService.GetAlliancesOfOrganizationAccountByKey(organizationAccountRetrieved.Profile.BasicProfile.ReferenceKey));

            return View(organizationAccountView);
        }
示例#35
0
 public PostViewTestBase()
 {
     var postViewRepostioryStub = new InMemoryViewRepository<PostItem>();
     PostView = new PostView(postViewRepostioryStub);
 }
示例#36
0
        public ActionResult Index()
        {
            CompleteProfile  myProfile = (CompleteProfile)Session["myProfile"];

            UserAccountView accountView = new UserAccountView();

            accountView.IsThisMyOwnProfile = true;
            //accountView.WallOfThisProfile.Posts = new List<PostView>();
            //accountView.WallOfThisProfile.Tweets = new List<TweetView>();
            //accountView.WallOfThisProfile.Retweets = new List<RetweetView>();

            CompleteProfileView completeProfile = new CompleteProfileView();
            BasicProfileView basicProfile = new BasicProfileView();
            completeProfile.BasicProfile = basicProfile;
            basicProfile.ReferenceKey = myProfile.BasicProfile.ReferenceKey.ToString();
            basicProfile.AccountType = AccountType.UserAccount;
            completeProfile.FullName = myProfile.FullName;
            completeProfile.Description1 = myProfile.Description1;
            completeProfile.Description2 = myProfile.Description2;

            accountView.Profile = completeProfile;

            accountView.EmailOfThisProfile = User.Identity.Name;

            accountView.FoldersOfThisProfile = new Dictionary<string, string>();
            accountView.WallOfThisProfile = new ContentStreamView();
            accountView.WallOfThisProfile.Posts = new List<PostView>();
            accountView.WallOfThisProfile.Tweets = new List<TweetView>();
            accountView.WallOfThisProfile.Retweets = new List<RetweetView>();

            accountView.WorkContactsOfThisProfile = Converters.ConvertFromViewModelToView(UserAccountService.GetWorkContactsOfUserAccountByKey( myProfile.BasicProfile.ReferenceKey.ToString() ));
            accountView.PartnershipContactsOfThisProfile =Converters.ConvertFromViewModelToView(UserAccountService.GetPartnershipContactsOfUserAccountByKey( myProfile.BasicProfile.ReferenceKey.ToString()));
            accountView.GroupsOfThisProfile = Converters.ConvertFromViewModelToView(UserAccountService.GetGroupsOfUserAccountByKey(myProfile.BasicProfile.ReferenceKey.ToString()));

            //Im the owner and the viewer of the wall
            var thisViewerKey = myProfile.BasicProfile.ReferenceKey.ToString();
            ContentStreamViewModel wallRetrieved = PublishingService.GetContentStreamAsNewsfeed(thisViewerKey,thisViewerKey);
            CompleteProfileViewModel myOrganizationAccount = OrganizationAccountService.GetOrganizationAccountProfileByEmployeeUserAccountKey(thisViewerKey);
            accountView.OrganizationAccountOfThisProfile = new CompleteProfileView { BasicProfile = new BasicProfileView  { ReferenceKey=myOrganizationAccount.BasicProfile.ReferenceKey, AccountType=myOrganizationAccount.BasicProfile.AccountType    }, FullName=myOrganizationAccount.FullName, Description1=myOrganizationAccount.Description1 , Description2=myOrganizationAccount.Description2  };
               // accountView.WallOfThisProfile = new ContentStreamView();
               // accountView.WallOfThisProfile.Posts = new List<PostView>();
            if (wallRetrieved.Posts.Count >0)
            {

                foreach (PostViewModel post in wallRetrieved.Posts)
                {
                    PostView thisPost = new PostView();
                    thisPost.Key = post.Key;
                    thisPost.Author = new CompleteProfileView { BasicProfile = new BasicProfileView { ReferenceKey=post.Author.BasicProfile.ReferenceKey  , AccountType= post.Author.BasicProfile.AccountType  }, FullName=post.Author.FullName, Description1= post.Author.Description1 , Description2= post.Author.Description2  };
                    thisPost.PublishDateTime = post.PublishDateTime;
                    thisPost.Text = post.Text;
                    thisPost.Likes = post.Likes;
                    thisPost.ILikedIt = post.ILikedIt;

                    thisPost.Comments = new List<CommentView>();
                    foreach (CommentViewModel comment in post.Comments)
                    {
                        CommentView thisComment = new CommentView();
                        thisComment.Key = comment.Key;
                        thisComment.Author = new CompleteProfileView { BasicProfile = new BasicProfileView { ReferenceKey = comment.Author.BasicProfile.ReferenceKey, AccountType = comment.Author.BasicProfile.AccountType }, FullName = comment.Author.FullName, Description1 = comment.Author.Description1, Description2 = comment.Author.Description2 };
                        thisComment.Text = comment.Text;
                        thisComment.PublishDateTime = comment.PublishDateTime;
                        thisComment.Likes = comment.Likes;
                        thisComment.ILikedIt = comment.ILikedIt;
                        thisPost.Comments.Add(thisComment);
                    }

                    accountView.WallOfThisProfile.Posts.Add(thisPost);
                }
            }

            if (wallRetrieved.Tweets.Count > 0)
            {
                foreach (TweetViewModel tweet in wallRetrieved.Tweets)
                {
                    TweetView thisTweet = new TweetView();

                    thisTweet.Key = tweet.Key;
                    thisTweet.Text = tweet.Text;
                    thisTweet.PublishDateTime = tweet.PublishDateTime;
                    thisTweet.Author = new CompleteProfileView { BasicProfile = new BasicProfileView { ReferenceKey = tweet.Author.BasicProfile.ReferenceKey, AccountType = tweet.Author.BasicProfile.AccountType }, FullName = tweet.Author.FullName, Description1 = tweet.Author.Description1, Description2 = tweet.Author.Description2 };

                    accountView.WallOfThisProfile.Tweets.Add(thisTweet);
                }
            }

            if (wallRetrieved.Retweets.Count > 0)
            {
                foreach (RetweetViewModel retweet in wallRetrieved.Retweets)
                {
                    RetweetView thisRetweet = new RetweetView();

                    thisRetweet.RetweetKey = retweet.RetweetKey;
                    thisRetweet.TweetKey = retweet.TweetKey;

                    thisRetweet.Text = retweet.Text;
                    thisRetweet.PublishDateTime = retweet.PublishDateTime;
                    thisRetweet.TweetPublishDateTime = retweet.TweetPublishDateTime.ToString();

                    thisRetweet.RetweetAuthor = new CompleteProfileView { BasicProfile = new BasicProfileView { ReferenceKey = retweet.RetweetAuthor.BasicProfile.ReferenceKey, AccountType = retweet.RetweetAuthor.BasicProfile.AccountType }, FullName = retweet.RetweetAuthor.FullName, Description1 = retweet.RetweetAuthor.Description1, Description2 = retweet.RetweetAuthor.Description2 };

                    thisRetweet.TweetAuthor = new CompleteProfileView { BasicProfile = new BasicProfileView { ReferenceKey = retweet.TweetAuthor.BasicProfile.ReferenceKey, AccountType = retweet.TweetAuthor.BasicProfile.AccountType }, FullName = retweet.TweetAuthor.FullName, Description1 = retweet.TweetAuthor.Description1, Description2 = retweet.TweetAuthor.Description2 };

                    accountView.WallOfThisProfile.Retweets.Add(thisRetweet);
                }
            }

            accountView.WallOfThisProfile.PublishedItems = new List<ISortingCapable>();

            accountView.WallOfThisProfile.PublishedItems.AddRange(accountView.WallOfThisProfile.Posts);
            accountView.WallOfThisProfile.PublishedItems.AddRange(accountView.WallOfThisProfile.Tweets);
            accountView.WallOfThisProfile.PublishedItems.AddRange(accountView.WallOfThisProfile.Retweets);

             accountView.WallOfThisProfile.PublishedItems= accountView.WallOfThisProfile.PublishedItems.OrderByDescending(x => x.PublishDateTime).ToList();

             CompleteProfileView groupView = new CompleteProfileView() { BasicProfile = new BasicProfileView() { ReferenceKey = "ACBCCE0E-7C9F-4386-99AA-1458F308EBB0", AccountType = AccountType.Group }, FullName = "Electric Providers Group" };
             CompleteProfileView coworkerView = new CompleteProfileView() { BasicProfile = new BasicProfileView() { ReferenceKey = "BCBCCE0E-7C9F-4386-98AA-1458F308E205", AccountType = AccountType.UserAccount  }, FullName = "Larry Page" };
             CompleteProfileView partnerView = new CompleteProfileView() { BasicProfile = new BasicProfileView() { ReferenceKey = "BCBCCE0E-7C9F-4386-98AA-1458F308E203", AccountType = AccountType.UserAccount }, FullName = "Allie Opper" };

             accountView.GroupSuggestion = groupView;
             accountView.PartnerSuggestion = partnerView;
             accountView.CoworkerSuggestion = coworkerView;

            return View("Newsfeed",accountView);
        }
示例#37
0
        public ActionResult UserAccount(string id)
        {
            CompleteProfile  myProfile = (CompleteProfile ) Session["myProfile"];

            UserAccountViewModel accountRetrieved = UserAccountService.GetUserAccountByKey(id);

            UserAccountView accountView = new UserAccountView();

            accountView.Profile = new CompleteProfileView { BasicProfile = new BasicProfileView { ReferenceKey = accountRetrieved.Profile.BasicProfile.ReferenceKey  , AccountType = AccountType.UserAccount  }, FullName= accountRetrieved.Profile.FullName  , Description1=accountRetrieved.Profile.Description1 , Description2=accountRetrieved.Profile.Description2   };

            accountView.EmailOfThisProfile = accountRetrieved.Email;

            accountView.FoldersOfThisProfile = new Dictionary<string, string>();
            accountView.WallOfThisProfile = new ContentStreamView();
            accountView.WallOfThisProfile.Posts = new List<PostView>();
            accountView.WallOfThisProfile.Tweets = new List<TweetView>();
            accountView.WallOfThisProfile.Retweets = new List<RetweetView>();

            if (User.Identity.Name == accountRetrieved.Email)
            {
                accountView.IsThisMyOwnProfile = true;
            }
            else
            {
                FriendshipStateInfoViewModel friendship = UserAccountService.GetFriendshipBetweenUserAccountsByKeys(myProfile.BasicProfile.ReferenceKey.ToString() , accountRetrieved.Profile.BasicProfile.ReferenceKey );

                switch (friendship.FriendshipAction)
                {
                    case FriendshipAction.Accept :
                        accountView.ShowFriendshipButtonForThisProfile = true;
                        accountView.EnableFriendshipButtonForThisProfile = true;
                        accountView.IsThisProfileAFriendOfMine = true;
                        accountView.FriendshipButtonActionNameForThisProfile = "CancelFriendshipWith";
                        accountView.FriendshipButtonControllerNameForThisProfile = "UserAccounts";
                        accountView.FriendshipButtonCaptionForThisProfile = "Cancel Friendship";
                        break;

                    case FriendshipAction.Request :

                        if (friendship.Sender.BasicProfile.ReferenceKey == myProfile.BasicProfile.ReferenceKey.ToString())
                        {
                            //if the viewer is the one that sent the request
                            accountView.ShowFriendshipButtonForThisProfile = true;
                            accountView.EnableFriendshipButtonForThisProfile = false;
                            accountView.isWaitingForFriendshipResponse = true;
                            accountView.FriendshipButtonActionNameForThisProfile = "CancelRequestTo";
                            accountView.FriendshipButtonControllerNameForThisProfile = "UserAccounts";
                            accountView.FriendshipButtonCaptionForThisProfile = "Cancel Request";
                        }
                        else
                        {
                            //if the viewer is the one that received the request
                            accountView.ShowFriendshipButtonForThisProfile = true;
                            accountView.EnableFriendshipButtonForThisProfile = false;
                            accountView.FriendshipButtonActionNameForThisProfile = "Null";
                            accountView.FriendshipButtonControllerNameForThisProfile = "Null";
                            accountView.FriendshipButtonCaptionForThisProfile = "Request Received";
                        }

                        break;

                    //case Domain.Friendships.States.FriendshipAction.New :
                    //case Domain.Friendships.States.FriendshipAction.Cancel :
                    //case Domain.Friendships.States.FriendshipAction.Reject :
                    default :
                        accountView.ShowFriendshipButtonForThisProfile = true;
                        accountView.EnableFriendshipButtonForThisProfile = true;
                        accountView.FriendshipButtonActionNameForThisProfile = "RequestFriendshipTo";
                        accountView.FriendshipButtonControllerNameForThisProfile = "UserAccounts";
                        accountView.FriendshipButtonCaptionForThisProfile = "Send Request";
                        break;

                }
            }

            var thisViewerKey = myProfile.BasicProfile.ReferenceKey.ToString();
            ContentStreamViewModel wallRetrieved = PublishingService.GetContentStreamAsProfileWall(id,thisViewerKey);

            if (wallRetrieved.Posts.Count>0)
            {
                if (wallRetrieved.Posts != null)
                {
                    accountView.WallOfThisProfile.Posts = new List<PostView>();
                    foreach (PostViewModel post in wallRetrieved.Posts)
                    {
                        PostView thisPost = new PostView();
                        thisPost.Key = post.Key;
                        thisPost.Author = new CompleteProfileView { BasicProfile = new BasicProfileView { ReferenceKey=post.Author.BasicProfile.ReferenceKey , AccountType=post.Author.BasicProfile.AccountType  }, FullName= post.Author.FullName , Description1= post.Author.Description1 , Description2= post.Author.Description2  };

                        thisPost.Text = post.Text;
                        thisPost.PublishDateTime = post.PublishDateTime;
                        thisPost.Likes = post.Likes;
                        thisPost.ILikedIt = post.ILikedIt;
                        thisPost.Comments = new List<CommentView>();
                        foreach (CommentViewModel comment in post.Comments)
                        {
                            CommentView thisComment = new CommentView();
                            thisComment.Key = comment.Key;
                            thisComment.Author = new CompleteProfileView { BasicProfile = new BasicProfileView { ReferenceKey = comment.Author.BasicProfile.ReferenceKey, AccountType = comment.Author.BasicProfile.AccountType }, FullName = comment.Author.FullName, Description1 = comment.Author.Description1, Description2 = comment.Author.Description2 };

                            thisComment.Text = comment.Text;
                            thisComment.ILikedIt = comment.ILikedIt;
                            thisComment.PublishDateTime = comment.PublishDateTime;
                            thisComment.Likes = comment.Likes;
                            thisPost.Comments.Add(thisComment);
                        }
                        accountView.WallOfThisProfile.Posts.Add(thisPost);
                    }
                }

            }

            if (wallRetrieved.Tweets.Count > 0)
            {
                foreach (TweetViewModel tweet in wallRetrieved.Tweets)
                {
                    TweetView thisTweet = new TweetView();

                    thisTweet.Key = tweet.Key;
                    thisTweet.Text = tweet.Text;
                    thisTweet.PublishDateTime = tweet.PublishDateTime;
                    thisTweet.Author = new CompleteProfileView { BasicProfile = new BasicProfileView { ReferenceKey = tweet.Author.BasicProfile.ReferenceKey, AccountType = tweet.Author.BasicProfile.AccountType }, FullName = tweet.Author.FullName, Description1 = tweet.Author.Description1, Description2 = tweet.Author.Description2 };

                    accountView.WallOfThisProfile.Tweets.Add(thisTweet);
                }
            }

            if (wallRetrieved.Retweets.Count > 0)
            {
                foreach (RetweetViewModel retweet in wallRetrieved.Retweets)
                {
                    RetweetView thisRetweet = new RetweetView();

                    thisRetweet.RetweetKey = retweet.RetweetKey;
                    thisRetweet.TweetKey = retweet.TweetKey;

                    thisRetweet.Text = retweet.Text;
                    thisRetweet.PublishDateTime = retweet.PublishDateTime;
                    thisRetweet.TweetPublishDateTime = retweet.TweetPublishDateTime.ToString();

                    thisRetweet.RetweetAuthor = new CompleteProfileView { BasicProfile = new BasicProfileView { ReferenceKey = retweet.RetweetAuthor.BasicProfile.ReferenceKey, AccountType = retweet.RetweetAuthor.BasicProfile.AccountType }, FullName = retweet.RetweetAuthor.FullName, Description1 = retweet.RetweetAuthor.Description1, Description2 = retweet.RetweetAuthor.Description2 };

                    thisRetweet.TweetAuthor = new CompleteProfileView { BasicProfile = new BasicProfileView { ReferenceKey = retweet.TweetAuthor.BasicProfile.ReferenceKey, AccountType = retweet.TweetAuthor.BasicProfile.AccountType }, FullName = retweet.TweetAuthor.FullName, Description1 = retweet.TweetAuthor.Description1, Description2 = retweet.TweetAuthor.Description2 };

                    accountView.WallOfThisProfile.Retweets.Add(thisRetweet);
                }
            }

            accountView.WorkContactsOfThisProfile = Converters.ConvertFromViewModelToView(UserAccountService.GetWorkContactsOfUserAccountByKey(accountRetrieved.Profile.BasicProfile.ReferenceKey  ));
            accountView.PartnershipContactsOfThisProfile = Converters.ConvertFromViewModelToView(UserAccountService.GetPartnershipContactsOfUserAccountByKey(accountRetrieved.Profile.BasicProfile.ReferenceKey));
            accountView.GroupsOfThisProfile = Converters.ConvertFromViewModelToView(UserAccountService.GetGroupsOfUserAccountByKey(accountRetrieved.Profile.BasicProfile.ReferenceKey));

            accountView.WallOfThisProfile.PublishedItems = new List<ISortingCapable>();

            accountView.WallOfThisProfile.PublishedItems.AddRange(accountView.WallOfThisProfile.Posts);
            accountView.WallOfThisProfile.PublishedItems.AddRange(accountView.WallOfThisProfile.Tweets);
            accountView.WallOfThisProfile.PublishedItems.AddRange(accountView.WallOfThisProfile.Retweets);

            accountView.WallOfThisProfile.PublishedItems = accountView.WallOfThisProfile.PublishedItems.OrderByDescending(x => x.PublishDateTime).ToList();

            return View("MyWall", accountView);
        }
示例#38
0
 public PostViewModel(PostView view)
     : base(view.Dispatcher)
 {
     Comments = new ObservableCollection<Comment>();
 }