示例#1
0
        /// <summary>
        /// Resets user's photo to default one
        /// </summary>
        public ResetPhotoResponse ResetPhoto(ISession session, ResetPhotoRequest request)
        {
            var response = request.CreateResponse <ResetPhotoResponse>();

            try
            {
                using (var uow = UnitOfWorkFactory.Create())
                {
                    var target = uow.UsersRepository.FirstMatching(UserSpecification.Id(request.TargetId));
                    if (target != null)
                    {
                        response.NewPhotoId = target.ResetPhoto(session.User);
                        uow.Commit();
                        response.Success = true;
                    }
                }
            }
            catch (ModeratorsRightsRequiredException)
            {
                response.Success = false;
            }
            if (response.Success)
            {
                _profileChangesNotificator.NotifyEverybodyInChatAboutProfileChanges(request.TargetId, new Dictionary <string, object> {
                    { "PhotoId", response.NewPhotoId }
                });
            }
            return(response);
        }
示例#2
0
 public Task <ResetPhotoResponse> ResetPhoto(ResetPhotoRequest request)
 {
     return(ConnectionManager.SendRequestAndWaitResponse <ResetPhotoResponse>(request));
 }