public ActionResult Create(PostViewModel model) { if (!this.ModelState.IsValid) { return this.View(model); } var categoryPostToAdd = this.postCategory.EnsureCategory(model.Category); var post = new Post() { IsVideo = model.IsVideo, SharedUrl = model.SharedUrl, Title = model.Title, Category = categoryPostToAdd, AuthorId = this.User.Identity.GetUserId() }; if (post.IsVideo) { var videoId = post.SharedUrl.Split('='); post.SharedUrl = @"https://www.youtube.com/embed/" + videoId[videoId.Count() - 1]; } categoryPostToAdd.Posts.Add(post); this.posts.Create(post); this.TempData["Notification"] = "Post Created!"; return this.Redirect("/"); }
public ActionResult AddCategoryToPost(string postid) { PostViewModel model = new PostViewModel(); model.ID = postid; model.Categories = _blogRepository.GetCategories(); return View(model); }
public ActionResult Create(PostViewModel post, HttpPostedFileBase upload) { if (this.ModelState.IsValid) { var postToAdd = new Post { Title = post.Title, Content = post.Content, CreatorId = this.User.Identity.GetUserId() }; if (upload != null && upload.ContentLength > 0) { var photo = new Data.Models.File { FileName = Path.GetFileName(upload.FileName), FileType = FileType.Photo, ContentType = upload.ContentType }; using (var reader = new BinaryReader(upload.InputStream)) { photo.Content = reader.ReadBytes(upload.ContentLength); } postToAdd.Photo = photo; } this.posts.Add(postToAdd); } return this.Redirect(this.Request.UrlReferrer.ToString()); }
public ActionResult Create(PostViewModel post) { var dto = post.ToDTO(); postService.Create(dto); return RedirectToAction("Index"); }
public ActionResult Destroy([DataSourceRequest]DataSourceRequest request, PostViewModel model) { var post = this.posts .GetById(model.Id); this.posts.Delete(post); this.posts.SaveChanges(); return this.Json(new[] { model }.ToDataSourceResult(request, this.ModelState)); }
public JsonResult Destroy([DataSourceRequest] DataSourceRequest request, PostViewModel model) { var dbModel = this.posts.GetById(model.Id); this.posts.Delete(dbModel); this.posts.SaveChanges(); return this.Json(new[] { model }, JsonRequestBehavior.AllowGet); }
public MainContext() { _activeTasks = new ObservableCollection<Guid>(); _activeTasks.CollectionChanged += ActiveTasksOnCollectionChanged; _databaseConnectionViewModel = new DatabaseConnectionViewModel(this); _postViewModel = new PostViewModel(this); _postMetaViewModel = new PostMetaViewModel(this); _taxonomyTermRelationViewModel = new TaxonomyTermRelationViewModel(this); }
public ActionResult Destroy([DataSourceRequest]DataSourceRequest request, PostViewModel inputPost) { if (inputPost != null) //ModelState.IsValid && { this.posts.Delete(inputPost.Id); this.posts.SaveChanges(); } return this.Json(new[] { inputPost }.ToDataSourceResult(request, this.ModelState)); }
public ActionResult Destroy([DataSourceRequest]DataSourceRequest request, PostViewModel model) { if (model != null && ModelState.IsValid) { this.Data.Posts.Delete(model.Id); this.Data.SaveChanges(); } return this.Json(new[] { model }.ToDataSourceResult(request, this.ModelState)); }
public ActionResult Comment(PostViewModel model) { var user = this.User.Identity.GetUserId(); var comment = new Comment { Content = model.NewComment.Content, AuthorId = user, PostId = model.Id }; this.postComments.Add(comment); return this.Redirect(string.Format("/Post/{0}", model.Id)); }
public ActionResult Update([DataSourceRequest]DataSourceRequest request, PostViewModel model) { if (model != null && ModelState.IsValid) { var postDbModel = this.posts.GetById(model.Id); postDbModel.Title = model.Title; postDbModel.Content = model.Content; this.posts.SaveChanges(); } return this.Json(new[] { model }.ToDataSourceResult(request, this.ModelState)); }
public ActionResult Index() { var post = BuildSamplePost(); var errors = GetErrorsInPost(post); var viewModel = new PostViewModel(post) { Errors = errors }; return View("Show", viewModel); }
public ActionResult Update([DataSourceRequest]DataSourceRequest request, PostViewModel inputPost) { if (inputPost != null) //ModelState.IsValid && { var post = this.posts.GetById(inputPost.Id); //Mapper.Map(inputPost, post); post.Title = inputPost.Title; post.Content = inputPost.Content; this.posts.SaveChanges(); } return this.Json(new[] { inputPost }.ToDataSourceResult(request, this.ModelState)); }
public ActionResult Create([DataSourceRequest]DataSourceRequest request, PostViewModel model) { if (model != null && ModelState.IsValid) { var postDbModel = new Post(); postDbModel.Title = model.Title; postDbModel.Content = model.Content; postDbModel.AuthorId = this.User.Identity.GetUserId(); this.posts.Add(postDbModel); this.posts.SaveChanges(); } return this.Json(new[] { model }.ToDataSourceResult(request, this.ModelState)); }
public ActionResult Create(int userId, PostViewModel postVM) { if (ModelState.IsValid) { User u = _userRepository.GetById(userId); var post = new Post() { PostDate = DateTime.Today, Text = postVM.Text }; u.Posts.Add(post); _userRepository.Save(); return RedirectToAction("Index", new { userId = u.Id }); } else { return View(); } }
public ActionResult Update([DataSourceRequest]DataSourceRequest request, PostViewModel model) { if (model != null && ModelState.IsValid) { var post = this.Data.Posts.GetById(model.Id); // tinymce shit post.Content = Request.Params["title"]; post.Title = model.Title; this.Data.SaveChanges(); } // return result to kendo return this.Json(new[] { model }.ToDataSourceResult(request, this.ModelState)); }
public ActionResult Create([DataSourceRequest]DataSourceRequest request, PostViewModel inputPost) { // invalid date from input post so I add it manually inputPost.CreatedOn = DateTime.Now; if (ModelState.IsValid && inputPost != null) { var dbPostModel = Mapper.Map<Post>(inputPost); this.posts.Add(dbPostModel); this.posts.SaveChanges(); inputPost.Id = dbPostModel.Id; } return this.Json(new[] { inputPost }.ToDataSourceResult(request, this.ModelState)); }
public JsonResult Update([DataSourceRequest] DataSourceRequest request, PostViewModel model) { var dbModel = this.posts.GetById(model.Id); if (model != null && this.ModelState.IsValid) { dbModel.Title = model.Title; dbModel.Content = model.Content; this.posts.Update(dbModel); this.posts.SaveChanges(); model.ModifiedOn = dbModel.ModifiedOn; } return this.Json((new[] { model }.ToDataSourceResult(request, this.ModelState)), JsonRequestBehavior.AllowGet); }
public ActionResult Create([DataSourceRequest]DataSourceRequest request, PostViewModel model) { if (model != null) { var post = new Post() { Title = model.Title, // tinymce shit Content = Request.Params["title"], Author = this.UserProfile, }; this.Data.Posts.Add(post); this.Data.SaveChanges(); model.Id = post.Id; } return this.Json(new[] { model }.ToDataSourceResult(request, this.ModelState)); }
public async Task<IActionResult> New(PostViewModel model) { ViewBag.Title = "New Post"; if(ModelState.IsValid) { var post = new Post { Title = model.Title, Content = model.Content, UserId = "1", Slug = model.Slug, Published = model.Published, PublishDateTime = model.PublishDateTime }; await m_postService.CreatePostAsync(post); } return View("NewEdit", model); }
public PostViewModel Create(PostViewModel model) { if (model != null && this.ModelState.IsValid) { var post = new Post() { Title = model.Title, Content = model.Content, AuthorId = this.User.Identity.GetUserId(), CreatedOn = DateTime.Now }; this.posts.Add(post); this.posts.SaveChanges(); var mapped = Mapper.Map<PostViewModel>(post); mapped.Id = post.Id; return mapped; } return null; }
public ActionResult Posts_Create([DataSourceRequest]DataSourceRequest request, PostViewModel post) { var newId = 0; if (ModelState.IsValid) { var entity = new Post { Title = post.Title, Content = post.Content, AuthorId = this.User.Identity.GetUserId() }; this.posts.Add(entity); this.posts.SaveChanges(); newId = entity.Id; } var postToDisplay = this.posts.All().Project() .To<PostViewModel>() .FirstOrDefault(x => x.Id == newId); return Json(new[] { postToDisplay }.ToDataSourceResult(request, ModelState)); }
public ActionResult AddCategoryToPost(PostViewModel model) { var post = _blogRepository.GetPostById(model.ID); var postCats = _blogRepository.GetPostCategories(post); List<string> pCatIds = new List<string>(); foreach (var pCat in postCats) { pCatIds.Add(pCat.id); } var newCats = model.Categories.Where(x => x.Checked == true).ToList(); List<string> nCatIds = new List<string>(); foreach (var pCat in newCats) { nCatIds.Add(pCat.id); } if (!pCatIds.SequenceEqual(nCatIds)) { foreach (var pCat in postCats) { _blogRepository.RemovePostCategories(model.ID, pCat.id); } foreach (var cat in model.Categories) { PostCategory postCategory = new PostCategory(); if (cat.Checked == true) { postCategory.PostId = model.ID; postCategory.CategoryId = cat.id; postCategory.Checked = true; _blogRepository.AddPostCategories(postCategory); } } _blogRepository.Save(); } return RedirectToAction("EditPost", new { slug = post.UrlSeo }); }
public TestModule() { // Generates any static page given all site content Post["/static"] = x => { var siteContent = new ContentViewModel { GeneratedUrl = GeneratedUrl, PostsInCategory = PostsInCategory, AllCategories = Categories, Posts = Posts, PostsPaged = PostsPaged, Pages = Pages, PostsGroupedByYearThenMonth = PostsGroupedByYearThenMonth, HasPreviousPage = HasPreviousPage, HasNextPage = HasNextPage, NextPage = PageNumber + 1, PreviousPage = PageNumber - 1, MonthYearList = MonthYear, GeneratedDate = GeneratedDate, Category = Category, Drafts = Drafts, Published = Published }; return View[StaticFile, siteContent]; }; // Generates an actual post based on the Markdown content // with a SiteContent property for access to everything Post["/compose"] = x => { dynamic result = new PostViewModel { Drafts = Drafts, Posts = Posts, Pages = Pages, GeneratedUrl = GeneratedUrl, PostContent = Data.Content, PostDate = Data.Date, Layout = Data.Layout, Title = Data.Title, GeneratedDate = GeneratedDate, Url = Data.Url, AllCategories = Categories, Categories = Data.Categories.Select(c => new Category { Name = c }).ToList(), Keywords = Data.Keywords, MonthYearList = MonthYear, Author = Data.Author, Email = Data.Email, Settings = Settings, Series = Data.Series, MetaDescription = Data.MetaDescription, Published = Data.Published, ContentExcerpt = Data.ContentExcerpt, }; result.Banana = "WOW!"; return View[result.Layout, result]; }; Post["/rss"] = x => Response.AsRSS(Posts.Take(Settings.FeedSize), Settings.BlogTitle, Settings.SiteUrl, StaticFile); Post["/atom"] = x => Response.AsAtom(Posts.Take(Settings.FeedSize), Settings.BlogTitle, Settings.SiteUrl, Settings.Author, Settings.Email, StaticFile); Post["/sitemap"] = x => { var publishedPosts = Posts.Where(post => post.Published == Published.True); return Response.AsSiteMap(publishedPosts, Settings.SiteUrl); }; }
public ActionResult CreatePost(PostViewModel inputPost) { var userId = TempData["userId"].ToString(); TempData["userId"] = userId; if (inputPost == null || string.IsNullOrEmpty(userId) || !CheckIfTwoUsersAreFriends(this.User.Identity.GetUserId(), userId)) { return new EmptyResult(); } var loggedUserId = this.User.Identity.GetUserId(); var post = new Post() { FromId = loggedUserId, ToId = userId, Content = inputPost.Content }; this.Data.Posts.Add(post); this.Data.SaveChanges(); ViewBag.areFriends = CheckIfTwoUsersAreFriends(this.User.Identity.GetUserId(), userId); var postToView = this.Data.Posts.All() .Project() .To<PostViewModel>() .FirstOrDefault(p => p.Id == post.Id); return PartialView("_DisplayPost", postToView); }
public TestModule() { // Generates the post from Markdown Get["/post/{file}"] = x => View[(string) x.file]; // Generates any static page given all site content Post["/static"] = x => { var siteContent = new ContentViewModel { GeneratedUrl = GeneratedUrl, PostsInCategory = PostsInCategory, Categories = Categories, Posts = Posts, PostsPaged = PostsPaged, PostsGroupedByYearThenMonth = PostsGroupedByYearThenMonth, HasPreviousPage = HasPreviousPage, HasNextPage = HasNextPage, NextPage = PageNumber + 1, PreviousPage = PageNumber - 1, MonthYearList = MonthYear, GeneratedDate = GeneratedDate, Category = Category }; return View[StaticFile, siteContent]; }; // Generates an actual post based on the Markdown content // with a SiteContent property for access to everything Post["/compose"] = x => { var result = new PostViewModel { GeneratedUrl = GeneratedUrl, PostContent = Data.Content, PostDate = Data.Date, Layout = Data.Layout, Title = Data.Title, GeneratedDate = GeneratedDate, Url = Data.Url, Categories = Data.Categories.Select(c => new Category {Name = c}).ToList(), MonthYearList = MonthYear, Author = Data.Author, Email = Data.Email, Settings = Settings, Series = Data.Series, MetaDescription = Data.MetaDescription }; return View[result.Layout, result]; }; Post["/rss"] = x => { return this.Response.AsRSS(PostsPaged, Settings.BlogTitle, Settings.SiteUrl, StaticFile); }; Post["/sitemap"] = x => { return this.Response.AsSiteMap(Posts, Settings.SiteUrl); }; }
public void DeserializeFromJson_WithNestedObject_ShouldWork() { var json = (JsDictionary<string, object>) Json.Parse( @" { ""Title"": ""Test Title"", ""Content"": ""Test Text"", ""Author"": { ""Email"": ""*****@*****.**"", ""Id"": 2 } } "); var post = new PostViewModel(); post.SetFromJSON(json, null); Assert.AreEqual(post.Title, "Test Title"); Assert.AreEqual(post.Content, "Test Text"); Assert.AreEqual(post.Author.Id, 2); Assert.AreEqual(post.Author.Email, "*****@*****.**"); }
public void DeserializeFromJson_WithNestedObject_WithExistingNestedObjectReference_ShouldPreserveObjectIdentity() { var json = (JsDictionary<string, object>) Json.Parse( @" { ""Title"": ""Test Title"", ""Content"": ""Test Text"", ""Author"": { ""Email"": ""*****@*****.**"", ""Id"": 2 } } "); var post = new PostViewModel(); var originalAuthor = new UserViewModel {Id = 3, Email = "*****@*****.**"}; var anotherAuthor = new UserViewModel {Id = 2, Email = "*****@*****.**"}; post.Author = originalAuthor; post.SetFromJSON(json, null); Assert.AreEqual(post.Title, "Test Title"); Assert.AreEqual(post.Content, "Test Text"); Assert.AreEqual(post.Author.Id, 2); Assert.AreEqual(post.Author.Email, "*****@*****.**"); Assert.IsTrue(post.Author == originalAuthor, "identity equality check - ensure any existing nested object's identity is preserved by FromJson, otherwise existing event bindings to be lost."); Assert.IsTrue(post.Author != anotherAuthor, "identity equality check - verify that 2 instances which are known to have different identities are marked as not equal"); }
public static OrganizationAccountViewModel ConvertOrganizationAccountToViewModel(OrganizationAccount organizationAccount) { OrganizationAccountViewModel organizationAccountView = new OrganizationAccountViewModel(); //organizationAccountView.Key = organizationAccount.Key.ToString(); //organizationAccountView.Name = organizationAccount.Name; //organizationAccountView.Description = organizationAccount.Description; organizationAccountView.Profile = new CompleteProfileViewModel { BasicProfile = new BasicProfileViewModel { ReferenceKey=organizationAccount.Key.ToString(), AccountType= Domain._Base.Accounts.AccountType.OrganizationAccount }, FullName=organizationAccount.Name , Description1= organizationAccount.Organization.Name , Description2= organizationAccount.Organization.Name }; organizationAccountView.Organization = new CompleteProfileViewModel { BasicProfile = new BasicProfileViewModel { ReferenceKey=organizationAccount.Organization.Key.ToString(), AccountType= Domain._Base.Accounts.AccountType.Organization }, FullName=organizationAccount.Organization.Name, Description1=organizationAccount.Description, Description2=organizationAccount.Organization.Description }; organizationAccountView.Email = organizationAccount.Email; organizationAccountView.Location = new GeoLocationViewModel { Latitude = organizationAccount.Location.Latitude.ToString(), Longitude = organizationAccount.Location.Longitude.ToString() }; organizationAccountView.Partners = new List<CompleteProfileViewModel>(); organizationAccountView.Alliances = new List<CompleteProfileViewModel>(); organizationAccountView.Employees = new List<CompleteProfileViewModel>(); organizationAccountView.Wall = new ContentStreamViewModel(); organizationAccountView.Wall.Posts = new List<PostViewModel>(); if (organizationAccount.Employees != null) { foreach (var subitem in organizationAccount.Employees) { organizationAccountView.Employees.Add(new CompleteProfileViewModel { BasicProfile = new BasicProfileViewModel { ReferenceKey=subitem.Key.ToString(), AccountType= Domain._Base.Accounts.AccountType.UserAccount }, FullName= subitem.User.FirstName + " " + subitem.User.LastName , Description1= subitem.OrganizationAccount.Name , Description2=subitem.OrganizationAccount.Organization.Name }); } } if (organizationAccount.AllianceMemberships.Count>0) { foreach (var subitem in organizationAccount.AllianceMemberships) { organizationAccountView.Alliances.Add(new CompleteProfileViewModel { BasicProfile = new BasicProfileViewModel { ReferenceKey=subitem.AllianceRequested.Key.ToString(), AccountType= Domain._Base.Accounts.AccountType.Alliance }, FullName=subitem.AllianceRequested.Name , Description1=subitem.AllianceRequested.Description }); } } if (organizationAccount.PartnershipsReceived.Count>0) { foreach (var subitem in organizationAccount.PartnershipsReceived) { organizationAccountView.Partners.Add(new CompleteProfileViewModel { BasicProfile = new BasicProfileViewModel { ReferenceKey=subitem.Sender.Key.ToString(), AccountType= Domain._Base.Accounts.AccountType.OrganizationAccount }, FullName=subitem.Sender.Name , Description1= subitem.Sender.Description }); } } if (organizationAccount.PartnershipsRequested.Count>0) { foreach (var subitem in organizationAccount.PartnershipsRequested) { organizationAccountView.Partners.Add(new CompleteProfileViewModel { BasicProfile = new BasicProfileViewModel { ReferenceKey=subitem.Receiver.Key.ToString(), AccountType= Domain._Base.Accounts.AccountType.OrganizationAccount }, FullName= subitem.Receiver.Name, Description1= subitem.Receiver.Description }); } } if (organizationAccount.Wall.Posts.Count>0) { foreach (var post in organizationAccount.Wall.Posts) { PostViewModel thisPost = new PostViewModel(); thisPost.Key = post.Key.ToString(); //postView.AuthorKey = post.Author.ReferenceKey.ToString(); //postView.AuthorName = SecurityRepository.GetCompleteProfile(post.Author.ReferenceKey); var postAuthorProfile = SecurityRepository.GetCompleteProfile(post.Author); thisPost.Author = new CompleteProfileViewModel { BasicProfile = new BasicProfileViewModel { ReferenceKey = postAuthorProfile.BasicProfile.ReferenceKey.ToString(), AccountType = post.Author.ReferenceType }, FullName = postAuthorProfile.FullName, Description1 = postAuthorProfile.Description1, Description2 = postAuthorProfile.Description2 }; thisPost.Text = post.Text; thisPost.PublishDateTime = post.PublishDateTime; thisPost.Comments = new List<CommentViewModel>(); foreach (var comment in post.Comments) { CommentViewModel thisComment = new CommentViewModel(); thisComment.Key = comment.Key.ToString(); //thisComment.AuthorKey = comment.Author.ReferenceKey.ToString(); //thisComment.AuthorName = SecurityRepository.GetCompleteProfile(comment.Author.ReferenceKey); var commentAuthorProfile = SecurityRepository.GetCompleteProfile(comment.Author); thisComment.Author = new CompleteProfileViewModel { BasicProfile = new BasicProfileViewModel { ReferenceKey = commentAuthorProfile.BasicProfile.ReferenceKey.ToString(), AccountType = commentAuthorProfile.BasicProfile.ReferenceType }, FullName = commentAuthorProfile.FullName, Description1 = commentAuthorProfile.Description1, Description2 = commentAuthorProfile.Description2 }; thisComment.Text = comment.Text; thisComment.PublishDateTime = comment.PublishDateTime; thisPost.Comments.Add(thisComment); } organizationAccountView.Wall.Posts.Add(thisPost); } } else { organizationAccountView.Wall = new ContentStreamViewModel(); organizationAccountView.Wall.Posts = new List<PostViewModel>(); } return organizationAccountView; }
public static UserAccountViewModel ConvertUserAccountToViewModel(UserAccount userAccount) { UserAccountViewModel itemview = new UserAccountViewModel(); itemview.Profile = new CompleteProfileViewModel { BasicProfile = new BasicProfileViewModel { ReferenceKey=userAccount.Key.ToString(), AccountType= Domain._Base.Accounts.AccountType.UserAccount }, FullName=userAccount.User.FirstName + " " + userAccount.User.LastName , Description1= userAccount.OrganizationAccount.Name, Description2=userAccount.OrganizationAccount.Organization.Name }; //itemview.UserAccountKey = userAccount.Key.ToString(); // itemview.UserName = userAccount.User.FirstName + " " + userAccount.User.LastName; // itemview.Organization = new KeyValuePair<string, string>(userAccount.OrganizationAccount.Organization.Key.ToString(), userAccount.OrganizationAccount.Organization.Name); itemview.Email = userAccount.Email; // itemview.UserKey = userAccount.User.Key.ToString(); //itemview.OrganizationAccount = new CompleteProfileViewModel { BasicProfile = new BasicProfileViewModel { }, }; new KeyValuePair<string, string>(userAccount.OrganizationAccount.Key.ToString(), userAccount.OrganizationAccount.Name); itemview.WorkContacts = new List<CompleteProfileViewModel>(); itemview.PartnershipContacts = new List<CompleteProfileViewModel>(); itemview.Groups = new List<CompleteProfileViewModel>(); //itemview.WorkContacts.Clear(); //itemview.PartnershipContacts.Clear(); //itemview.Groups.Clear(); itemview.Wall = new ContentStreamViewModel(); itemview.Wall.Posts = new List<PostViewModel>(); if (userAccount.GroupMemberships.Count>0) { foreach (var subitem in userAccount.GroupMemberships) { itemview.Groups.Add(new CompleteProfileViewModel { BasicProfile = new BasicProfileViewModel { ReferenceKey=subitem.RequestedGroup.Key.ToString(), AccountType= Domain._Base.Accounts.AccountType.Group }, FullName=subitem.RequestedGroup.Name, Description1=subitem.RequestedGroup.Description }); } } if (userAccount.FriendshipsReceived.Count>0) { foreach (var subitem in userAccount.FriendshipsReceived) { if (subitem.Receiver.OrganizationAccount.Key == subitem.Sender.OrganizationAccount.Key) { itemview.WorkContacts.Add(new CompleteProfileViewModel { BasicProfile = new BasicProfileViewModel { ReferenceKey= subitem.Sender.Key.ToString(), AccountType= Domain._Base.Accounts.AccountType.UserAccount }, FullName = subitem.Sender.User.FirstName + " " + subitem.Sender.User.LastName, Description1 = subitem.Sender.OrganizationAccount.Name, Description2 = subitem.Sender.OrganizationAccount.Organization.Name }); } else { itemview.PartnershipContacts.Add(new CompleteProfileViewModel { BasicProfile = new BasicProfileViewModel { ReferenceKey= subitem.Sender.Key.ToString(), AccountType= Domain._Base.Accounts.AccountType.UserAccount }, FullName = subitem.Sender.User.FirstName + " " + subitem.Sender.User.LastName, Description1 = subitem.Sender.OrganizationAccount.Name, Description2 = subitem.Sender.OrganizationAccount.Organization.Name }); } } } if (userAccount.FriendshipsRequested.Count>0) { foreach (var subitem in userAccount.FriendshipsRequested) { if (subitem.Receiver.OrganizationAccount.Key == subitem.Sender.OrganizationAccount.Key) { itemview.WorkContacts.Add(new CompleteProfileViewModel { BasicProfile = new BasicProfileViewModel { ReferenceKey = subitem.Receiver.Key.ToString(), AccountType = Domain._Base.Accounts.AccountType.UserAccount }, FullName = subitem.Receiver.User.FirstName + " " + subitem.Receiver.User.LastName, Description1 = subitem.Receiver.OrganizationAccount.Name, Description2 = subitem.Receiver.OrganizationAccount.Organization.Name }); } else { itemview.PartnershipContacts.Add(new CompleteProfileViewModel { BasicProfile = new BasicProfileViewModel { ReferenceKey = subitem.Receiver.Key.ToString(), AccountType = Domain._Base.Accounts.AccountType.UserAccount }, FullName = subitem.Receiver.User.FirstName + " " + subitem.Receiver.User.LastName, Description1 = subitem.Receiver.OrganizationAccount.Name, Description2 = subitem.Receiver.OrganizationAccount.Organization.Name }); } } } if (userAccount.Wall.Posts.Count>0) { foreach (var post in userAccount.Wall.Posts) { PostViewModel thisPost = new PostViewModel(); thisPost.Key = post.Key.ToString(); //thisPost.AuthorKey = post.Author.ReferenceKey.ToString(); //thisPost.AuthorName = SecurityRepository.GetCompleteProfile(post.Author.ReferenceKey); var postAuthorProfile = SecurityRepository.GetCompleteProfile(post.Author); thisPost.Author = new CompleteProfileViewModel { BasicProfile = new BasicProfileViewModel { ReferenceKey = postAuthorProfile.BasicProfile.ReferenceKey.ToString(), AccountType = post.Author.ReferenceType }, FullName = postAuthorProfile.FullName, Description1 = postAuthorProfile.Description1, Description2 = postAuthorProfile.Description2 }; thisPost.Text = post.Text; thisPost.PublishDateTime = post.PublishDateTime; thisPost.Comments = new List<CommentViewModel>(); if (post.PostLikes != null) { thisPost.Likes = post.PostLikes.Count(); } else{ thisPost.Likes = 0; } foreach (var comment in post.Comments) { CommentViewModel thisComment = new CommentViewModel(); thisComment.Key = comment.Key.ToString(); //thisComment.AuthorKey = comment.Author.ReferenceKey.ToString(); //thisComment.AuthorName = SecurityRepository.GetCompleteProfile(comment.Author.ReferenceKey); var commentAuthorProfile = SecurityRepository.GetCompleteProfile(comment.Author); thisComment.Author = new CompleteProfileViewModel { BasicProfile = new BasicProfileViewModel { ReferenceKey = commentAuthorProfile.BasicProfile.ReferenceKey.ToString(), AccountType = commentAuthorProfile.BasicProfile.ReferenceType }, FullName = commentAuthorProfile.FullName, Description1 = commentAuthorProfile.Description1, Description2 = commentAuthorProfile.Description2 }; thisComment.Text = comment.Text; thisComment.PublishDateTime = comment.PublishDateTime; if (comment.CommentLikes != null) { thisComment.Likes = comment.CommentLikes.Count(); } else { thisComment.Likes = 0; } thisPost.Comments.Add(thisComment); } itemview.Wall.Posts.Add(thisPost); } } return itemview; }