Esempio n. 1
0
        public Friendship Create(Friendship friendship)
        {
            Validator.Validate(friendship);

            var saveFriendship = _FriendshipRepository.Save(friendship);
            return saveFriendship;
        }
Esempio n. 2
0
 public Friendship Update(Friendship friendship)
 {
     DbEntityEntry entry = _context.Entry(friendship);
     entry.State = EntityState.Modified;
     _context.SaveChanges();
     return friendship;
 }
Esempio n. 3
0
        public Friendship Update(Friendship friendship)
        {
            Validator.Validate(friendship);

            var updateFriendship = _FriendshipRepository.Update(friendship);
            return updateFriendship;
        }
Esempio n. 4
0
 public void CreateAValidFriendshiNameAndIdTest()
 {
     Friendship Friendship = new Friendship();
     Friendship.Name = "Lages";
     Friendship.Id = 1;
     Validator.Validate(Friendship);
 }
 public void Setup()
 {
     _Friendship = ObjectMother.GetFriendship();
     _mockRepository = new MockRepository(MockBehavior.Default);
     _FriendshipRepoMoq = _mockRepository.Create<IFriendshipRepository>();
     _service = new FriendshipService(_FriendshipRepoMoq.Object);
 }
Esempio n. 6
0
 public void Follow(Friendship friendship)
 {
     this.FollowersCount += 1;
     followers.Add(friendship);
     foreach (var postsOfFriend in friendship.posts)
     {
         posts.Add(postsOfFriend);
     }
 }
Esempio n. 7
0
 public IEnumerable<Post> GetAllPostsOfFriendship(Friendship friendship)
 {
     IEnumerable<Post> posts = null;
     foreach (var post in friendship.posts)
     {
         posts = postRepository.GetAll().Where(x => x.Message == post.Message);
     }
     return posts;
 }
Esempio n. 8
0
        public static Friendship GetFriendship()
        {
            Friendship friendship = new Friendship();
            friendship.Name = "user1";
            friendship.FollowersCount = 20;
            friendship.Id = 1;
            friendship.followers.Add(new Friendship()
            {
                Name = "user1",
                FollowersCount = 20,
                Id = 1,
                posts = new List<Post>() {
               new Post(){
                Id = 1,
                Name = "name1",
                Message = "Post1" }}
            });
            friendship.posts.Add(new Post()
            {
                Id = 1,
                Name = "name1",
                Message = "Post1"
            });

            friendship.posts.Add(new Post()
            {
                Id = 2,
                Name = "name2",
                Message = "Post2"
            });

            friendship.posts.Add(new Post()
            {
                Id = 3,
                Name = "name3",
                Message = "Post3"
            });

            friendship.posts.Add(new Post()
            {
                Id = 4,
                Name = "name4",
                Message = "Post4"
            });
            friendship.followers.Add(new Friendship()
            {
                Name = "user2",
                FollowersCount = 20,
                Id = 1
            });

            return friendship;
        }
Esempio n. 9
0
 public Friendship Save(Friendship friendship)
 {
     var newFriendship = _context.Friendships.Add(friendship);
     _context.SaveChanges();
     return newFriendship;
 }
Esempio n. 10
0
 public void UnFollow(Friendship friendship)
 {
     this.FollowersCount -= 1;
     posts.RemoveAll(x => this.Id != friendship.Id);
 }
Esempio n. 11
0
 public void Setup()
 {
     _Friendship = ObjectMother.GetFriendship();
 }