Exemplo n.º 1
0
 public IActionResult Create(Circle c)
 {
     c.PostIds = new List <string> ();
     c.UserIds = new List <string> ();
     _circleService.Create(c);
     return(RedirectToAction("Index"));
 }
Exemplo n.º 2
0
 public ActionResult Create(Circle circle)
 {
     try
     {
         _circleService.Create(circle);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
     //if (ModelState.IsValid)
     //{
     //    _circleService.Create(circle);
     //    return RedirectToAction(nameof(Index));
     //}
     //return View(circle);
 }
        public ActionResult Create(Circle circle)
        {
            var loggedInUserId = _circleService.GetLoggedInUserId();

            circle.OwnerId = loggedInUserId;
            var circleId = _circleService.Create(circle);



            var wall = new Wall()
            {
                owner     = circle.Name,
                Followers = new List <follower>()
                {
                    new follower()
                    {
                        followerID   = loggedInUserId,
                        followerName = _userService.Get(loggedInUserId).Name
                    }
                },
                BlackList = new List <blacklistedUser>(),
                ownerID   = circleId,
                type      = "Circle",
                postIDs   = new List <string>(),
            };

            var newWall = _wallService.Create(wall);

            //add circle.wallId after creating wall
            circle.WallId = newWall.ID;
            circle.Id     = circleId;

            _circleService.Update(circle.Id, circle);

            return(RedirectToAction("GetWall", "Wall", new { id = circleId, type = "Circle" }));
        }
 public ActionResult <Circle> Create(Circle Circle)
 {
     _circleService.Create(Circle);
     return(CreatedAtRoute("GetCircle", new { id = Circle.Id }, Circle));
 }
Exemplo n.º 5
0
        public ActionResult <Circle> Create(Circle circle)
        {
            _circleService.Create(circle);

            return(CreatedAtRoute("GetCircle", new { id = circle.Id.ToString() }, circle));
        }
Exemplo n.º 6
0
        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);
            }
        }
Exemplo n.º 7
0
        public Circle Create(Circle circle)
        {
            _circleService.Create(circle);

            return(circle);
        }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            var _userService   = new UserService();
            var _circleService = new CircleService();
            var _postService   = new PostService();

            User u1 = CreateUser("Anders", "M", 28);
            User u2 = CreateUser("David", "M", 31);
            User u3 = CreateUser("Christoffer", "M", 27);
            User u4 = CreateUser("Lau", "M", 22);

            _userService.Create(u1);
            _userService.Create(u2);
            _userService.Create(u3);
            _userService.Create(u4);

            Circle c = new Circle()
            {
                Name    = "My New Circle",
                UserIds = new List <string> (),
                PostIds = new List <string> (),
            };

            _circleService.Create(c);

            _circleService.AddUserToCircle(u1, c);
            _userService.AddCircleToUser(u1, c);
            _circleService.AddUserToCircle(u2, c);
            _userService.AddCircleToUser(u2, c);

            _userService.FollowUser(u3, u1);
            _userService.BlacklistUser(u2, u1);

            Post p1 = CreatePost(u1, c, "Text", "Hello everybody", null);

            _postService.Create(p1);
            _circleService.AddPostToCircle(p1, c);
            _userService.AddPostToUser(u1, p1);

            Post p2 = CreatePost(u1, null, "Image", "Nice picture of ocean!", "https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Ftse3.mm.bing.net%2Fth%3Fid%3DOIP.X1kDFM6ei4tqszAXo5DIEAHaE9%26pid%3DApi%26h%3D180%26p%3D0&f=1");

            _postService.Create(p2);
            _userService.AddPostToUser(u1, p2);

            Post p3 = CreatePost(u2, c, "Text", "Anders why have you blacklisted me?", null);

            _postService.Create(p3);
            _circleService.AddPostToCircle(p3, c);
            _userService.AddPostToUser(u2, p3);

            Post p4 = CreatePost(u3, null, "Image", "Look at this view!", "https://forestsnews.cifor.org/wp-content/uploads/2014/12/integrated-rice-and-fish-farms-anirban-mahapatra-1024x767.jpg");

            _postService.Create(p4);
            _userService.AddPostToUser(u3, p4);

            Comment comment = new Comment()
            {
                UserId   = p3.UserId,
                UserName = p3.UserName,
                Text     = "Hi Doctor Nick!"
            };

            _postService.AddCommentToPost(comment, p1);

            System.Console.WriteLine("=======================================");
            System.Console.WriteLine("Done seeding data");
            System.Console.WriteLine("Users are: Anders, David, Lau, Christoffer");
            System.Console.WriteLine("Anders and David are part of same circle");
            System.Console.WriteLine("David is blacklisted by Anders");
            System.Console.WriteLine("Christoffer is followed by Anders");
            System.Console.WriteLine("Press enter to exit");

            System.Console.ReadLine();
        }
Exemplo n.º 9
0
 public ActionResult <Circle> Create(Circle circle)
 {
     _circleService.Create(circle);
     return(CreatedAtRoute("GetCircle", new { groupName = circle.CircleName }, circle));
 }