public void createUserFriend_Test()
        {
            var repoMock     = new Mock <IUserFriendRepo>();
            var returnedList = new List <UserFriendDto> {
                new UserFriendDto {
                    userFollowerId = 1,
                    userFollowedId = 2
                },
                new UserFriendDto {
                    userFollowerId = 2,
                    userFollowedId = 1
                }
            };
            var userFriend = new UserFriendDto
            {
                userFollowerId = 1,
                userFollowedId = 2
            };

            repoMock.Setup(p => p.AddUserFriendById(1, 2)).Returns(returnedList);
            var service = new UserFriendServices(repoMock.Object);
            var ctl     = new UserFriendController(service);

            // Act
            var result = ctl.createUserFriend(userFriend).Result as OkObjectResult;

            // Assert
            result.Value.Should().BeEquivalentTo(returnedList, options => options.ComparingByMembers <UserFriendDto>());
        }
Esempio n. 2
0
 private UserBookmark1 GetUserBookmark(UserFriendDto userFriend)
 {
     return(_unitOfWork.Repository <UserBookmark1>().Query()
            .Filter(x => x.UserId == userFriend.UserId && x.BookmarkId == userFriend.BookmarkId)
            .Get()
            .FirstOrDefault());
 }
Esempio n. 3
0
        public ActionResult ShareWithFriend(UserFriendDto userFriendDto)
        {
            if (ModelState.IsValid)
            {
                _userBookmarkService.ShareWithFriend(userFriendDto);
                return(RedirectToAction("Index"));
            }

            return(View(userFriendDto));
        }
Esempio n. 4
0
        public void ShareWithFriend(UserFriendDto userFriend)
        {
            UserFriendBookmark1 userFriendBookmark = new UserFriendBookmark1();

            var userBookMark = GetUserBookmark(userFriend);

            userFriendBookmark.BookmarkId  = userBookMark.BookmarkId;
            userFriendBookmark.DateSend    = DateTime.Today;
            userFriendBookmark.FriendsIds  = userFriend.FriendId;
            userFriendBookmark.URL         = userFriend.ShortUrl;
            userFriendBookmark.UserId      = userBookMark.UserId;
            userFriendBookmark.ObjectState = ObjectState.Modified;
            _unitOfWork.Repository <UserFriendBookmark1>().Update(userFriendBookmark);
            _unitOfWork.Save();
        }
Esempio n. 5
0
        public ActionResult <IEnumerable <UserFriendDto> > createUserFriend(UserFriendDto _userfriend)
        {
            var userFriends = _userFriendService.ServiceAddUserFriendById((int)_userfriend.userFollowerId, (int)_userfriend.userFollowedId);

            return(Ok(userFriends));
        }