public ActionResult Index() { InterestIdentityViewBags(); var model = new FindUsersModel(); LoadFilteredUsers(false, model); ViewBag.FilteredUsers = _uas.ToUnorderdList; var rle = new Role(SiteEnums.RoleTypes.cyber_girl.ToString()); IList<UserAccount> girlModels = UserAccountRole.GetUsersInRole(rle.RoleID); if (girlModels == null || girlModels.Count <= 0) return View(model); girlModels.Shuffle(); UserAccount featuredModel = girlModels[0]; var featuredPhoto = new UserAccountDetail(); featuredPhoto.GetUserAccountDeailForUser(featuredModel.UserAccountID); int photoNumber = Utilities.RandomNumber(1, 4); string photoPath = featuredPhoto.FullProfilePicURL; if (photoNumber > 1) { var ups = new UserPhotos(); ups.GetUserPhotos(featuredModel.UserAccountID); if (ups.Count > 0) { foreach (UserPhoto up1 in ups.Where(up1 => (up1.RankOrder + 1) == photoNumber)) { photoPath = up1.FullProfilePicURL; break; } } } string[] colorBorder = GeneralConfigs.RandomColors.Split(','); var rnd = new Random(); string[] myRandomArray = colorBorder.OrderBy(x => rnd.Next()).ToArray(); ViewBag.FeaturedModel = string.Format(@" <a class=""m_over"" href=""{1}""> <img src=""{0}"" class=""featured_user"" style="" border: 2px dashed {2}; "" /></a>", photoPath, featuredModel.UrlTo, myRandomArray[0]); return View(model); }
public ActionResult Register(RegisterModel model) { if (Utilities.IsSpamIP(Request.UserHostAddress)) { ModelState.AddModelError("", Messages.Invalid + @": " + Messages.Account); return View(model); } if ( Request.Browser.Type == "IE3" || Request.Browser.Type == "IE4" || Request.Browser.Type == "IE5" || Request.Browser.Type == "IE6" || Request.Browser.Type == "IE7" || BlackIPs.IsIPBlocked(Request.UserHostAddress) ) { Response.Redirect("http://browsehappy.com/"); return View(); } if (!GeneralConfigs.EnableSameIP && UserAccount.IsAccountIPTaken(Request.UserHostAddress) && string.IsNullOrEmpty(model.RefUser)) { ModelState.AddModelError("", Messages.Invalid + @": " + Messages.Account); return View(model); } TryUpdateModel(model); if (!ModelState.IsValid) return View(model); if (!Utilities.IsEmail(model.Email)) { ModelState.AddModelError("", Messages.IncorrectFormat + @": " + Messages.EMail); return View(); } if ( model.UserName.Trim().Contains(" ") || model.UserName.Trim().Contains("?") || model.UserName.Trim().Contains("*") || model.UserName.Trim().Contains(":") || model.UserName.Trim().Contains("/") || model.UserName.Trim().Contains(@"\")) { ModelState.AddModelError("", Messages.Invalid + @": " + Messages.UserName); return View(); } if (model.YouAreID == null) { ModelState.AddModelError("", Messages.Invalid + @": " + Messages.YouAre); return View(); } DateTime dt; if (!DateTime.TryParse(model.Year + "-" + model.Month + "-" + model.Day, out dt)) { ModelState.AddModelError("", Messages.Invalid + @": " + Messages.BirthDate); return View(); } if (DateTime.TryParse(model.Year + "-" + model.Month + "-" + model.Day, out dt)) { if (Utilities.CalculateAge(dt) < GeneralConfigs.MinimumAge) { ModelState.AddModelError("", Messages.Invalid + @": " + Messages.BirthDate); return View(); } } model.UserName = model.UserName.Replace(":", string.Empty); model.UserName = model.UserName.Replace(" ", string.Empty); model.UserName = model.UserName.Replace(".", string.Empty); MembershipCreateStatus createStatus; Membership.CreateUser(model.UserName, model.NewPassword, model.Email, "Q", "A", true, out createStatus); if (createStatus == MembershipCreateStatus.Success) { FormsAuthentication.RedirectFromLoginPage(model.UserName, true); var ua = new UserAccount(model.UserName); _uad = new UserAccountDetail { UserAccountID = ua.UserAccountID, BirthDate = dt, YouAreID = model.YouAreID, DisplayAge = true, DefaultLanguage = Utilities.GetCurrentLanguageCode() }; if (!string.IsNullOrEmpty(model.RefUser)) { var refUser = new UserAccount(model.RefUser); _uad.ReferringUserID = refUser.UserAccountID; } _uad.Set(); var sb = new StringBuilder(100); sb.Append(Messages.Hello); sb.Append(Environment.NewLine); sb.Append(Messages.YourNewAccountIsReadyForUse); sb.Append(Environment.NewLine); sb.Append(Environment.NewLine); sb.AppendFormat("{0}: ", Messages.UserName); sb.Append(ua.UserName); sb.Append(Environment.NewLine); sb.Append(GeneralConfigs.SiteDomain); _mail.SendMail(AmazonCloudConfigs.SendFromEmail, ua.EMail, Messages.YourNewAccountIsReadyForUse, sb.ToString()); // see if this is the 1st user var recentUsers = new UserAccounts(); recentUsers.GetNewestUsers(); if (recentUsers.Count == 1) { var adminRole = new Role(SiteEnums.RoleTypes.admin.ToString()); UserAccountRole.AddUserToRole(ua.UserAccountID, adminRole.RoleID); } var dm = new DirectMessage {IsRead = false}; var communityManager = new UserAccount(SiteDomain.GetSiteDomainValue( SiteEnums.SiteBrandType.GRTUR, Utilities.GetCurrentLanguageCode()) .Trim()); dm.FromUserAccountID = communityManager.UserAccountID; dm.ToUserAccountID = ua.UserAccountID; sb = new StringBuilder(100); sb.Append(SiteDomain.GetSiteDomainValue( SiteEnums.SiteBrandType.GREET, Utilities.GetCurrentLanguageCode())); dm.Message = sb.ToString(); if (communityManager.UserAccountID != 0) { dm.CreatedByUserID = communityManager.UserAccountID; } dm.Create(); return RedirectToAction("Home", "Account"); } ModelState.AddModelError(string.Empty, AccountValidation.ErrorCodeToString(createStatus)); return View(model); }
public override string[] GetUsersInRole(string roleName) { var rle = new Role(roleName); var allRoles = new ArrayList(); var users = UserAccountRole.GetUsersInRole(rle.RoleID); foreach (UserAccount ua1 in users) allRoles.Add(ua1.UserName); var stringArray = (string[]) allRoles.ToArray(typeof (string)); return stringArray; }