Пример #1
0
        public RemoveFromFriendsResponse RemoveFromFriends(ISession session, RemoveFromFriendsRequest request)
        {
            var response = request.CreateResponse<RemoveFromFriendsResponse>();
            response.Success = true;
            
            if (session.User.Friends.All(i => i.Id != request.TargetUserId))
            {
                response.Success = false;
                return response;
            }

            using (var uow = UnitOfWorkFactory.Create())
            {
                uow.Attach(session.User);
                var friend = uow.UsersRepository.FirstMatching(UserSpecification.Id(request.TargetUserId));
                if (friend == null)
                {
                    response.Success = false;
                }
                else
                {
                    session.User.Friends.Remove(friend);
                    uow.Commit();
                }
            } 
            return response;
        }
		public Task<RemoveFromFriendsResponse> RemoveFromFriends(RemoveFromFriendsRequest request)
		{
			return ConnectionManager.SendRequestAndWaitResponse<RemoveFromFriendsResponse>(request);
		}