public IActionResult Index() { var circles = _circleService.Get(); return(View(circles)); }
public ActionResult CreateToCircle(string userId, string circleId) { ViewData["id"] = userId; var circle = circleService.Get(circleId); var model = new PostViewModel() { Post = new Post(), Circle = circle }; return(View()); }
public ActionResult Create_Post(string userId, Post post) { _postsService.Create(post); if (post.CircleId != null) // not tested { var circle = _circleService.Get(post.CircleId); if (circle == null) { return(NotFound()); } circle.PostId.Add(post.Id); _circleService.Update(circle); } else { var user = _userService.Get(userId); if (user == null) { return(NotFound()); } user.PostId.Add(post.Id); _userService.Update(user); } return(NoContent()); }
public IActionResult Profile(string id) { profileViewModel = new ProfileViewModel(); user = userService.Get(id); // Get all posts profileViewModel.User = user; foreach (var PostId in user.PostIds) { profileViewModel.UserPosts.Add(postService.Get(PostId)); } //Get all circles and posts if (user.CircleIds != null) { foreach (var userCircleId in user.CircleIds) { profileViewModel.Circles.Add(circleService.Get(userCircleId)); if (profileViewModel.Circles.Last().PostIds == null) { continue; } foreach (var post in profileViewModel.Circles.Last().PostIds) { profileViewModel.CirclePosts.Add(postService.Get(post)); } } } return(View(profileViewModel)); }
public ActionResult <List <Post> > Get(string userId, string guestId) { List <Post> postsToWall = new List <Post>(); User user = _userService.Get(userId); User guestUser = _userService.Get(guestId); foreach (var id in user.BlockedUserId) { if (guestId == id) { return(NoContent()); } } foreach (var postId in user.PostId) { postsToWall.Add(_postsService.Get(postId)); } List <string> circleIdList = new List <string>(); foreach (var circleId in user.CircleId) { foreach (var circleIdOther in guestUser.CircleId) { if (circleId == circleIdOther) { circleIdList.Add(circleId); } } } foreach (var circleId in circleIdList) { Circle circle = _circleService.Get(circleId); foreach (var postId in circle.PostId) { var post = _postsService.Get(postId); if (post.UserId == userId) { postsToWall.Add(post); } } } return(postsToWall); }
public ActionResult <List <Post> > Get(string id) { List <Post> postsInFeed = new List <Post>(); var user = _userService.Get(id); if (user == null) { return(NotFound()); } foreach (var postId in user.PostId) { postsInFeed.Add(_postsService.Get(postId)); } if (user.CircleId != null) { foreach (var circleId in user.CircleId) { var Circle = _circleService.Get(circleId); foreach (var postId in Circle.PostId) { postsInFeed.Add(_postsService.Get(postId)); } } } if (user.FollowUserId != null) { foreach (var followUserId in user.FollowUserId) { var User = _userService.Get(followUserId); foreach (var postId in User.PostId) { postsInFeed.Add(_postsService.Get(postId)); } } } return(postsInFeed); }
public ActionResult <List <Circle> > Get() { return(_circleService.Get()); }
public ActionResult <List <Circle> > Get() => _circleService.Get();
// GET: Cicles public ActionResult Index() { return(View(_circleService.Get())); }
private void SeedData(IDabHandIn3DatabaseSettings settings) { UserService userService = new UserService(settings); CircleService circleService = new CircleService(settings); PostService postService = new PostService(settings); // Seeding Users List <User> users = userService.Get(); if (users != null) { foreach (var user in users) { userService.Remove(user); } } List <User> usersToInsert = new List <User>() { new User() { UserName = "******", Age = 21, Email = "*****@*****.**", Gender = "Male", BlockedUsers = new List <string>(), Following = new List <string>() }, new User() { UserName = "******", Age = 21, Email = "*****@*****.**", Gender = "Male", BlockedUsers = new List <string>(), Following = new List <string>() }, new User() { UserName = "******", Age = 22, Email = "*****@*****.**", Gender = "Male", BlockedUsers = new List <string>(), Following = new List <string>() }, new User() { UserName = "******", Age = 22, Email = "*****@*****.**", Gender = "Male", BlockedUsers = new List <string>(), Following = new List <string>() } }; foreach (var user in usersToInsert) { userService.Create(user); } // Roman follows Rosendal usersToInsert[1].Following = new List <string>() { usersToInsert[0].Id }; userService.Update(usersToInsert[1].Id, usersToInsert[1]); // Seeding Circles List <Circle> circles = circleService.Get(); if (circles != null) { foreach (var circle in circles) { circleService.Remove(circle); } } List <Circle> circlesToInsert = new List <Circle>() { new Circle() { Admin = usersToInsert[0], Public = true, CircleName = "Rosendals Circle", PostIds = new List <string>(), UserIds = new List <string>() { usersToInsert[0].Id, usersToInsert[1].Id } }, new Circle() { Admin = usersToInsert[2], Public = false, CircleName = "Bommys Circle", PostIds = new List <string>(), UserIds = new List <string>() { usersToInsert[2].Id, usersToInsert[3].Id } } }; foreach (var circle in circlesToInsert) { circleService.Create(circle); } // Seeding Posts List <Post> posts = postService.Get(); if (posts != null) { foreach (var post in posts) { postService.Remove(post); } } List <Post> postsToInsert = new List <Post>() { new Post() { Author = usersToInsert[0], Content = new Content() { Text = "Now this is content boys", Image = null }, Comments = new List <Comment>() { new Comment() { Author = usersToInsert[1], Content = "This is not content boys", CreationTime = DateTime.Now } }, CreationTime = DateTime.Now.AddMinutes(-1) }, new Post() { Author = usersToInsert[0], Content = new Content() { Text = "So bored today, lol", Image = null }, Comments = new List <Comment>() { new Comment() { Author = usersToInsert[2], Content = "Roflcopter", CreationTime = DateTime.Now } }, CreationTime = DateTime.Now.AddMinutes(-2) } }; foreach (var post in postsToInsert) { postService.Create(post, circlesToInsert[0].Id); } }
public List <Circle> Get() { return(_circleService.Get()); }