Beispiel #1
0
        public void Init(IEditAccount View, bool IsPostBack)
        {
            _view = View;
            if (_userSession.LoggedIn)
            {
                if (_userSession.CurrentUser != null)
                {
                    account = _userSession.CurrentUser;
                    List <Permission> permissions = _permissionRepository.GetPermissionsByAccountID(_userSession.CurrentUser.AccountID);
                    foreach (Permission p in permissions)
                    {
                        if (_permissionRepository.GetPermissionByName("OutSider").PermissionID == p.PermissionID)
                        {
                            _view.DisplayAuthentical(false);
                        }
                    }
                }
                else
                {
                    _redirector.GoToAccountLoginPage();
                }

                if (!IsPostBack)
                {
                    LoadCurrentUser();
                }
            }
            else
            {
                _redirector.GoToAccountLoginPage();
            }
        }
        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();

        }
Beispiel #3
0
        public void Init(IManageProfile view, bool IsPostback)
        {
            _view = view;
            if (_userSession.LoggedIn == true)
            {
                _listVisibilityLevel = _privacyRepository.GetVisibilityLevels();

                profile = _profileService.LoadProfileByUserName(_userSession.Username);
                _listProfileAttributeType = _profileAttributeService.GetProfileAttributeType();
                if (profile != null)
                {
                    _listPrivacyFlags = _privacyRepository.GetPrivacyFlagsByProfileID(profile.ProfileID);
                    _view.loadProfileAttribute(_listProfileAttributeType, _listVisibilityLevel, _listPrivacyFlags, profile);
                }
                else
                {
                    profile             = new Profile();
                    profile.AccountID   = _userSession.CurrentUser.AccountID;
                    profile.profileName = _userSession.CurrentUser.UserName;
                    _profileService.SaveProfileTable(profile);
                    AddProfileAttribute(_listProfileAttributeType, profile);
                }
                //_view.LoadProfile(profile);
                _view.ShowProfileName(profile.profileName);
                LoadProfile(IsPostback);
            }
            else
            {
                _redirector.GoToAccountLoginPage();
            }
        }
Beispiel #4
0
 public void Logout()
 {
     _userSession.LoggedIn    = false;
     _userSession.CurrentUser = null;
     _userSession.Username    = "";
     _redirector.GoToAccountLoginPage();
 }
Beispiel #5
0
        public void Init(IHome View, bool IsPostBack)
        {
            _view = View;
            List <VisibilityLevel> _listVisibilityLevel = new List <VisibilityLevel>();

            _listVisibilityLevel = _privacyService.GetListVisibilityLevel();
            if (_userSession.LoggedIn == true)
            {
                IProfileRepository _profileRepository = new ProfileRepository();
                Profile            profile            = _profileRepository.GetProfileByAccountID(_userSession.CurrentUser.AccountID);
                if (profile == null)
                {
                    _redirector.Redirect("~/Profiles/ManageProfile.aspx");
                }
                else
                {
                    _view.LoadStatusControl(_listVisibilityLevel, true);
                    account = _userSession.CurrentUser;
                    if (!IsPostBack)
                    {
                        _view.LoadStatus(GetStatusToShow(account));
                    }
                }
            }
            else
            {
                account = null;
                _redirector.GoToAccountLoginPage();
            }
            _view.DisplayCurrentAccount(account);
        }
Beispiel #6
0
 protected void LinkButton1_Click(object sender, EventArgs e)
 {
     if (_ussersession != null)
     {
         //MessageNew1.LoadTo(_ac.GetAccountByID(idac).UserName);
     }
     else
     {
         _redirect.GoToAccountLoginPage();
     }
 }
Beispiel #7
0
 public void Init(IMyGroups view)
 {
     _view = view;
     if (_usersession.LoggedIn)
     {
         LoadData();
     }
     else
     {
         _redirector.GoToAccountLoginPage();
     }
 }
Beispiel #8
0
 public void Init(IUploadAvatar View)
 {
     _view = View;
     if (_userSession.LoggedIn)
     {
         profile = _profileRepository.GetProfileByAccountID(_userSession.CurrentUser.AccountID);
         if (profile == null || profile.ProfileID < 1)
         {
             _redirector.GoToAccountLoginPage();
         }
     }
 }
Beispiel #9
0
 protected void LinkButton1_Click(object sender, EventArgs e)
 {
     if (_usersession != null)
     {
         Account a = _ac.GetAccountByID(idac);
         bt_invite.Text      = "Đã gửi lời mời";
         bt_invite.ForeColor = System.Drawing.Color.Maroon;
         _email.SendInvitations1(_usersession.CurrentUser, a.Email, " Mời bạn: ");
     }
     else
     {
         _redirect.GoToAccountLoginPage();
     }
 }
Beispiel #10
0
        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>();
            _redirector = ObjectFactory.GetInstance<IRedirector>();
            if (!_userSession.LoggedIn || _userSession.CurrentUser == null)
                _redirector.GoToAccountLoginPage();
            //check profile of current user
            Profile profiles = Profile.GetProfileByAccountID(_userSession.CurrentUser.AccountID);
            //if (profiles == null)
            //    _redirector.GoToProfilesManageProfile();

            if (txtusernam != null)
                txtusernam.InnerHtml = _userSession.CurrentUser.FirstName + " " + _userSession.CurrentUser.LastName;
            

            _navigation = ObjectFactory.GetInstance<INavigation>();
            _alertService = ObjectFactory.GetInstance<IAlertService>();

            //repPrimaryNav.DataSource = _navigation.PrimaryNodes();
            //repPrimaryNav.DataBind();

            if (_navigation.CurrentNode != null)
            {
                if (_navigation.CurrentNode["PageTitle"] != null &&
                    !String.IsNullOrEmpty(_navigation.CurrentNode["PageTitle"]))
                {
                    //lblPageTitle.Text = _navigation.CurrentNode["PageTitle"].ToString();
                    Page.Title = _navigation.CurrentNode["PageTitle"].ToString();
                }
                else
                {
                    //lblPageTitle.Text = _navigation.CurrentNode.Title;
                    Page.Title = _navigation.CurrentNode.Title;
                }
            }

            //if (_userSession.CurrentUser != null)
            //{
            //    LoadStatus();
            //    pnlStatusUpdate.Visible = true;
            //}
            //else
            //    pnlStatusUpdate.Visible = false;
        }
Beispiel #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            _showfriendpresenter = new ShowFriendPresenter();
            _showfriendpresenter.Init(this);
            _webcontext=new WebContext();
            _usersession=new UserSession();
            _ri=new Redirector();

            if (_usersession.CurrentUser!= null)
            {
                if (_usersession.CurrentUser.AccountID != _webcontext.AccountID)
                {
                    lblSearchTerm.Text = "Danh sách bạn bè của " + _webcontext.Username;
                }
                else
                    lblSearchTerm.Text = "Danh sách bạn bè của " + _usersession.CurrentUser.UserName;
            }
            else
                _ri.GoToAccountLoginPage();
        }
Beispiel #13
0
        public void Register(string Username, string Password, string Email, EnumObject Object,
                             string Captcha)
        {
            if (Captcha == _webContext.CaptchaImageText)
            {
                SPKTCore.Core.Domain.Account a =
                    new SPKTCore.Core.Domain.Account();
                a.Email       = Email;
                a.UserName    = Username;
                a.DisplayName = a.UserName;
                a.CreateDate  = DateTime.Now;
                a.Password    = Password.Encrypt(Username);
                a.UseAuthenticationService = false;

                if (_accountService.EmailInUse(Email))
                {
                    _view.ShowErrorMessage("Mail đã được sử dụng");
                }
                else if (_accountService.UsernameInUse(Username))
                {
                    _view.ShowErrorMessage("Tên đăng nhập này đã được sử dụng");
                }
                else
                {
                    string permission = Object.ToString();
                    _accountRepository.SaveAccount(a);
                    if (friendInvitation != null)
                    {
                        _friendService.CreateFriendFromFriendInvitation(new Guid(_webContext.FriendshipRequest), a);
                    }
                    _accountService.Register(a, permission);
                    _redirector.GoToAccountLoginPage();
                }
            }
            else
            {
                _view.ShowErrorMessage("CAPTCHA bạn nhập không đúng! Vui lòng nhập lại");
            }
        }
Beispiel #14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            _redirector = new Redirector();
            _usersession = new UserSession();
            _webcontext=new WebContext();
            _fi=new FriendInvitationRepository();
            _ac = new AccountRepository();
            _mr = new MessageRecipientRepository();
            _f = new FriendService();
            Account acid;

            if (_usersession.CurrentUser != null)
            {
                if (_webcontext.AccountID != _usersession.CurrentUser.AccountID && _webcontext.AccountID != 0)
                {
                    acid = _ac.GetAccountByID(_webcontext.AccountID);
                    lblProfileName.Text = acid.UserName;
                    lb_ban.Text = " ( " + _f.SearchFriend(acid).Count.ToString() + " )";
                    testImage.Src = "~/Image/ProfileAvatar.aspx?AccountID=" + acid.AccountID;
                    AccordionPane1.Visible = false;
                    AccordionPane3.Visible = false;
                    id = acid.AccountID;
                    lbtnChangeAvatar.Visible = false;
                }
                else
                {
                    lblProfileName.Text = _usersession.CurrentUser.UserName;
                    lb_ban.Text = " ( " + _f.SearchFriend(_usersession.CurrentUser).Count.ToString() + " )";
                    testImage.Src = "~/Image/ProfileAvatar.aspx?AccountID=" + _usersession.CurrentUser.AccountID;
                    AccordionPane1.Visible = true;
                    AccordionPane3.Visible = true;
                    lb_invite.Text = " ( " + _fi.FriendInv(_usersession.CurrentUser).Count.ToString() + " )";
                    id = _usersession.CurrentUser.AccountID;
                    lb_message.Text = " ( 0 ) ";
                    lbtnChangeAvatar.Visible = true;
                    //lb_message.Text = " ( " + _mr.getMessageRecipientByAccountID(_usersession.CurrentUser.AccountID).Count.ToString() + " ) ";
                }
            }
            else
            {
                if (_webcontext.AccountID > 0)
                {
                    acid = _ac.GetAccountByID(_webcontext.AccountID);
                    lblProfileName.Text = acid.UserName;
                    testImage.Src = "~/Image/ProfileAvatar.aspx?AccountID=" + acid.AccountID;
                    AccordionPane1.Visible = false;
                    AccordionPane3.Visible = false;
                    id = acid.AccountID;
                    lbtnChangeAvatar.Visible = false;
                }
                else
                    _redirector.GoToAccountLoginPage();

            }
        }
 public void LoginClick()
 {
     _redirector.GoToAccountLoginPage(_webContext.FriendshipRequest);
 }
Beispiel #16
0
        public void Save(BoardPost post)
        {
            //is new thread
            if (_webContext.LoggedIn)
            {
                post.ReplyByAccountID = _webContext.AccountID;
                post.ReplyByUsername  = _webContext.CurrentUser.UserName;
                if (_webContext.PostID > 0)
                {
                    BoardPost postToReplyToo = _postRepository.GetPostByID(_webContext.PostID);
                    if (postToReplyToo.IsThread)
                    {
                        post.ThreadID = postToReplyToo.PostID;
                    }
                    else
                    {
                        //if post.ThreadID = postToReplyToo.ThreadID thì ở thread show tất cả bình luận.
                        post.ThreadID = postToReplyToo.PostID;
                    }
                    post.ForumID = postToReplyToo.ForumID;
                }
                else
                if (_webContext.ForumID > 0)
                {
                    post.ForumID  = _webContext.ForumID;
                    post.IsThread = _webContext.IsThread;
                    if (!_postRepository.CheckPostPageNameIsUnique(post.PageName))
                    {
                        _view.SetErrorMessage("The page name you are trying to use is already in use!");
                        return;
                    }
                }
                post.CreateDate = DateTime.Now;
                post.UpdateDate = DateTime.Now;
                post.AccountID  = _webContext.CurrentUser.AccountID;
                post.Username   = _webContext.CurrentUser.UserName;
                post.ReplyCount = 0;
                post.ViewCount  = 0;
                if (post.PageName != null)
                {
                    post.PageName = post.PageName.Replace(" ", "-");
                }
                else
                {
                    post.PageName = post.Name;
                    post.PageName = post.PageName.Replace(" ", "-");
                }

                post.PostID = _postRepository.SavePost(post);

                BoardForum forum = _forumRepository.GetForumByID(post.ForumID);
                forum.LastPostByAccountID = post.AccountID;
                forum.LastPostByUsername  = post.Username;
                _forumRepository.SaveForum(forum);
                BoardCategory category = _categoryRepository.GetCategoryByCategoryID(forum.CategoryID);
                category.LastPostByAccountID = post.AccountID;
                category.LastPostByUsername  = post.Username;
                _categoryRepository.SaveCategory(category);
                BoardPost thread;
                if (post.IsThread)
                {
                    thread = _postRepository.GetPostByID(post.PostID);
                }
                else
                {
                    thread = _postRepository.GetPostByID((long)post.ThreadID);
                }

                //is this forum part of a group?
                Group group = _groupRepository.GetGroupByForumID(forum.ForumID);

                //add an alert to the filter
                if (post.IsThread)
                {
                    //is this a group forum?
                    if (group != null)
                    {
                        _alertService.AddNewBoardThreadAlert(category, forum, thread, group);
                    }
                    else
                    {
                        _alertService.AddNewBoardThreadAlert(category, forum, thread);
                    }
                }
                else
                {
                    //is this a group forum?
                    if (group != null)
                    {
                        _alertService.AddNewBoardPostAlert(category, forum, post, thread, group);
                    }
                    else
                    {
                        _alertService.AddNewBoardPostAlert(category, forum, post, thread);
                    }
                }
                //_redirector.GoToForumsViewPost(forum.PageName, category.PageName, thread.PageName);
                if (_webContext.IsThread == false)
                {
                    _redirector.Redirect("~/Groups/ViewGroupForumPost.aspx?PostID=" + _webContext.PostID + "&GroupID=" + _webContext.GroupID);
                }
                else
                {
                    _redirector.Redirect("~/Groups/ViewGroup.aspx?GroupID=" + _webContext.GroupID);
                }
            }
            else
            {
                _redirector.GoToAccountLoginPage();
            }
        }