/// <summary>
        /// NOTE: we don't need an app-level ack for this method :-)
        /// </summary>
        public void PublicMessage(ISession session, PublicMessageRequest msgRequest)
        {
            if (session.User.IsDevoiced)
            {
                session.Send(new YouAreDevoicedNotification());
                return;
            }

            PublicMessage message = null;
            using (var uow = UnitOfWorkFactory.Create())
            {
                uow.Attach(session.User);
                message = new PublicMessage(session.User, msgRequest.Body);
                uow.PublicMessageRepository.Add(message);
                uow.Commit();
            }

            var dto = message.ProjectedAs<PublicMessageDto>();
            dto.Role = (UserRoleEnum)(int)session.User.Role;
            _sessionManager.SendToEachChatSessions(dto);
        }
 public void Add(PublicMessage msg)
 {
     _uow.PublicMessages.Add(msg);
 }
        public SendImageResponse SendImage(ISession session, SendImageRequest request)
        {
            var response = request.CreateResponse<SendImageResponse>();
            response.ImageId = -1;

            if (session.User.IsDevoiced)
            {
                session.Send(new YouAreDevoicedNotification());
                return response;
            }

            PublicMessage message = null;
            using (var uow = UnitOfWorkFactory.Create())
            {
                int fileId;
                try
                {
                    fileId = _fileStorage.AppendFile(request.Image);
                    response.ImageId = fileId;
                }
                catch (System.Exception)
                {
                    //Invalid image
                    return response;
                }
                uow.Attach(session.User);
                message = new PublicMessage(session.User, fileId, "Your client doesn't support IMAGE messages");
                uow.PublicMessageRepository.Add(message);
                uow.Commit();
            }

            var dto = message.ProjectedAs<PublicMessageDto>();
            dto.Role = (UserRoleEnum)(int)session.User.Role;
            _sessionManager.SendToEachChatSessions(dto);
            return response;
        }