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); }
protected void Application_AuthenticateRequest(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(Request.QueryString[SiteEnums.QueryStringNames.language.ToString()]) || User == null) return; MembershipUser mu = MembershipWrapper.GetUser(); if (mu == null) return; var uad = new UserAccountDetail(); uad.GetUserAccountDeailForUser(Convert.ToInt32(mu.ProviderUserKey)); string language = Request.QueryString[SiteEnums.QueryStringNames.language.ToString()]; uad.DefaultLanguage = language; uad.Update(); }
protected void Page_Load(object sender, EventArgs e) { string email = Server.UrlDecode(Request.QueryString[SiteEnums.QueryStringNames.email.ToString()]); string autoUnSub = Server.UrlDecode(Request.QueryString[SiteEnums.QueryStringNames.autounsubscribe.ToString()]); if (!string.IsNullOrWhiteSpace(email) && !string.IsNullOrWhiteSpace(autoUnSub)) { var ua = new UserAccount(); ua.GetUserAccountByEmail(email); var uad = new UserAccountDetail(); uad.GetUserAccountDeailForUser(ua.UserAccountID); uad.EmailMessages = false; uad.Update(); } }
protected void btnSubmit_Click(object sender, EventArgs e) { var ua = new UserAccount(); ua.GetUserAccountByEmail(txtEmail.Text.Trim()); if (ua.UserAccountID == 0) { litResult.Text = @"<span style=""color:red"">Email not found!</span>"; return; } var uad = new UserAccountDetail(); uad.GetUserAccountDeailForUser(ua.UserAccountID); uad.EmailMessages = false; if (uad.Update()) { litResult.Text = @"<span style=""color:green"">Unsubscribed!</span>"; } else { litResult.Text = @"<span style=""color:red"">error!</span>"; } }
private void SetUserAccountToEdit(UserAccount ua) { ViewBag.SelectedUser = ua; var uad = new UserAccountDetail(); uad.GetUserAccountDeailForUser(ua.UserAccountID); ViewBag.UserAccountDetail = uad; }
public ActionResult RequestApproval(int contentID) { var content = new Content(contentID) { CurrentStatus = Convert.ToChar(SiteEnums.ContentStatus.P.ToString()), UpdatedByUserID = Convert.ToInt32(_mu.ProviderUserKey) }; content.Set(); var dm = new DirectMessage { IsRead = false }; if (_mu != null) dm.FromUserAccountID = Convert.ToInt32(_mu.ProviderUserKey); var admin = new UserAccount(GeneralConfigs.AdminUserName); dm.ToUserAccountID = admin.UserAccountID; dm.Message = "Content To Approve: " + content.PreviewLink; if (_mu != null) { var currentUserId = Convert.ToInt32(_mu.ProviderUserKey); // ignore low quality users if (currentUserId == 18136) return RedirectToAction("Articles"); dm.CreatedByUserID = currentUserId; dm.Create(); } var uad = new UserAccountDetail(); uad.GetUserAccountDeailForUser(admin.UserAccountID); if (uad.EmailMessages) { _mail.SendMail( AmazonCloudConfigs.SendFromEmail, admin.EMail, string.Format("{0}: {1}", Messages.From, _mu.UserName), dm.Message); } return RedirectToAction("Articles"); }
public ActionResult ProfileDetail(string userName) { ViewBag.VideoHeight = (Request.Browser.IsMobileDevice) ? 100 : 277; ViewBag.VideoWidth = (Request.Browser.IsMobileDevice) ? 225 : 400; _ua = new UserAccount(userName); var uad = new UserAccountDetail(); uad.GetUserAccountDeailForUser(_ua.UserAccountID); uad.BandsSeen = ContentLinker.InsertBandLinks(uad.BandsSeen, false); uad.BandsToSee = ContentLinker.InsertBandLinks(uad.BandsToSee, false); var model = new ProfileModel(); model.ProfilePhotoMainRaw = uad.RawProfilePicUrl; if (_ua.UserAccountID > 0) { model.UserAccountID = _ua.UserAccountID; model.PhotoCount = PhotoItems.GetPhotoItemCountForUser(_ua.UserAccountID); model.CreateDate = _ua.CreateDate; } if (_mu != null) { ViewBag.IsBlocked = BlockedUser.IsBlockedUser(_ua.UserAccountID, Convert.ToInt32(_mu.ProviderUserKey)); ViewBag.IsBlocking = BlockedUser.IsBlockedUser(Convert.ToInt32(_mu.ProviderUserKey), _ua.UserAccountID); if (_ua.UserAccountID == Convert.ToInt32(_mu.ProviderUserKey)) { model.IsViewingSelf = true; } else { var ucon = new UserConnection(); ucon.GetUserToUserConnection(Convert.ToInt32(_mu.ProviderUserKey), _ua.UserAccountID); model.UserConnectionID = ucon.UserConnectionID; if (BlockedUser.IsBlockedUser(Convert.ToInt32(_mu.ProviderUserKey), _ua.UserAccountID)) { return RedirectToAction("index", "home"); } } } else { if (uad.MembersOnlyProfile) { return RedirectToAction("LogOn", "Account"); } } ViewBag.ThumbIcon = uad.FullProfilePicURL; SetModelForUserAccount(model, uad); // var su = new StatusUpdate(); su.GetMostRecentUserStatus(_ua.UserAccountID); if (su.StatusUpdateID > 0) { model.LastStatusUpdate = su.CreateDate; model.MostRecentStatusUpdate = su.Message; } model.ProfileVisitorCount = ProfileLog.GetUniqueProfileVisitorCount(_ua.UserAccountID); GetUserPhotos(model); GetUserNews(model); model.MetaDescription = _ua.UserName + " " + Messages.Profile + " " + FromDate.DateToYYYY_MM_DD(_ua.LastActivityDate); GetUserPlaylist(); ForumThreads(_ua.UserAccountID, model); if (uad.UserAccountID > 0) { model.Birthday = uad.BirthDate; if (uad.ShowOnMapLegal) { // because of the foreign cultures, numbers need to stay in the English version unless a javascript encoding could be added string currentLang = Utilities.GetCurrentLanguageCode(); Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(SiteEnums.SiteLanguages.EN.ToString()); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(SiteEnums.SiteLanguages.EN.ToString()); model.DisplayOnMap = uad.ShowOnMapLegal; var rnd = new Random(); int offset = rnd.Next(10, 100); SiteStructs.LatLong latlong = GeoData.GetLatLongForCountryPostal(uad.Country, uad.PostalCode); if (latlong.latitude != 0 && latlong.longitude != 0) { model.Latitude = Convert.ToDecimal(latlong.latitude + Convert.ToDouble("0.00" + offset)) .ToString(CultureInfo.InvariantCulture); model.Longitude = Convert.ToDecimal(latlong.longitude + Convert.ToDouble("0.00" + offset)) .ToString(CultureInfo.InvariantCulture); } else { model.DisplayOnMap = false; } Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(currentLang); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(currentLang); } ViewBag.ThumbIcon = uad.FullProfilePicThumbURL; LoadCurrentImagesViewBag(uad.UserAccountID); } ViewBag.UserAccountDetail = uad; ViewBag.UserAccount = _ua; GetUserContacts(model); UserAccountDetail uadLooker = null; if (_mu != null) { uadLooker = new UserAccountDetail(); uadLooker.GetUserAccountDeailForUser(Convert.ToInt32(_mu.ProviderUserKey)); } if (uadLooker != null && (_mu != null && _ua.UserAccountID > 0 && uadLooker.EnableProfileLogging && uad.EnableProfileLogging)) { var pl = new ProfileLog { LookedAtUserAccountID = _ua.UserAccountID, LookingUserAccountID = Convert.ToInt32(_mu.ProviderUserKey) }; if (pl.LookingUserAccountID != pl.LookedAtUserAccountID) pl.Create(); ArrayList al = ProfileLog.GetRecentProfileViews(_ua.UserAccountID); if (al != null && al.Count > 0) { var uas = new UserAccounts(); foreach (UserAccount viewwer in al.Cast<int>().Select(id => new UserAccount(id)) .Where(viewwer => !viewwer.IsLockedOut && viewwer.IsApproved) .TakeWhile(viewwer => uas.Count < Maxcountusers)) { uas.Add(viewwer); } } } GetUserAccountVideos(); // this is either a youtube user or this is a band var art = new Artist(); art.GetArtistByAltname(userName); if (art.ArtistID > 0) { // try this way for dashers model.UserName = art.Name; } var vids = new Videos(); var sngrs = new SongRecords(); if (art.ArtistID == 0) { vids.GetAllVideosByUser(userName); var uavs = new UserAccountVideos(); uavs.GetRecentUserAccountVideos(_ua.UserAccountID, 'U'); foreach (Video f2 in uavs.Select(uav1 => new Video(uav1.VideoID)).Where(f2 => !vids.Contains(f2))) { vids.Add(f2); } vids.Sort((x, y) => (y.PublishDate.CompareTo(x.PublishDate))); model.UserName = _ua != null ? _ua.UserName : userName; } else { GetArtistProfile(art, vids); } vids.Sort((p1, p2) => p2.PublishDate.CompareTo(p1.PublishDate)); sngrs.AddRange(vids.Select(v1 => new SongRecord(v1))); if (_mu != null && _ua.UserAccountID != Convert.ToInt32(_mu.ProviderUserKey)) { var uc1 = new UserConnection(); uc1.GetUserToUserConnection(_ua.UserAccountID, Convert.ToInt32(_mu.ProviderUserKey)); if (uc1.UserConnectionID > 0) { switch (uc1.StatusType) { case 'C': if (uc1.IsConfirmed) { model.IsCyberFriend = true; } else { model.IsWatingToBeCyberFriend = true; } break; case 'R': if (uc1.IsConfirmed) { model.IsRealFriend = true; } else { model.IsWatingToBeRealFriend = true; } break; default: model.IsDeniedCyberFriend = true; model.IsDeniedRealFriend = true; break; } } } if (sngrs.Count == 0 && art.ArtistID == 0 && _ua.UserAccountID == 0) { // no longer exists Response.RedirectPermanent("/"); return new EmptyResult(); } var sngDisplay = new SongRecords(); sngDisplay.AddRange(from sr1 in sngrs let vidToShow = new Video(sr1.VideoID) where vidToShow.IsEnabled select sr1); model.SongRecords = sngDisplay.VideosList(); return View(model); }
public ActionResult EditProfile(UserAccountDetail uad) { // must change culture because decimal will not be correct for long/ lat string currentLang = Utilities.GetCurrentLanguageCode(); if (currentLang == null) throw new ArgumentNullException("uad"); Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(SiteEnums.SiteLanguages.EN.ToString()); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(SiteEnums.SiteLanguages.EN.ToString()); LoadCountries(); InterestIdentityViewBags(); if (_mu != null) { var uadCurrent = new UserAccountDetail {UserAccountID = Convert.ToInt32(_mu.ProviderUserKey)}; uadCurrent.GetUserAccountDeailForUser(uadCurrent.UserAccountID); ViewBag.IsValid = true; ViewBag.ProfileUpdated = false; DateTime dt; if (DateTime.TryParse(Request.Form["birthyear"] + "-" + Request.Form["birthmonth"] + "-" + Request.Form["birthday"], out dt)) { uad.BirthDate = dt; } else { ViewBag.IsValid = false; ModelState.AddModelError(string.Empty, Messages.Invalid + @": " + Messages.BirthDate); return View(uad); } if (string.IsNullOrEmpty(uad.Country) || uad.Country == Messages.DashSelect) { uad.Country = string.Empty; ViewBag.IsValid = false; ModelState.AddModelError(string.Empty, Messages.Invalid + @": " + Messages.Country); return View(uad); } if (uad.YouAreID == null) { ViewBag.IsValid = false; ModelState.AddModelError(string.Empty, Messages.Invalid + @": " + Messages.YouAre); return View(uad); } if (uad.InterestedInID == null) { ViewBag.IsValid = false; ModelState.AddModelError(string.Empty, Messages.Invalid + @": " + Messages.InterestedIn); return View(uad); } if (!string.IsNullOrEmpty(uad.ExternalURL.Trim()) && !Uri.IsWellFormedUriString(uad.ExternalURL, UriKind.Absolute)) { ViewBag.IsValid = false; ModelState.AddModelError(string.Empty, Messages.Invalid + @": " + Messages.Website); return View(uad); } bool isNewProfile = string.IsNullOrEmpty(uad.Country.Trim()); uadCurrent.AboutDesc = uad.AboutDesc; uadCurrent.HardwareSoftware = uad.HardwareSoftware; uadCurrent.BirthDate = uad.BirthDate; uadCurrent.YouAreID = uad.YouAreID; uadCurrent.ExternalURL = uad.ExternalURL; uadCurrent.Country = uad.Country; uadCurrent.PostalCode = uad.PostalCode; uadCurrent.BandsSeen = uad.BandsSeen; uadCurrent.BandsToSee = uad.BandsToSee; uadCurrent.RelationshipStatusID = uad.RelationshipStatusID; uadCurrent.InterestedInID = uad.InterestedInID; uadCurrent.FirstName = uad.FirstName; uadCurrent.LastName = uad.LastName; if (!string.IsNullOrWhiteSpace(uad.Country) && !string.IsNullOrWhiteSpace(uad.PostalCode)) { SiteStructs.LatLong latlong = GeoData.GetLatLongForCountryPostal(uad.Country, uad.PostalCode); // ReSharper disable CompareOfFloatsByEqualityOperator if (latlong.latitude != 0 && latlong.longitude != 0) // ReSharper restore CompareOfFloatsByEqualityOperator { uad.Latitude = Convert.ToDecimal(latlong.latitude); uad.Longitude = Convert.ToDecimal(latlong.longitude); uadCurrent.Latitude = uad.Latitude; uadCurrent.Longitude = uad.Longitude; } } if (uadCurrent.Set() > 0) { ViewBag.ProfileUpdated = true; } else { ModelState.AddModelError(string.Empty, Messages.Error); } if (isNewProfile) { return RedirectToAction("EditPhoto"); } } Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(currentLang); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(currentLang); return View(uad); }
public ActionResult EditPhotoDelete() { string str = Request.Form["delete_photo"]; _uad = new UserAccountDetail(); if (_mu != null) _uad.GetUserAccountDeailForUser(Convert.ToInt32(_mu.ProviderUserKey)); var s3 = new S3Service { AccessKeyID = AmazonCloudConfigs.AmazonAccessKey, SecretAccessKey = AmazonCloudConfigs.AmazonSecretKey }; switch (str) { case "1": try { if (!string.IsNullOrWhiteSpace(_uad.RawProfilePicUrl) && s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, _uad.RawProfilePicUrl)) { s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, _uad.RawProfilePicUrl); } if (s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, _uad.ProfilePicURL)) { s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, _uad.ProfilePicURL); } if (s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, _uad.ProfileThumbPicURL)) { s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, _uad.ProfileThumbPicURL); } } catch { // whatever } // set to blank the profile images that were deleted _uad.RawProfilePicUrl = string.Empty; _uad.ProfileThumbPicURL = string.Empty; _uad.ProfilePicURL = string.Empty; _uad.Update(); break; case "3": case "2": _ups = new UserPhotos(); _ups.GetUserPhotos(_uad.UserAccountID); foreach (UserPhoto up1 in _ups) { try { if ((up1.RankOrder != 1 || str != "2") && (up1.RankOrder != 2 || str != "3")) continue; if (!string.IsNullOrWhiteSpace(up1.RawPicUrl) && s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, up1.RawPicUrl)) { s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, up1.RawPicUrl); } if (s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, up1.PicURL)) { s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, up1.PicURL); } if (s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, up1.ThumbPicURL)) { s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, up1.ThumbPicURL); } up1.Delete(); } catch { // whatever } } _ups = new UserPhotos(); _ups.GetUserPhotos(_uad.UserAccountID); if (_ups.Count == 1 && _ups[0].RankOrder == 2) { _ups[0].RankOrder = 1; _ups[0].Update(); } break; } return RedirectToAction("EditPhoto"); }
public ActionResult EditPhoto(HttpPostedFileBase file) { UserPhoto up1 = null; var currentUserId = Convert.ToInt32(_mu.ProviderUserKey); int swapID; const CannedAcl acl = CannedAcl.PublicRead; var s3 = new S3Service { AccessKeyID = AmazonCloudConfigs.AmazonAccessKey, SecretAccessKey = AmazonCloudConfigs.AmazonSecretKey }; if (Request.Form["new_default"] != null && int.TryParse(Request.Form["new_default"], out swapID)) { // swap the default with the new default up1 = SwapOutDefaultPhoto(currentUserId, swapID); return View(_uad); } const string photoOne = "photo_edit_1"; const string photoTwo = "photo_edit_2"; const string photoThree = "photo_edit_3"; if (_mu != null) LoadCurrentImagesViewBag(currentUserId); _uad = new UserAccountDetail(); if (_mu != null) _uad.GetUserAccountDeailForUser(currentUserId); if (file == null) { ViewBag.IsValid = false; ModelState.AddModelError(string.Empty, Messages.NoFile); return View(_uad); } string photoEdited = Request.Form["photo_edit"]; string rawPhotoToDelete = string.Empty; string mainPhotoToDelete = string.Empty; string thumbPhotoToDelete = string.Empty; _ups = new UserPhotos(); _ups.GetUserPhotos(_uad.UserAccountID); if (string.IsNullOrEmpty(_uad.ProfilePicURL) || _ups.Count == 2 && photoEdited == photoOne) { rawPhotoToDelete = _uad.RawProfilePicUrl; mainPhotoToDelete = _uad.ProfilePicURL; thumbPhotoToDelete = _uad.ProfileThumbPicURL; } else { if (_ups.Count > 1 && photoEdited == photoTwo) { up1 = new UserPhoto(_ups[0].UserPhotoID) { RankOrder = 1 }; rawPhotoToDelete = up1.RawPicUrl; mainPhotoToDelete = up1.PicURL; thumbPhotoToDelete = up1.ThumbPicURL; } else if (_ups.Count > 1 && photoEdited == photoThree) { up1 = new UserPhoto(_ups[1].UserPhotoID) { RankOrder = 2 }; rawPhotoToDelete = up1.RawPicUrl; mainPhotoToDelete = up1.FullProfilePicURL; thumbPhotoToDelete = up1.ThumbPicURL; } } if (!string.IsNullOrEmpty(mainPhotoToDelete)) { DeletePhotos(s3, rawPhotoToDelete, mainPhotoToDelete, thumbPhotoToDelete); } var photoBitmap = new Bitmap(file.InputStream); // 300x 300 and raw up1 = ProcessMainPhotoItem(file, up1, currentUserId, acl, s3, photoOne, photoTwo, photoThree, photoEdited, photoBitmap); // 75 x 75 (thumbnail) var thumbFileName = AddPhotoToBucket(file, acl, s3, photoBitmap, true, 75, 75); if (string.IsNullOrEmpty(_uad.ProfileThumbPicURL) || _ups.Count == 2 && photoEdited == photoOne) { _uad.ProfileThumbPicURL = thumbFileName; _uad.LastPhotoUpdate = DateTime.UtcNow; _uad.Set(); } else { if (up1 != null) { if (_mu != null) up1.UserAccountID = currentUserId; up1.ThumbPicURL = thumbFileName; if ( (_ups.Count == 0 && photoEdited == photoTwo) || (_ups.Count > 0 && photoEdited == photoTwo) ) { up1.RankOrder = 1; } else if ( (_ups.Count == 0 && photoEdited == photoThree) || (_ups.Count > 1 && photoEdited == photoThree) ) { up1.RankOrder = 2; } } } photoBitmap.Dispose(); if (up1 != null && up1.UserPhotoID == 0) { if (_mu != null) up1.CreatedByUserID = currentUserId; up1.Create(); } else if (up1 != null && up1.UserPhotoID > 0) { up1.UpdatedByUserID = currentUserId; up1.Update(); } LoadCurrentImagesViewBag(currentUserId); return View(_uad); }
public ActionResult Send() { string displayname = Request.Form["displayname"]; string msg = Request.Form["message"]; _ua = new UserAccount(displayname); if (_mu != null && (string.IsNullOrEmpty(msg) || Lib.BOL.BlockedUser.IsBlockedUser(_ua.UserAccountID, Convert.ToInt32( _mu.ProviderUserKey))) ) { return RedirectToAction("Reply", new {@userName = displayname}); } var dm = new DirectMessage {IsRead = false}; if (_mu != null) dm.FromUserAccountID = Convert.ToInt32(_mu.ProviderUserKey); dm.ToUserAccountID = _ua.UserAccountID; dm.Message = msg; if (_mu != null) dm.CreatedByUserID = Convert.ToInt32(_mu.ProviderUserKey); dm.Create(); var language = Utilities.GetCurrentLanguageCode(); _uad = new UserAccountDetail(); _uad.GetUserAccountDeailForUser(_ua.UserAccountID); Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(_uad.DefaultLanguage); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(_uad.DefaultLanguage); var sb = new StringBuilder(); sb.Append(Messages.Hello); sb.Append(","); sb.AppendLine(Environment.NewLine); sb.AppendLine(Environment.NewLine); sb.AppendFormat("{0}: ", Messages.From); sb.Append(GeneralConfigs.SiteDomain); sb.Append("/"); if (_mu != null) sb.Append(_mu.UserName); sb.AppendLine(Environment.NewLine); sb.AppendFormat("{0}: ", Messages.Message); sb.AppendFormat(GeneralConfigs.SiteDomain + "/account/inbox"); sb.AppendLine(Environment.NewLine); sb.AppendFormat("{0}: {1}", Messages.SignIn, GeneralConfigs.SiteDomain); sb.AppendLine(Environment.NewLine); if (_uad.EmailMessages) { if (_mu != null) _mail.SendMail( AmazonCloudConfigs.SendFromEmail, _ua.EMail, string.Format("{0}: {1}", Messages.From, _mu.UserName), sb.ToString()); } Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(language); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(language); return RedirectToAction("Reply", new {@userName = displayname}); }
public ActionResult ConfirmContactRequest(string input) { NameValueCollection qury = HttpUtility.ParseQueryString(input); var userToBe = new UserAccount(qury["username"]); var ucToSet = new UserConnection(); if (_mu != null) ucToSet.GetUserToUserConnection(Convert.ToInt32(_mu.ProviderUserKey), userToBe.UserAccountID); if (ucToSet.UserConnectionID == 0 && qury["rslt"] == "0") { // they never set anything up and are ending the request Response.Redirect("~/" + userToBe.UserName); } else if (ucToSet.UserConnectionID != 0 && qury["rslt"] == "0") { if (_mu != null && Convert.ToInt32(_mu.ProviderUserKey) != ucToSet.CreatedByUserID) { // one user sent a request and now it's rejected ucToSet.StatusType = 'L'; ucToSet.UpdatedByUserID = Convert.ToInt32(_mu.ProviderUserKey); ucToSet.IsConfirmed = true; ucToSet.Update(); if (_mu != null) Response.Redirect("/" + _mu.UserName); } else { // this is assumed to be not a declude because it is a reject by the issuer Response.Redirect("/" + userToBe.UserName); } } else if (ucToSet.UserConnectionID == 0 && qury["rslt"] == "1") { // they are not yet connected and are requesting to begin a connection ucToSet.IsConfirmed = false; if (_mu != null) { ucToSet.CreatedByUserID = Convert.ToInt32(_mu.ProviderUserKey); ucToSet.FromUserAccountID = Convert.ToInt32(_mu.ProviderUserKey); } ucToSet.ToUserAccountID = userToBe.UserAccountID; ucToSet.StatusType = Convert.ToChar(qury["contacttype"]); ucToSet.Create(); Response.Redirect("/" + userToBe.UserName); } else if (ucToSet.UserConnectionID > 0 && qury["rslt"] == "1") { // there was a request that is being confirmed if (ucToSet.StatusType == Convert.ToChar(qury["contacttype"])) { ucToSet.IsConfirmed = true; } else { // upgrading the request ucToSet.IsConfirmed = false; if (_mu != null && Convert.ToInt32(_mu.ProviderUserKey) == ucToSet.ToUserAccountID) { // the opposite this time ucToSet.FromUserAccountID = Convert.ToInt32(_mu.ProviderUserKey); ucToSet.ToUserAccountID = userToBe.UserAccountID; } } if (_mu != null) ucToSet.UpdatedByUserID = Convert.ToInt32(_mu.ProviderUserKey); ucToSet.StatusType = Convert.ToChar(qury["contacttype"]); ucToSet.Update(); switch (Convert.ToChar(qury["contacttype"])) { case 'R': if (ucToSet.IsConfirmed) { if (_mu != null) { Response.Redirect("~/account/irlcontacts/" + _mu.UserName); } } else { var requestedUserDetails = new UserAccountDetail(); requestedUserDetails.GetUserAccountDeailForUser(userToBe.UserAccountID); NotifyUserOfContactRequest(userToBe); Response.Redirect("/" + userToBe.UserName); } break; case 'C': if (ucToSet.IsConfirmed) { if (_mu != null) { Response.Redirect("~/account/CyberAssociates/" + _mu.UserName); } } else { NotifyUserOfContactRequest(userToBe); Response.Redirect("~/" + userToBe.UserName); } break; case 'L': if (_mu != null) Response.Redirect("~/" + _mu.UserName); break; } } return View(); }
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 ActionResult MyUsers() { if (_mu != null) { ViewBag.CurrentUserName = _mu.UserName; if (_mu != null) { _uad = new UserAccountDetail(); _uad.GetUserAccountDeailForUser(Convert.ToInt32(_mu.ProviderUserKey)); ViewBag.EnableProfileLogging = _uad.EnableProfileLogging; } } var unconfirmedUsers = new UserConnections(); var allusrcons = new UserConnections(); if (_mu != null) { allusrcons.GetUserConnections(Convert.ToInt32(_mu.ProviderUserKey)); unconfirmedUsers.AddRange( allusrcons.Where( uc1 => !uc1.IsConfirmed && Convert.ToInt32(_mu.ProviderUserKey) != uc1.FromUserAccountID)); } ViewBag.ApprovalList = unconfirmedUsers.ToUnorderdList; ViewBag.BlockedUsers = _mu != null && Lib.BOL.BlockedUsers.HasBlockedUsers(Convert.ToInt32(_mu.ProviderUserKey)); return View(); }
public ActionResult LogOn(LogOnModel model, string returnUrl) { if (ModelState.IsValid) { var remember = Convert.ToBoolean(model.RememberMe); if (string.IsNullOrWhiteSpace(model.UserName) || string.IsNullOrWhiteSpace(model.Password)) { return View(model); } _ua = new UserAccount(model.UserName); if (_ua.UserAccountID == 0) { _ua = new UserAccount(); _ua.GetUserAccountByEmail(model.UserName); if (_ua.UserAccountID > 0) { // they were stupid and put their email not username model.UserName = _ua.UserName; } } if (Membership.ValidateUser(model.UserName, model.Password)) { FormsAuthentication.RedirectFromLoginPage(model.UserName, remember); if (!String.IsNullOrEmpty(returnUrl)) { return Redirect(returnUrl); } _ua = new UserAccount(model.UserName); if (_ua.IsLockedOut) { ModelState.AddModelError(string.Empty, Messages.IsLockedOut); return View(model); } _ua.LastLoginDate = DateTime.UtcNow; _ua.FailedPasswordAttemptCount = 0; _ua.IsOnLine = true; _ua.SigningOut = false; _ua.Update(); var uad = new UserAccountDetail(); uad.GetUserAccountDeailForUser(_ua.UserAccountID); if (string.IsNullOrWhiteSpace(uad.DefaultLanguage)) return RedirectToAction("Home", "Account"); var nvc = new NameValueCollection { {SiteEnums.CookieValue.language.ToString(), uad.DefaultLanguage} }; Utilities.CookieMaker(SiteEnums.CookieName.Usersetting, nvc); Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(uad.DefaultLanguage); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(uad.DefaultLanguage); return RedirectToAction("Home", "Account"); } _ua = new UserAccount(model.UserName); if (_ua.UserAccountID > 0) { _ua.IsOnLine = false; _ua.SigningOut = true; _ua.Update(); } } ModelState.AddModelError(string.Empty, Messages.LoginUnsuccessfulPleaseCorrect); // If we got this far, something failed, redisplay form return View(model); }
/// <summary> /// Notify the user that there is a contact request /// </summary> /// <param name="userToBe"></param> private void NotifyUserOfContactRequest(UserAccount userToBe) { if (_mu == null) return; string currentLang = Utilities.GetCurrentLanguageCode(); Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(SiteEnums.SiteLanguages.EN.ToString()); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(SiteEnums.SiteLanguages.EN.ToString()); var requestedUserDetails = new UserAccountDetail(); requestedUserDetails.GetUserAccountDeailForUser(userToBe.UserAccountID); if (requestedUserDetails.EmailMessages) { _mail.SendMail(AmazonCloudConfigs.SendFromEmail, userToBe.EMail, string.Format("{0}: {1}", Messages.ContactRequest, _mu.UserName), string.Format("{0}{1}{2}", Messages.ContactRequest, Environment.NewLine, GeneralConfigs.SiteDomain)); } Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(currentLang); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(currentLang); }
private UserPhoto SwapOutDefaultPhoto(int currentUserId, int swapID) { UserPhoto up1; _uad = new UserAccountDetail(); if (_mu != null) _uad.GetUserAccountDeailForUser(currentUserId); string currentDefaultRaw = _uad.RawProfilePicUrl; string currentDefaultMain = _uad.ProfilePicURL; string currentDefaultMainThumb = _uad.ProfileThumbPicURL; up1 = new UserPhoto(swapID); _uad.RawProfilePicUrl = up1.RawPicUrl; _uad.ProfilePicURL = up1.PicURL; _uad.ProfileThumbPicURL = up1.ThumbPicURL; _uad.LastPhotoUpdate = DateTime.UtcNow; _uad.Update(); up1.RawPicUrl = currentDefaultRaw; up1.PicURL = currentDefaultMain; up1.ThumbPicURL = currentDefaultMainThumb; if (_mu != null) up1.UpdatedByUserID = currentUserId; up1.Update(); if (_mu != null) LoadCurrentImagesViewBag(currentUserId); return up1; }
public ActionResult Settings() { ViewBag.IsValid = true; _uad = new UserAccountDetail(); if (_mu != null) _uad.GetUserAccountDeailForUser(Convert.ToInt32(_mu.ProviderUserKey)); ViewBag.UserAccountDetail = _uad; ViewBag.Membership = _mu; return View(_uad); }
public ActionResult EditPhoto() { _uad = new UserAccountDetail(); if (_mu == null) return View(_uad); _uad.GetUserAccountDeailForUser(Convert.ToInt32(_mu.ProviderUserKey)); LoadCurrentImagesViewBag(Convert.ToInt32(_mu.ProviderUserKey)); return View(_uad); }
public ActionResult Settings(NameValueCollection nvc) { ViewBag.IsValid = true; if (_mu != null) _ua = new UserAccount(Convert.ToInt32(_mu.ProviderUserKey)); _uad = new UserAccountDetail(); if (_mu != null) _uad.GetUserAccountDeailForUser(Convert.ToInt32(_mu.ProviderUserKey)); string enableProfileLogging = Request.Form["enableprofilelogging"]; string emailmessages = Request.Form["emailmessages"]; string showonmap = Request.Form["showonmap"]; string displayAge = Request.Form["displayage"]; string membersOnlyProfile = Request.Form["membersonlyprofile"]; _uad.MembersOnlyProfile = !string.IsNullOrEmpty(membersOnlyProfile); _uad.EnableProfileLogging = !string.IsNullOrEmpty(enableProfileLogging); _uad.DisplayAge = !string.IsNullOrEmpty(displayAge); _uad.EmailMessages = !string.IsNullOrEmpty(emailmessages); _uad.ShowOnMap = !string.IsNullOrEmpty(showonmap); _uad.Set(); string username = Request.Form["username"].Trim(); bool isNewUserName = false; bool isValidName; try { isValidName = !Regex.IsMatch(@"[A-Za-z][A-Za-z0-9_]{3,14}", username); } catch { // bad name isValidName = false; } if (_mu.UserName != username && isValidName) { // TODO: PUT IN ALL THE SAME VALIDATION AS REGISTRATION isNewUserName = true; var newUsername = new UserAccount(username.Replace(":", string.Empty) /* still annoying errors */); if (newUsername.UserAccountID != 0) { ViewBag.IsValid = false; ModelState.AddModelError("", Messages.AlreadyInUse + @": " + Messages.UserName); _uad = new UserAccountDetail(); _uad.GetUserAccountDeailForUser(Convert.ToInt32(_mu.ProviderUserKey)); ViewBag.UserAccountDetail = _uad; ViewBag.Membership = _mu; return View(); } if (!Utilities.IsEmail(Request.Form["email"])) { ViewBag.IsValid = false; ModelState.AddModelError("", Messages.Invalid + @": " + Messages.EMail); return View(); } if (Request.Form["email"].Trim() != _ua.EMail) { _ua = new UserAccount(Convert.ToInt32(_mu.ProviderUserKey)) {EMail = Request.Form["email"]}; _ua.Update(); } username = username.Replace(":", string.Empty); username = username.Replace(" ", string.Empty); username = username.Replace(".", string.Empty); _ua.UserName = username; _ua.Update(); FormsAuthentication.SetAuthCookie(username, false); ViewBag.IsValid = true; } else if (!Utilities.IsEmail(Request.Form["email"])) { ViewBag.IsValid = false; ModelState.AddModelError("", Messages.Invalid + @": " + Messages.EMail); return View(); } else if (Request.Form["email"].Trim() != _ua.EMail) { _ua = new UserAccount(Convert.ToInt32(_mu.ProviderUserKey)) {EMail = Request.Form["email"]}; _ua.Update(); } ViewBag.ProfileUpdated = true; _uad = new UserAccountDetail(); _uad.GetUserAccountDeailForUser(Convert.ToInt32(_mu.ProviderUserKey)); ViewBag.UserAccountDetail = _uad; ViewBag.Membership = _mu; if (isNewUserName) { // new username Response.Redirect("~/account/settings/?updated=1"); } return View(); }
public ActionResult EditProfile() { ViewBag.IsValid = true; _uad = new UserAccountDetail(); if (_mu != null) _uad.GetUserAccountDeailForUser(Convert.ToInt32(_mu.ProviderUserKey)); LoadCountries(); InterestIdentityViewBags(); return View(_uad); }
public ActionResult UserAddress(UserAddressModel model) { LoadCountries(); if (_mu != null) _ua = new UserAccount(Convert.ToInt32(_mu.ProviderUserKey)); _uad = new UserAccountDetail(); _uad.GetUserAccountDeailForUser(_ua.UserAccountID); var uadress = new UserAddress(); uadress.GetUserAddress(_ua.UserAccountID); TryUpdateModel(model); if (ModelState.IsValid) { uadress.AddressLine1 = model.AddressLine1; uadress.AddressLine2 = model.AddressLine2; uadress.AddressLine3 = model.AddressLine3; uadress.City = model.City; uadress.CountryISO = model.Country; uadress.FirstName = model.FirstName; uadress.LastName = model.LastName; uadress.PostalCode = model.PostalCode; uadress.Region = model.RegionState; uadress.UserAccountID = _ua.UserAccountID; // uadress.Choice1 = "||" + Request.Form["sex"] + "|" + Request.Form["size"]; if (uadress.UserAddressID == 0) uadress.AddressStatus = 'U'; ViewBag.ProfileUpdated = uadress.Set(); Response.Redirect("/account/home"); } return View(model); }
public ActionResult WriteWallMessage(string message, int toUserAccountID) { _ua = new UserAccount(toUserAccountID); if (_ua.UserAccountID != 0 && !string.IsNullOrWhiteSpace(message)) { if (_mu != null) { var comment = new WallMessage { Message = Server.HtmlEncode(message), ToUserAccountID = toUserAccountID, FromUserAccountID = Convert.ToInt32(_mu.ProviderUserKey), CreatedByUserID = Convert.ToInt32(_mu.ProviderUserKey) }; comment.Create(); var uad = new UserAccountDetail(); uad.GetUserAccountDeailForUser(_ua.UserAccountID); if (uad.EmailMessages) { _mail.SendMail(AmazonCloudConfigs.SendFromEmail, _ua.EMail, "Wall Post From: " + _mu.UserName, _ua.UrlTo.ToString()); } } } return RedirectToAction("ProfileDetail", new {@userName = _ua.UserName}); }
public ActionResult UserAddress() { LoadCountries(); if (_mu != null) _ua = new UserAccount(Convert.ToInt32(_mu.ProviderUserKey)); _uad = new UserAccountDetail(); _uad.GetUserAccountDeailForUser(_ua.UserAccountID); var model = new UserAddressModel(); var uadress = new UserAddress(); uadress.GetUserAddress(_ua.UserAccountID); if (GeneralConfigs.IsGiveAway && uadress.UserAddressID > 0) return View("NotAllowed"); if (uadress.UserAddressID == 0) { model.PostalCode = _uad.PostalCode; model.Country = _uad.Country; } else { model.AddressLine1 = uadress.AddressLine1; model.AddressLine2 = uadress.AddressLine2; model.AddressLine3 = uadress.AddressLine3; model.City = uadress.City; model.Country = uadress.CountryISO; model.FirstName = uadress.FirstName; model.LastName = uadress.LastName; model.PostalCode = uadress.PostalCode; model.RegionState = uadress.Region; } return View(model); }
private void SetModelForUserAccount(ProfileModel model, UserAccountDetail uad) { // model.UserName = _ua.UserName; model.CreateDate = _ua.CreateDate; model.LastActivityDate = _ua.LastActivityDate; // model.DisplayAge = uad.DisplayAge; model.Age = uad.YearsOld; model.BandsSeen = uad.BandsSeen; model.BandsToSee = uad.BandsToSee; model.HardwareAndSoftwareSkills = uad.HardwareSoftware; model.MessageToTheWorld = uad.AboutDescription; model.YouAreFull = uad.Sex; model.InterestedInFull = uad.InterestedFull; model.RelationshipStatusFull = uad.RelationshipStatusFull; model.RelationshipStatus = uad.RelationshipStatus; model.InterestedIn = uad.InterestedIn; model.YouAre = uad.YouAre; model.Website = uad.ExternalURL; model.CountryCode = uad.Country; model.CountryName = uad.CountryName; model.IsBirthday = uad.IsBirthdayToday; model.ProfilePhotoMain = uad.FullProfilePicURL; model.ProfilePhotoMainThumb = uad.FullProfilePicThumbURL; model.DefaultLanguage = uad.DefaultLanguage; model.EnableProfileLogging = uad.EnableProfileLogging; model.Handed = uad.HandedFull; model.RoleIcon = uad.SiteBages; }
public ActionResult Visitors() { _uad = new UserAccountDetail(); if (_mu != null) _ua = new UserAccount(Convert.ToInt32(_mu.ProviderUserKey)); if (_ua.IsAdmin) { ViewBag.AdminLink = "/m/auth/default.aspx"; } _uad.GetUserAccountDeailForUser(_ua.UserAccountID); var uadLooker = new UserAccountDetail(); uadLooker.GetUserAccountDeailForUser(_ua.UserAccountID); var unconfirmedUsers = new UserConnections(); var allusrcons = new UserConnections(); if (_mu != null) { allusrcons.GetUserConnections(Convert.ToInt32(_mu.ProviderUserKey)); unconfirmedUsers.AddRange( allusrcons.Where( uc1 => !uc1.IsConfirmed && Convert.ToInt32(_mu.ProviderUserKey) != uc1.FromUserAccountID)); } ViewBag.ApprovalList = unconfirmedUsers.ToUnorderdList; ViewBag.BlockedUsers = _mu != null && Lib.BOL.BlockedUsers.HasBlockedUsers(Convert.ToInt32(_mu.ProviderUserKey)); ViewBag.EnableProfileLogging = _uad.EnableProfileLogging; if (_mu != null && (Roles.IsUserInRole(_mu.UserName, SiteEnums.RoleTypes.supporter.ToString()) || Roles.IsUserInRole(_mu.UserName, SiteEnums.RoleTypes.admin.ToString()) )) { LoadVisitorsView(_ua.UserName); } return View(); }
public ActionResult UpdateRoles(int userAccountID, IEnumerable<string> roleOption) { var ua = new UserAccount(userAccountID) { IsApproved = (Request.Form["isApproved"] != null), EMail = Request.Form["email"] }; ua.Update(); var uad1 = new UserAccountDetail(); uad1.GetUserAccountDeailForUser(ua.UserAccountID); uad1.EmailMessages = (Request.Form["emailMessages"] != null); uad1.Update(); UserAccountRole.DeleteUserRoles(userAccountID); if (roleOption != null) { foreach (Role thenewRole in roleOption.Select(newRole => new Role(newRole))) { UserAccountRole.AddUserToRole(userAccountID, thenewRole.RoleID); } } if (ua.UserAccountID > 0) { ViewBag.SelectedUser = ua; var uad = new UserAccountDetail(); uad.GetUserAccountDeailForUser(ua.UserAccountID); ViewBag.UserAccountDetail = uad; } LoadAllRoles(); return View("UserManagement"); }
private string GetUserMails(int userAccountId, int pageNumber = 1) { // TODO: IMPROVE PERFORMANCE BY GETTING EVERYTHING IN 1 DB CALL var amountPerPage = PageSize; using (var context = new DasKlubDbContext()) { var query = context.DirectMessage .Where(x => x.toUserAccountID == userAccountId) .GroupBy(s => s.fromUserAccountID) .Select(s => new UserMailModel() { FromUserAccountId = s.Key, LastMessageDateTime = s.Max(m => m.createDate), LastMessageBody = s.OrderByDescending(x => x.createDate).FirstOrDefault().message, TotalUnread = s.Count(x => x.isRead == false && x.fromUserAccountID == s.Key), // UserName = context.UserAccount.Where(x => x.userAccountID == s.Key).FirstOrDefault().userName }); ViewBag.RecordCount = query.Count(); var results = query.OrderByDescending(x => x.LastMessageDateTime) .Skip((pageNumber - 1) * amountPerPage) .Take(amountPerPage) .ToList(); var maxStringLength = 100; foreach (var item in results) { var ua = new UserAccount(item.FromUserAccountId); var uad = new UserAccountDetail(); uad.GetUserAccountDeailForUser(item.FromUserAccountId); item.ResponseToMessageUrl = VirtualPathUtility.ToAbsolute("~/account/reply/") + ua.UserNameLower; item.UserIcon = uad.SmallUserIcon; item.LastMessageBody = FromString.Truncate(item.LastMessageBody, maxStringLength); } var sb = new StringBuilder(); foreach (var formattedItem in results) { sb.Append(@"<div class=""row"">"); sb.Append(@"<div class=""span2 user_icons"" style=""width: 120px;margin-left:0;"">"); sb.Append(@"<ul>"); sb.Append(formattedItem.UserIcon); sb.Append(@"</ul>"); sb.Append(@"</div>"); sb.Append(@"<div class=""span6"">"); sb.AppendFormat(@"<span title=""{0}"">{1}</span>", FromDate.DateToYYYY_MM_DD(formattedItem.LastMessageDateTime), Utilities.TimeElapsedMessage(formattedItem.LastMessageDateTime)); sb.Append(@"<br />"); if (formattedItem.TotalUnread > 0) { sb.AppendFormat(@"<span class=""badge badge-warning"">{0} {1}</span>", formattedItem.TotalUnread, Messages.New); } sb.Append(@"<ul class=""nav nav-pills nav-stacked"">"); sb.Append(@"<li>"); sb.AppendFormat(@"<a href=""{0}"">{1}</a>", formattedItem.ResponseToMessageUrl, formattedItem.LastMessageBody); sb.Append(@"</li>"); sb.Append(@"</ul>"); sb.Append(@"</div>"); sb.Append(@"</div>"); sb.Append(@"<hr />"); } return sb.ToString(); } }
private void SendMassMail(string message) { _mail = new MailService(); int totalSent = 0; var uas = new UserAccounts(); uas.GetAll(); foreach (UserAccount ua1 in uas.OrderBy(x => x.CreateDate)) { var uad = new UserAccountDetail(); uad.GetUserAccountDeailForUser(ua1.UserAccountID); if (!uad.EmailMessages) continue; // safety if (ua1.UserName != "bootlegbaron") continue; var userAddress = new UserAddress(); userAddress.GetUserAddress(ua1.UserAccountID); System.Threading.Thread.Sleep(200); if (_mail.SendMail("*****@*****.**", ua1.EMail, "Das Klub Kalendar 2017 - Competition!", message)) { totalSent++; } else { uad.EmailMessages = false; uad.Update(); } } HttpContext.Current.Response.Write(totalSent); }
private void LoadVisitorsView(string userName) { const int maxcountusers = 100; _uad = new UserAccountDetail(); if (userName != null) _ua = new UserAccount(userName); _uad.GetUserAccountDeailForUser(_ua.UserAccountID); var uadLooker = new UserAccountDetail(); if (_mu == null) return; uadLooker.GetUserAccountDeailForUser(Convert.ToInt32(_mu.ProviderUserKey)); if (_mu == null || _ua.UserAccountID <= 0 || !_uad.EnableProfileLogging || !_uad.EnableProfileLogging) return; ArrayList al = ProfileLog.GetRecentProfileViews(_ua.UserAccountID); if (al == null || al.Count <= 0) return; var uas = new UserAccounts(); foreach (int id in al) { var viewwer = new UserAccount(id); if (viewwer.IsLockedOut || !viewwer.IsApproved) continue; _uad = new UserAccountDetail(); _uad.GetUserAccountDeailForUser(id); if (_uad.EnableProfileLogging == false) continue; if (uas.Count >= maxcountusers) break; uas.Add(viewwer); } ViewBag.TheViewers = uas.ToUnorderdList; }