//[OutputCache(CacheProfile = "Day", VaryByParam = "id")]
        public ActionResult GetLanguage(int id)
        {
            if (SessionNames.IsValidationExceed("GetLanguage", 100))
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }
            var languges = CachedQueriedData.GetLanguages(id);

            if (languges != null)
            {
                var represent =
                    languges.Select(n => new { text = n.Language + " - " + n.NativeName, id = n.CountryLanguageID });
                return(Json(represent.ToList(), JsonRequestBehavior.AllowGet));
            }
            return(Json(null, JsonRequestBehavior.AllowGet));
        }
        /// <summary>
        ///     External Validations
        ///     Register Code Validation
        /// </summary>
        /// <param name="model"></param>
        public static async Task <bool> ExternalUserValidation(RegisterViewModel model, ApplicationDbContext db,
                                                               ErrorCollector errors = null)
        {
            var validOtherConditions = true;

            if (errors == null)
            {
                errors = new ErrorCollector();
            }
            if (!AppVar.Setting.IsRegisterCodeRequiredToRegister)
            {
                model.RegistraterCode = Guid.NewGuid();
                model.Role            = -1;
            }
            else
            {
                var regCode =
                    db.RegisterCodes.FirstOrDefault(
                        n =>
                        n.IsUsed == false && n.RoleID == model.Role && n.RegisterCodeID == model.RegistraterCode &&
                        !n.IsExpired);
                if (regCode != null)
                {
                    if (regCode.ValidityTill <= DateTime.Now)
                    {
                        // not valid
                        regCode.IsExpired = true;
                        errors.AddMedium(MessageConstants.RegistercCodeExpired, MessageConstants.SolutionContactAdmin);
                        await db.SaveChangesAsync();

                        validOtherConditions = false;
                    }
                }
                else
                {
                    errors.AddMedium(MessageConstants.RegistercCodeNotValid, MessageConstants.SolutionContactAdmin);
                    validOtherConditions = false;
                }
            }

            //validation for country language
            var languages = CachedQueriedData.GetLanguages(model.CountryID, 0);

            if (languages == null)
            {
                //select english as default.
                model.CountryLanguageID = CachedQueriedData.GetDefaultLanguage().CountryLanguageID;
            }
            else if (languages.Count > 1)
            {
                //it should be selected inside the register panel.
                validOtherConditions = !(model.CountryLanguageID == 0); //if zero then false.
                errors.AddMedium("You forgot you set your language.");
            }
            else if (languages.Count == 1)
            {
                model.CountryLanguageID = languages[0].CountryLanguageID;
            }

            //validation for country timzone
            var timezones = CachedQueriedData.GetTimezones(model.CountryID, 0);

            if (timezones != null && timezones.Count > 1)
            {
                //it should be selected inside the register panel.
                validOtherConditions = !(model.UserTimeZoneID == 0); //if zero then false.
                errors.AddMedium("You forgot you set your time zone.");
            }
            else if (timezones.Count == 1)
            {
                model.UserTimeZoneID = timezones[0].UserTimeZoneID;
            }
            else
            {
                validOtherConditions = false;
                errors.AddMedium(
                    "You time zone not found. Please contact with admin and notify him/her about the issue to notify developer.");
            }


            if (!validOtherConditions)
            {
                AppConfig.SetGlobalError(errors);
            }
            return(validOtherConditions);
        }