Example #1
0
        //return current user
        public static bq_User GetUser()
        {
            var     userName = WebMatrix.WebData.WebSecurity.CurrentUserName;
            bl_User bl_user  = new bl_User();

            return(bl_user.GetByUserName(userName));
        }
Example #2
0
        public ActionResult Zing(string signed_request)
        {
            ZingMe  zing     = new ZingMe(signed_request);
            bl_User bluser   = new bl_User();
            var     zingUser = zing.GetInfo();
            string  userName = zingUser.UserName;

            var user = bluser.GetByUserName(userName);

            if (user == null)
            {
                var userId = Guid.NewGuid();
                bluser.Create(userId, userName, "", false, DateTime.Now);
                bluser.HardUpdate(
                    userId,
                    zingUser.Avatar160, true,
                    DateTime.Now,
                    zingUser.DisplayName);
            }
            else
            {
                bluser.HardUpdate(
                    user.UserId,
                    zingUser.Avatar160,
                    user.Gender,
                    user.Birthday,
                    zingUser.DisplayName);
            }

            OAuthWebSecurity.CreateOrUpdateAccount("zing", zingUser.Id, userName);
            FormsAuthentication.SetAuthCookie(userName, true);
            return(Redirect("/"));
        }
Example #3
0
        public UserProfile GetById(Guid userId)
        {
            bl_User blUser = new bl_User();
            var     model  = new UserProfile(blUser.GetById(userId));

            return(model);
        }
Example #4
0
        public ActionResult Ranking()
        {
            bl_User blUser = new bl_User();
            var     model  = blUser.GetTop(12);

            return(View(model));
        }
Example #5
0
        public List <UserProfile> GetAll()
        {
            bl_User blUser = new bl_User();
            var     model  = blUser.GetAll()
                             .Select(m => new UserProfile(m))
                             .ToList();

            return(model);
        }
Example #6
0
        public TopModel GetTop(Guid userId, int top = 10)
        {
            bl_User  blUser = new bl_User();
            TopModel model  = new TopModel();

            model.CurrentUser = new UserProfile(blUser.GetById(userId));
            model.UserList    = blUser.GetTop(10)
                                .Select(m => new UserProfile(m))
                                .ToList();

            return(model);
        }
Example #7
0
        public ActionResult EditProfile(bq_User user)
        {
            bl_User bl_User = new bl_User();

            bl_User.Update(user.UserId,
                           user.UserName,
                           user.Email,
                           user.Gender,
                           user.Birthday);

            return(View(user));
        }
Example #8
0
        public ActionResult Link(Guid questionId, string userName)
        {
            bl_Question blQuestion = new bl_Question();
            bl_User     blUser     = new bl_User();

            var user  = blUser.GetByUserName(userName);
            var model = blQuestion.GetById(questionId);

            if (user != null)
            {
                ViewBag.DisplayName = user.DisplayName;
            }
            return(View(model));
        }
Example #9
0
        public ActionResult Share(Guid id, string userName)
        {
            bl_QuestionGroup bl_group    = new bl_QuestionGroup();
            bl_Question      bl_question = new bl_Question();
            bl_User          blUser      = new bl_User();

            var group = new ps_Group();
            var user  = blUser.GetByUserName(userName);

            group.Group           = bl_group.GetById(id);
            group.Group.Paragraph = HttpUtility.HtmlDecode(group.Group.Paragraph);
            group.QuestionList    = bl_question.GetByGroupId(id);

            if (user != null)
            {
                ViewBag.DisplayName = user.DisplayName;
            }
            return(View(group));
        }
Example #10
0
        public ActionResult CloseWindows()
        {
            bl_User _objUser = new bl_User();

            DateTime dCurrentLoginTime = DateTime.Now;
            string   sCurrentLoginIP   = string.Empty;

            // ********************************** // ***************************************
            string hostName = Dns.GetHostName();                                     // Retrive the Name of HOST

            sCurrentLoginIP = Dns.GetHostByName(hostName).AddressList[0].ToString(); // Get the

            #region Update Login Detail

            if (!string.IsNullOrWhiteSpace(_objAuthentication.UserName) && !string.IsNullOrWhiteSpace(_objAuthentication.Id))
            {
                Guid guid = new Guid(_objAuthentication.Id);

                var vObj = _objUser.GetById(guid);
                if (vObj != null)
                {
                    vObj.LastLoginTime = DateTime.Now;
                    vObj.LastLoginIP   = sCurrentLoginIP;
                    _objUser.Update(vObj);
                }

                HttpCookie authCookie = HttpContext.Request.Cookies["UserInfo"];
                if (authCookie != null)
                {
                    authCookie.Values["LastLoginTime"] = Convert.ToString(DateTime.Now.ToString("dd/MM/yyyy") + ",  " + DateTime.Now.ToString("hh:mm:ss tt"));
                    authCookie.Values["LastLoginIP"]   = sCurrentLoginIP;
                    Response.SetCookie(authCookie);
                }
            }

            #endregion

            return(View());
        }
Example #11
0
        public TopModel GetTopByZingUser(string userName, int top = 10)
        {
            bl_User  blUser = new bl_User();
            TopModel model  = new TopModel();

            //var user = blUser.GetByUserName("zing." + userName);
            var user = blUser.GetByUserName(userName);

            if (user != null)
            {
                model.CurrentUser = new UserProfile(user);
            }
            else
            {
                model.CurrentUser = null;
            }

            model.UserList = blUser.GetTop(10)
                             .Select(m => new UserProfile(m))
                             .ToList();

            return(model);
        }
Example #12
0
        public UserProfile(bq_User user)
        {
            UserId    = user.UserId;
            UserName  = user.UserName;
            Email     = user.Email;
            Gender    = user.Gender;
            BirthDay  = user.Birthday;
            BestScore = user.BestScore;

            DisplayName = (user.DisplayName != null) ? user.DisplayName : user.UserName;
            if (user.Avatar.Contains("http"))
            {
                Avatar = user.Avatar;
            }
            else
            {
                Avatar = ps_Server.AvatarPath + user.Avatar;
            }

            bl_User blUser = new bl_User();

            Ranking = blUser.GetRanking(BestScore);
        }
Example #13
0
        public void UpdateAuthenticationDetail(M_User ObjUser)
        {
            bl_User _objUser = new bl_User();

            DateTime dCurrentLoginTime = DateTime.Now;
            string   sCurrentLoginIP   = string.Empty;

            // ********************************** // ***************************************
            string hostName = Dns.GetHostName();                                     // Retrive the Name of HOST

            sCurrentLoginIP = Dns.GetHostByName(hostName).AddressList[0].ToString(); // Get the IP

            #region Authentication

            var vRoleName = _objLogin.GetUserRoleName(ObjUser);

            HttpCookie cookieUser = new HttpCookie("UserInfo");
            cookieUser.Values.Add("Id", Convert.ToString(ObjUser.Id));
            cookieUser.Values.Add("UserId", Convert.ToString(ObjUser.UserName));
            cookieUser.Values.Add("Name", Convert.ToString(ObjUser.Name));
            cookieUser.Values.Add("Email", Convert.ToString(ObjUser.Email));
            cookieUser.Values.Add("Phone", Convert.ToString(ObjUser.Phone));

            cookieUser.Values.Add("LastLoginTime", Convert.ToString(ObjUser.CurrentLoginTime.HasValue ? ObjUser.CurrentLoginTime.Value.ToString("dd/MM/yyyy") + ",  " + ObjUser.CurrentLoginTime.Value.ToString("hh:mm:ss tt") : "[N/A]"));
            cookieUser.Values.Add("LastLoginIP", Convert.ToString(ObjUser.LastLoginIP));
            cookieUser.Values.Add("CurrentLoginTime", Convert.ToString(dCurrentLoginTime != null ? dCurrentLoginTime.ToString("dd/MM/yyyy") + ",  " + dCurrentLoginTime.ToString("hh:mm:ss tt") : "[N/A]"));
            cookieUser.Values.Add("CurrentLoginIP", Convert.ToString(sCurrentLoginIP));
            cookieUser.Values.Add("RoleName", Convert.ToString(vRoleName));
            cookieUser.Expires = DateTime.Now.AddDays(10.0);

            Response.Cookies.Add(cookieUser);

            // Success, create non-persistent authentication cookie.
            //FormsAuthentication.SetAuthCookie(vUserObject.UserName.Trim(), false);
            //FormsAuthenticationTicket ticket1 =
            //   new FormsAuthenticationTicket(
            //        1,                          // version
            //        vUserObject.UserName.Trim(),    // get username  from the form
            //        DateTime.Now,               // issue time is now
            //        DateTime.Now.AddMinutes(10),// expires in 10 minutes
            //        false,                      // cookie is not persistent
            //        "HR"                   // role assignment is stored in userData
            //        );
            //HttpCookie cookieUser = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket1));
            //Response.Cookies.Add(cookieUser);

            #endregion

            #region Update Login Detail

            if (!string.IsNullOrWhiteSpace(Convert.ToString(ObjUser.Id)))
            {
                var vObj = _objUser.GetById(ObjUser.Id);
                if (vObj != null)
                {
                    vObj.LastLoginTime = ObjUser.CurrentLoginTime;
                    vObj.LastLoginIP   = sCurrentLoginIP;

                    vObj.CurrentLoginTime = dCurrentLoginTime;
                    vObj.CurrentLoginIP   = sCurrentLoginIP;

                    _objUser.Update(vObj);
                }
            }

            #endregion
        }