Ejemplo n.º 1
0
        public ActionResult Edit(Int32 id)
        {
            var zones = CachedQueriedData.GetTimezones(id);

            ViewBag.Timezone    = new SelectList(_db.UserTimeZones.ToList(), "UserTimeZoneID", "Display");
            ViewBag.CountryID   = id;
            ViewBag.CountryName = _db.Countries.Find(id).DisplayCountryName + " - " + _db.Countries.Find(id).Alpha2Code;
            return(View(zones));
        }
        public ActionResult GetTimeZone(int id)
        {
            if (SessionNames.IsValidationExceed("GetTimeZone", 100))
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }
            var getZones = CachedQueriedData.GetTimezones(id);

            if (getZones != null)
            {
                var represent = getZones.Select(n => new { text = n.Display, id = n.UserTimeZoneID });
                return(Json(represent.ToList(), JsonRequestBehavior.AllowGet));
            }
            return(Json(null, JsonRequestBehavior.AllowGet));
        }
        //[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));
        }
Ejemplo n.º 4
0
        public static string EmailConfirmHtml(ApplicationUser user, string callBackUrl, string footerSenderName = "",
                                              string department = "Administration", string body = null)
        {
            SB.Clear();
            if (body == null)
            {
                body = string.Format(_defaultMailConfirmBody, AppVar.Url, AppVar.Name, callBackUrl, callBackUrl);
            }

            AddGreetingsToStringBuilder(user);
            SB.AppendLine(body);
            SB.AppendLine(LINE_BREAK);
            SB.AppendLine(string.Format(DIV_TAG, "", "", "Name : " + user.DisplayName));
            SB.AppendLine(string.Format(DIV_TAG, "", "", "Login(username) : " + user.UserName));
            SB.AppendLine(string.Format(DIV_TAG, "", "", "Email : " + user.Email));
            SB.AppendLine(string.Format(DIV_TAG, "", "", "Phone : " + user.PhoneNumber));
            SB.AppendLine(string.Format(DIV_TAG, "", "", "Timezone : " + CachedQueriedData.GetTimezone(user).UTCName));
            SB.AppendLine(string.Format(DIV_TAG, "", "", "Country : " + CachedQueriedData.GetCountry(user).CountryName));
            SB.AppendLine(LINE_BREAK);
            SB.AppendLine(ThanksFooter(AppVar.Setting.AdminName, department));
            return(SB.ToString());
        }
Ejemplo n.º 5
0
        public ActionResult Edit(int countryId, int timezone, bool hasMultiple)
        {
            var country = _db.Countries.Find(countryId);

            var foundTimeZone = _db.UserTimeZones.Find(timezone);

            if (foundTimeZone != null)
            {
                var addRelation = new CountryTimezoneRelation {
                    CountryID      = country.CountryID,
                    UserTimeZoneID = foundTimeZone.UserTimeZoneID
                };
                var anyExist =
                    _db.CountryTimezoneRelations.Any(
                        n => n.UserTimeZoneID == addRelation.UserTimeZoneID && n.CountryID == addRelation.CountryID);

                if (!anyExist)
                {
                    //not exist then add
                    _db.CountryTimezoneRelations.Add(addRelation);
                    country.RelatedTimeZoneID = addRelation.UserTimeZoneID;
                }

                country.IsSingleTimeZone  = !hasMultiple;
                country.RelatedTimeZoneID = addRelation.UserTimeZoneID;
                _db.SaveChanges();
            }
            var zones = CachedQueriedData.GetTimezones(countryId);

            ViewBag.Timezone    = new SelectList(_db.UserTimeZones.ToList(), "UserTimeZoneID", "Display");
            ViewBag.CountryID   = countryId;
            ViewBag.CountryName = _db.Countries.Find(countryId).DisplayCountryName + " - " +
                                  _db.Countries.Find(countryId).Alpha2Code;

            return(View(zones));
        }
 public static void LoadTimeZonesIntoMemory()
 {
     _dbTimeZones = CachedQueriedData.GetTimezones();
 }
        public static HtmlString DropDowns(this HtmlHelper helper, string valueField, string textField,
                                           string htmlName = null, string displayName  = null, string modelValue      = null, string isRequried = "*",
                                           string classes  = null, string toolTipValue = null, string otherAttributes = "", string tableName    = null,
                                           AppVar.ConnectionStringType connectionType = AppVar.ConnectionStringType.DefaultConnection)
        {
            var divElement = @"<div class='form-group {0}-main'>
                             <div class='controls'>
                                <label class='col-md-2 control-label' for='{0}'>{1}<span class='red '>{2}</span></label>
                                <div class='col-md-10 {0}-combo-div'>
                                    {3}
                                    <a href='#' data-toggle='tooltip' data-original-title='{4}' title='{4}' class='tooltip-show'><span class='glyphicon glyphicon-question-sign font-size-22 glyphicon-top-fix almost-white'></span></a>
                                </div>
                            </div>
                        </div>";

            // 0- name
            // 1- displayName
            // 2 - isRequried
            // 3 - select element
            // 4 - tooltipValue
            if (tableName == null)
            {
                tableName = valueField.Replace("ID", "");
            }
            if (modelValue == null)
            {
                modelValue = "";
            }
            if (classes == null)
            {
                classes = "btn btn-success";
            }
            if (displayName == null)
            {
                displayName = textField;
            }
            if (toolTipValue == null)
            {
                toolTipValue = "Please select " + displayName;
            }
            if (htmlName == null)
            {
                htmlName = valueField;
            }
            var selected = "";
            var countryOptionsGenerate = "<select class='form-control selectpicker " + classes +
                                         "' data-live-search='true' name='" + htmlName + "' " + otherAttributes +
                                         " title='Choose...' data-style='" + classes + "'>";
            var dt = CachedQueriedData.GetTable(tableName, connectionType, new[] { valueField, textField });

            if (dt != null && dt.Rows.Count > 0)
            {
                var     sb = new StringBuilder(countryOptionsGenerate, dt.Rows.Count + 10);
                DataRow row;
                for (var i = 0; i < dt.Rows.Count; i++)
                {
                    row = dt.Rows[i];
                    if (row[valueField].Equals(modelValue))
                    {
                        selected = Selected;
                    }
                    sb.Append(string.Format("<option value='{0}' {1} {2}>{2}</option>", row[valueField], selected,
                                            row[textField]));
                }
                sb.AppendLine("</select>");
                var complete = string.Format(divElement, htmlName, displayName, isRequried, sb, toolTipValue);

                return(new HtmlString(complete));
            }
            return(new HtmlString(""));
        }
 public void SetThingsInViewBag()
 {
     ViewBag.Country = CachedQueriedData.GetCountries();
 }
        /// <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);
        }
Ejemplo n.º 10
0
 public ActionResult Index()
 {
     return(View(CachedQueriedData.GetCountries().ToList()));
 }