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)); }
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); }
public JsonResult GetUserInfo() { string emailId = GetEmailIdAndRefreshUserSession(false); return(Json(DALayer.GetUserInfo(emailId), JsonRequestBehavior.AllowGet)); }