示例#1
0
        public AddToBlacklistResponse AddToBlacklist(ISession session, AddToBlacklistRequest request)
        {
            var response = request.CreateResponse<AddToBlacklistResponse>();
            response.Success = true;

            if (session.User.PersonalBlackList.Any(i => i.Id == request.TargetUserId))
            {
                response.Success = false;
                return response;
            }

            using (var uow = UnitOfWorkFactory.Create())
            {
                uow.Attach(session.User);
                var target = uow.UsersRepository.FirstMatching(UserSpecification.Id(request.TargetUserId));
                if (target == null)
                {
                    response.Success = false;
                }
                else
                {
                    session.User.PersonalBlackList.Add(target);
                    uow.Commit();
                }
            }
            //TODO: notify target about it somehow
            return response;
        }
		public Task<AddToBlacklistResponse> AddToBlacklist(AddToBlacklistRequest request)
		{
			return ConnectionManager.SendRequestAndWaitResponse<AddToBlacklistResponse>(request);
		}