public bool CreateMessage(Message message)
        {
            try
            {
                var ctx = new CurrentContext();
                var client = ctx.CurrentClient;
                var userId = ctx.CurrentUserId;

                var messageType = MessageTypeService.GetMessageType(message.MessageTypeId);
                message.MessageType = messageType;
                //message.MessageTypeId;
                var user = ctx.GetSystemUser();
                message.Client = client;
                message.User = user;
                //message.User.UserId = userId;
                _messagesRepository.CreateMessage(message);
                return true;
            }
            catch (Exception ex)
            {
                _validationDictionary.AddError("_FORM", "Message not created" + ex.Message);
                 return false;
            }
        }
        public Message GetMessage(int id)
        {
            var message = _messagesRepository.GetMessage(id);

            var ctx = new CurrentContext();
            var client = ctx.CurrentClient;
            var user = ctx.GetSystemUser();
            //var userId = ctx.CurrentUserId;

            //var messageType = MessageTypeService.GetMessageType(message.MessageTypeId);
            message.MessageTypeReference.Load();
            //message.MessageType = messageType;
            message.Client = client;
            message.User = user;

            return message;
        }
        public List<Client> ListClients(bool deleted)
        {
            var ctx = new CurrentContext();
            var _status = StatusService.GetStatus(STATUSES.Deleted);

            var list = _repository.ListClients(_status, deleted);

            var system = list.Find(c => c.UserId == ctx.GetSystemUser().UserId);
            if (system != null)
                list.Remove(system);

            return list;
        }