public HttpResponseMessage GetEncryptMessage(Guid messageId)
        {
            try
            {
                if (Common.CurrentUser.UserID == -1)
                    return Request.CreateResponse(HttpStatusCode.Unauthorized, new {MessageError = App_GlobalResources.Errors.ErrorNotAuthorized});

                var message = _repository.GetMessage(messageId);

                MessageViewModel messageView = null;

                if (message != null)
                {
                    messageView = new MessageViewModel(message, true);
                    if (messageView.MessageCc.IndexOf(Common.CurrentUser.Email, StringComparison.OrdinalIgnoreCase) == -1 &&
                        messageView.MessageCco.IndexOf(Common.CurrentUser.Email, StringComparison.OrdinalIgnoreCase) == -1 &&
                        messageView.MessageTo.IndexOf(Common.CurrentUser.Email, StringComparison.OrdinalIgnoreCase) == -1)
                    {
                        messageView = null;
                    }
                }

                return Request.CreateResponse(HttpStatusCode.OK, new { Success = messageView != null, Message = messageView });
            }
            catch (Exception)
            {
                return Request.CreateResponse(HttpStatusCode.InternalServerError, App_GlobalResources.Errors.ErrorGeneric);
            }
        }
        /// <summary>
        /// Creates a Message object to update the database.
        /// </summary>
        /// <param name="viewModel">Message to be updated.</param>
        /// <returns></returns>
        private static Message UpdateMessage(MessageViewModel viewModel)
        {

            return new Message
            {
                MessageId = viewModel.MessageId,
                MessageFrom = viewModel.MessageFrom,
                MessageTo = viewModel.MessageTo,
                MessageCc = viewModel.MessageCc,
                MessageCco = viewModel.MessageCco,
                Subject = UrlUtils.EncryptParameter(viewModel.Subject, Common.GetDecryptionKey()),
                Body = UrlUtils.EncryptParameter(viewModel.Body, Common.GetDecryptionKey()),
                ExpireDate = viewModel.ExpireDate.ToUniversalTime()
            };
        }