/// <summary> /// Initialize the control and set all the label and links /// </summary> /// <param name="inLinkList"></param> public override void initControl(params object[] inLinkList) { _isInLinkList = (bool)inLinkList[1]; _thisLink = (VL.ORM.VLinkList)inLinkList[0]; _currentLink = VL.ORM.Link.Get(_thisLink.LinkID); lblPoint.Text = _thisLink.TotalPoint.ToString(); //Get description if there is if (_thisLink.Description.Length > 0) { if (_thisLink.Description.Length > 200 && _isInLinkList) { lblDescription.InnerHtml = _thisLink.Description.Substring(0, 200); } else { lblDescription.InnerHtml = _thisLink.Description; } if (_isInLinkList) { lblDescription.InnerHtml += string.Format("...<a href='{0}' class='lCol2'>More</a><br/>", VL.ORM.Link.GetRewriteLink(_thisLink.URLRewrite)); } } //Get user info _postedUser = VL.ORM.User.Get(_thisLink.Poster); //Check if user vote for this yet? If they did, then change the button if (VL.Current.User!=null) { int VotedCount = new VL.ORM.VoteCollection().Where("LinkID", _thisLink.LinkID).Where("UserID", VL.Current.User.UserID).Load().Count; if (VotedCount > 0) { _voted = true; btnVoteUp.ImageUrl = "/assets/images/fireOn.gif"; } } }
/// <summary> /// Login with input information /// </summary> /// <param name="thisPage"></param> /// <param name="UserName"></param> /// <param name="Password"></param> /// <param name="Remember"></param> /// <returns></returns> public static int LogIn(string UserName, string Password, bool Remember) { ORM.User loginUser = new VL.ORM.User("UserName", UserName); //Check if user is exist or not. Return 1 if not if (loginUser.UserID == 0) { return 1; } //Check if the password is correct, if not, return 2 if (loginUser.Password != Password) { return 2; } //Ok, now store the logged user into our main current.user User = loginUser; //Check to store the user in cookie if (Remember) { RememberUser = loginUser; } return 0; }