public ManagePrivacyPresenter() { _profileService = ObjectFactory.GetInstance<IProfileService>(); _userSession = ObjectFactory.GetInstance<IUserSession>(); account = _userSession.CurrentUser; profile = _profileService.LoadProfileByAccountID(account.AccountID); }
public ProfilePresenter() { _redirector = ObjectFactory.GetInstance<IRedirector>(); _userSession = ObjectFactory.GetInstance<IUserSession>(); if (!_userSession.LoggedIn || _userSession.CurrentUser == null) _redirector.GoToAccountLoginPage(); _alertService = ObjectFactory.GetInstance<IAlertService>(); _webContext = ObjectFactory.GetInstance<IWebContext>(); _accountService = ObjectFactory.GetInstance<IAccountService>(); _privacyService = ObjectFactory.GetInstance<IPrivacyService>(); _account = _userSession.CurrentUser; if (_webContext.AccountID > 0 && _webContext.AccountID != _userSession.CurrentUser.AccountID) { _accountBeingViewed = _accountService.GetAccountByID(_webContext.AccountID); _accountBeingViewed.Profile = Profile.GetProfileByAccountID(_webContext.AccountID); } else { _accountBeingViewed = _userSession.CurrentUser; _accountBeingViewed.Profile = Profile.GetProfileByAccountID(_userSession.CurrentUser.AccountID); } if (_accountBeingViewed == null) _redirector.GoToAccountLoginPage(); if (_accountBeingViewed.Profile != null && _accountBeingViewed.Profile.ProfileID > 0) _privacyFlags = PrivacyFlag.GetPrivacyFlagsByProfileID(_accountBeingViewed.Profile.ProfileID); else _redirector.GoToHomePage(); }
public static void AddPermission(Account account, Permission permission) { AccountPermission ap = new AccountPermission(); ap.AccountID = account.AccountID; ap.PermissionID = permission.PermissionID; ap.Save(); }
public void Init(IInviteFriends view) { _view = view; _userSession = ObjectFactory.GetInstance<IUserSession>(); _email = ObjectFactory.GetInstance<IEmail>(); _webContext = ObjectFactory.GetInstance<IWebContext>(); _account = _userSession.CurrentUser; if (_account != null) { _view.DisplayToData(_account.FirstName + " " + _account.LastName + " <" + _account.Email + ">"); if (_webContext.AccoundIdToInvite > 0) { _accountToInvite = Account.GetAccountByID(_webContext.AccoundIdToInvite); if (_accountToInvite != null) { SendInvitation(_accountToInvite.Email, _accountToInvite.FirstName + " " + _accountToInvite.LastName + " muốn kết bạn với bạn!"); _view.ShowMessage(" Yêu cầu kết bạn đã được gửi đến" + _accountToInvite.Username); _view.TogglePnlInvite(false); } } } }
public static void AddPermissions(Account account, List<Permission> permissions) { List<AccountPermission> list = new List<AccountPermission>(); foreach (var p in permissions) { AccountPermission ap = new AccountPermission(); ap.AccountID = account.AccountID; ap.PermissionID = p.PermissionID; list.Add(ap); } AccountPermission.AddMany(list); }
//protected void btnViewStatusUpdates_Click(object sender, EventArgs e) //{ // _presenter.GoToStatusUpdates(); //} public void DisplayInfo(Account account) { //lblFirstName.Text = account.FirstName; //lblLastName.Text = account.LastName; //litLastUpdateDate.Text = account.LastUpdateDate.ToString(); litZip.Text = account.Zip; if (account.BirthDate.HasValue) { DateTime dt = (DateTime)account.BirthDate.Value; litBirthDate.Text = string.Format("{0} tháng {1} năm {2}", dt.Day.ToString().PadLeft(2, '0'), dt.Month.ToString().PadLeft(2, '0'), dt.Year); } //litSex.Text = account.Profile.se; if (account.Profile != null) { //litIMAOL.Text = account.Profile.IMAOL; litIMGIM.Text = account.Profile.IMGIM; //litIMICQ.Text = account.Profile.IMICQ; //litIMMSN.Text = account.Profile.IMMSN; //litIMSkype.Text = account.Profile.IMSkype; litIMYIM.Text = account.Profile.IMYIM; litNumberOfTanksOwned.Text = account.Profile.Address.ToString(); litNumberOfFishOwned.Text = account.Profile.Enjoy.ToString(); litYearOfFirstTank.Text = account.Profile.SchoolsName.ToString(); //litLevelOfExperience.Text = "(" + account.Profile.LevelOfExperienceType.LevelOfExperience + ")"; //if (account.Profile.Attributes.Count > 0) //{ // foreach (ProfileAttribute attribute in account.Profile.Attributes) // { // if (_presenter.IsAttributeVisible(attribute.ProfileAttributeType.PrivacyFlagTypeID)) // { // //phAttributes.Controls.Add(new LiteralControl("<div class=\"divContainerTitle\">")); // //phAttributes.Controls.Add(new LiteralControl(attribute.ProfileAttributeType.AttributeType)); // //phAttributes.Controls.Add(new LiteralControl("</div>")); // //phAttributes.Controls.Add(new LiteralControl("<div class=\"divContainerRow\"><div class=\"divContainerCell\">")); // //phAttributes.Controls.Add(new LiteralControl(attribute.Response)); // //phAttributes.Controls.Add(new LiteralControl("</div></div>")); // phAttributes.Controls.Add(new LiteralControl("<div class=\"box profile\"><h2>")); // phAttributes.Controls.Add(new LiteralControl(attribute.ProfileAttributeType.AttributeType)); // phAttributes.Controls.Add(new LiteralControl("</h2>")); // phAttributes.Controls.Add(new LiteralControl(string.Format("<div class=\"block-c\" id=\"att-{0}\">", attribute.ProfileAttributeID))); // phAttributes.Controls.Add(new LiteralControl(attribute.Response)); // phAttributes.Controls.Add(new LiteralControl("</div></div>")); // } // } //} } }
public static void SaveAccount(Account account) { account.LastUpdateDate = DateTime.Now; if (account.AccountID > 0) { Account.Update(account); } else { account.CreateDate = DateTime.Now; Account.Add(account); } }
public FriendsPresenter() { _userSession = ObjectFactory.GetInstance<IUserSession>(); _webContext = ObjectFactory.GetInstance<IWebContext>(); _config = ObjectFactory.GetInstance<IConfiguration>(); if (_userSession.CurrentUser == null) return; if (_webContext.AccountID > 0 && _webContext.AccountID != _userSession.CurrentUser.AccountID) _accountBeingViewed = Account.GetAccountByID(_webContext.AccountID); else _accountBeingViewed = _userSession.CurrentUser; pageSize = _config.PageNumItem; totalItems = Friend.GetFriendsAccountsByAccountID(_accountBeingViewed.AccountID).Count; }
public DefaultPresenter() { _redirector = ObjectFactory.GetInstance<IRedirector>(); _userSession = ObjectFactory.GetInstance<IUserSession>(); if (!_userSession.LoggedIn || _userSession.CurrentUser == null) _redirector.GoToAccountLoginPage(); _alertService = ObjectFactory.GetInstance<IAlertService>(); _webContext = ObjectFactory.GetInstance<IWebContext>(); _accountService = ObjectFactory.GetInstance<IAccountService>(); _privacyService = ObjectFactory.GetInstance<IPrivacyService>(); if (_webContext.AccountID > 0 && _webContext.AccountID != _userSession.CurrentUser.AccountID) _accountBeingViewed = _accountService.GetAccountByID(_webContext.AccountID); else _accountBeingViewed = _userSession.CurrentUser; }
protected void Page_Load(object sender, EventArgs e) { _userSession = ObjectFactory.GetInstance<IUserSession>(); _webContext = ObjectFactory.GetInstance<IWebContext>(); if (_webContext.AccountID == -999 && _userSession.LoggedIn && _userSession.UploadImage != null) { Response.Clear(); //Response.ContentType = profile.AvatarMimeType; Response.BinaryWrite(_userSession.UploadImage); return; } //load an image by passed in accountid if (_webContext.AccountID > 0) { accountID = _webContext.AccountID; profile = Profile.GetProfileByAccountID(accountID); account = Account.GetAccountByID(accountID); } //get an image for the current user else { if (_userSession.LoggedIn && _userSession.CurrentUser != null) { account = _userSession.CurrentUser; profile = Profile.GetProfileByAccountID(account.AccountID); } } //show the appropriate image if (_webContext.ShowGravatar || (profile != null && profile.UseGravatar == 1)) { Response.Redirect(GetGravatarURL()); } else if (profile != null && profile.Avatar != null) { Response.Clear(); Response.ContentType = profile.AvatarMimeType; Response.BinaryWrite(profile.Avatar.ToArray()); } else { Response.Redirect("~/images/ProfileAvatar/default.jpg"); } }
public void LoadDisplay(Account account) { _account = account; ibInviteFriend.Attributes.Add("FriendsID", _account.AccountID.ToString()); ibDelete.Attributes.Add("FriendsID", _account.AccountID.ToString()); litAccountID.Text = account.AccountID.ToString(); litAccountID2.Text = account.AccountID.ToString(); //lblCreateDate.Text = account.CreateDate.ToString(); imgAvatar.ImageUrl += "?AccountID=" + account.AccountID.ToString(); lblFriendID.Text = account.AccountID.ToString(); //lblUsername.Text = account.Username; //lblLastName.Text = account.LastName; //lblFirstName.Text = account.FirstName; lblName.Text = account.LastName + " " + account.FirstName; }
public void Register(string username, string password, string firstname, string lastname, string email, DateTime birthDate, string captcha, bool agreeswithterms, int termid) { if (agreeswithterms) { if (captcha == _webContext.CaptchaImageText) { if (_accountService.EmailInUse(email)) { _view.ShowErrorMessage("Email này đã được sử dụng!"); //_view.ToggleWizardIndex(0); } else if (_accountService.UsernameInUse(username)) { _view.ShowErrorMessage("Tên tài khoản này đã được sử dụng!"); //_view.ToggleWizardIndex(0); } else { Account account = new Account(); account.FirstName = firstname; account.LastName = lastname; account.Email = email; account.BirthDate = birthDate; account.Username = username; account.Password = Cryptography.Encrypt(password, username); account.TermID = termid; try { Account.SaveAccount(account); Permission publicPermission = Permission.GetPermissionByName("PUBLIC"); Permission registeredPermission = Permission.GetPermissionByName("REGISTERED"); List<Permission> list = new List<Permission>(); list.Add(publicPermission); list.Add(registeredPermission); Account.AddPermissions(account, list); //if this registration came via a friend request... if (friendInvitation != null) { _friendService.CreateFriendFromFriendInvitation(new Guid(_webContext.FriendshipRequest), account); } // _email.SendEmailAddressVerificationEmail(username, account.Email); _view.ShowAccountCreatedPanel(); _view.ShowVerifyEmailTest(); } catch (Exception) { _view.ShowErrorMessage("Lỗi hệ thống!"); //_view.ToggleWizardIndex(0); } } } else { _view.ShowErrorMessage("Mã xác nhận không đúng, vui lòng nhập lại."); } } else { //_view.ToggleWizardIndex(2); _view.ShowErrorMessage("Vui lòng đồng ý với thỏa thuận sử dụng!"); } }