Ejemplo n.º 1
0
        public ChangePhotoResponse ChangePhoto(ISession session, ChangePhotoRequest request)
        {
            var response = request.CreateResponse <ChangePhotoResponse>();

            response.Success = true;
            int photoId = request.BuiltinPhotoId;

            if (!request.PhotoData.IsNullOrEmpty() && request.PhotoData.Length > 10)
            {
                try
                {
                    photoId = _fileStorage.AppendFile(request.PhotoData);
                }
                catch (Exception exc)
                {
                    photoId          = 0;
                    response.Success = false;
                }
            }
            response.PhotoId = photoId;

            if (response.Success)
            {
                using (var uow = UnitOfWorkFactory.Create())
                {
                    uow.Attach(session.User);
                    session.User.ChangePhoto(photoId);

                    uow.Commit();
                }
                _profileChangesNotificator.NotifyEverybodyInChatAboutProfileChanges(session.User.Id, new Dictionary <string, object> {
                    { "PhotoId", photoId }
                });
            }

            return(response);
        }
Ejemplo n.º 2
0
 public Task <ChangePhotoResponse> ChangePhoto(ChangePhotoRequest request)
 {
     return(ConnectionManager.SendRequestAndWaitResponse <ChangePhotoResponse>(request));
 }