Ejemplo n.º 1
0
        public JsonResult AddOrRemoveLike(int targetId, bool liked)
        {
            User model = GetProperty(SessionVariableNames.Current_User) as User;

            if (model == null && Request.Cookies["UserMail"] != null)
            {
                string emailId = Request.Cookies["UserMail"].Value;
                model = DALayer.GetUserInfo(emailId);
            }
            bool matched = DALayer.AddOrRemoveLike(model.UserId, targetId, liked);

            if (liked)
            {
                model.Likes.Add(targetId.ToString());
            }
            else
            {
                model.Likes.Remove(targetId.ToString());
            }
            if (matched)
            {
                model.Matches.Add(targetId.ToString());
            }

            return(Json(matched, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        private string GetEmailIdAndRefreshUserSession(bool refreshUserSession)
        {
            string emailId = GetProperty(SessionVariableNames.Email_Id) as string;

            if (emailId == null && Request.Cookies["UserMail"] != null)
            {
                emailId = Request.Cookies["UserMail"].Value;
                SetProperty(SessionVariableNames.Email_Id, emailId);
            }

            if (refreshUserSession)
            {
                SetProperty(SessionVariableNames.Current_User, DALayer.GetUserInfo(emailId));
            }
            else
            {
                User userModel = GetProperty(SessionVariableNames.Current_User) as User;
                if (userModel == null && emailId != null)
                {
                    SetProperty(SessionVariableNames.Current_User, DALayer.GetUserInfo(emailId));
                }
            }
            return(emailId);
        }
Ejemplo n.º 3
0
        public JsonResult GetUserInfo()
        {
            string emailId = GetEmailIdAndRefreshUserSession(false);

            return(Json(DALayer.GetUserInfo(emailId), JsonRequestBehavior.AllowGet));
        }