public JsonResult _MessageVariables(string login)
        {
            var receiverStrings = login.Split('@');
            var xmppLogin       = receiverStrings[0];

            using (var context = new InnostarModelsContext())
            {
                var result = new Dictionary <string, string>();

                var repository = new ChatUserRepository(context);
                var users      = repository._Get(e => e.XmppLogin == xmppLogin).ToList();

                if (users.Any())
                {
                    var user  = users.FirstOrDefault();
                    var email = string.IsNullOrEmpty(user.Email) ? string.Empty : user.Email;
                    var name  = string.IsNullOrEmpty(user.Name) ? user.Login : user.Name;

                    result.Add("userEmail", email);
                    result.Add("userDisplayName", name);


                    var requestRepository = new RecoverPasswordRequestRepository(context);
                    var requests          =
                        requestRepository._Get(e => e.UserId == user.Id)
                        .OrderByDescending(e => e.RequestAcceptedTime)
                        .ToList();

                    var request = requests.Any() ? GetRecoverLink(requests.FirstOrDefault().RequestKey) : string.Empty;
                    result.Add("userPasswordRequest", request);

                    var confirmEmailRepository = new ConfirmEmailRequestRepository(context);
                    var confirmEmailrequests   =
                        confirmEmailRepository._Get(e => e.UserId == user.Id)
                        .OrderByDescending(e => e.RequestAcceptedTime)
                        .ToList();

                    var confirmEmailrequest = confirmEmailrequests.Any() ? GetConfirmLink(confirmEmailrequests.FirstOrDefault().RequestKey) : string.Empty;
                    result.Add("userConfirmRequest", confirmEmailrequest);
                }
                else
                {
                    result.Add("userEmail", string.Empty);
                    result.Add("userDisplayName", string.Empty);
                    result.Add("userRequest", string.Empty);
                }

                return(Json(result, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult ConfirmEmail(string key)
        {
            using (var dataContext = new InnostarModelsContext())
            {
                var repository = new ConfirmEmailRequestRepository(dataContext);

                var requests = repository._Get(u => u.RequestKey.Equals(key) && u.IsActive).ToList();

                if (requests.Any())
                {
                    var request = requests.FirstOrDefault();

                    if (request == null)
                    {
                        throw new Exception("Данного запроса не существует");
                    }

                    var userRepository = new ChatUserRepository(dataContext);
                    var user           = userRepository._Get(e => e.Id == request.UserId).FirstOrDefault();

                    if (user == null)
                    {
                        throw new Exception("Произошла ошибка в обработке запроса. Обратитесь в службу поддержки");
                    }

                    user.Disabled = false;
                    userRepository._Update(user);
                    userRepository._Save();

                    request.IsActive = false;
                    repository._Update(request);
                    repository._Save();

                    return(View(new ConfirmEmailModel
                    {
                        RequestId = request.Id,
                        RequestKey = key,
                        UserDisplayName = user.Name
                    }));
                }
                else
                {
                    return(RedirectToAction("NotFound", "Error"));
                }
            }
        }