public ActionResult AddMemberInterest(String title, String content, String classes, String iconid, string selfhoodPictureId, string selfhoodPicture) { String mid = HttpContext.User.Identity.Name; if (title == null) return RedirectToAction("Error", "Error", new { errorno = "0" }); if (content == null) return RedirectToAction("Error", "Error", new { errorno = "0" }); if (classes == null) return RedirectToAction("Error", "Error", new { errorno = "0" }); if (iconid == null) return RedirectToAction("Error", "Error", new { errorno = "0" }); if (selfhoodPictureId == null) return RedirectToAction("Error", "Error", new { errorno = "0" }); if (selfhoodPicture == null) return RedirectToAction("Error", "Error", new { errorno = "0" }); if (mid == null) return RedirectToAction("Error", "Error", new { errorno = "0" }); //获取用户创建的兴趣数量 long interestcount = BiZ.InterestCenter.InterestFactory.GetInterestForMemberCount(mid); //定义用户创建兴趣所需的米果数集合 Dictionary<int, int> InterestInsertToPoints = Common.Comm.getInterestInsertToPoints(); int value = 0; if (Convert.ToInt32(interestcount) <= InterestInsertToPoints.Last().Key) { if (InterestInsertToPoints.ContainsKey(Convert.ToInt32(interestcount))) { value = InterestInsertToPoints[Convert.ToInt32(interestcount)]; } if (BiZ.MemberManager.MemberManager.GetMember(mid).Status.Points < value && value > 0) { return RedirectToAction("AddInterestNoIntegral", "InterestCenter"); } else { String[] iconids = iconid.Split('|'); foreach (string id in iconids) { if (id != "") iconid = id; } //比对去掉分类重复 String[] arrClasses = classes.Split(','); List<String> listClasses = new List<String>(); foreach (String class1 in arrClasses) { if (!listClasses.Contains(class1)) listClasses.Add(class1); } String strClasses; strClasses = String.Join(",", listClasses.ToArray()); BiZ.Photo.Photo myp = BiZ.Photo.PhotoManager.GetPhoto(iconid); if (myp == null) return Json(-1); //创建兴趣 BiZ.InterestCenter.Interest interest = BiZ.InterestCenter.InterestFactory.CreateInterest(mid, title, content, strClasses, iconid, myp.FileName, selfhoodPictureId, selfhoodPicture); //添加兴趣时(同时对兴趣加粉)记录用户对兴趣的喜好数据 BiZ.Recommendation.InterestTrainingData inttTrai = new BiZ.Recommendation.InterestTrainingData(mid, interest.ID, BiZ.Recommendation.InterestTrainingDataType.CreateInterest); //添加兴趣时(同时对兴趣加粉)并记录用户对兴趣的操作 BiZ.MemberManager.MemberManager.ModifyInterestCountCount(mid, BiZ.MemberManager.StatusModifyType.Add); //添加兴趣时(同时对兴趣加粉)改变兴趣排名的分值 CBB.RankingHelper.IRankingAble irk = BiZ.InterestCenter.InterestFactory.GetInterest(interest.ID); //分值改变 CBB.RankingHelper.RankingProvider.AddScores(irk, 3); //添加兴趣时(同时对兴趣加粉),记录动态 //扣除米果 BiZ.MemberManager.MemberManager.ModifyPoints(mid, BiZ.MemberManager.StatusModifyType.Decrease, value); //增加用户动态到后台 BiZ.Sys.MemberActivity.MemberActivityProvider.CreateMemberActivity( mid, "", BiZ.Sys.MemberActivity.MemberActivityType.CreateInterest, "/InterestCenter/ShowInterest/" + interest.ID); return Json(new JavaScriptSerializer().Serialize(interest)); } } else { return RedirectToAction("Error", "Error", new { errNo = "创建兴趣的数量已到上限,不能创建。" }); } }
public ActionResult InterestFans(string id) { #region metas version SetMetasVersion(); #endregion //if (iID == null) return RedirectToAction("Error", "Error", new { errorno = "0" }); //string mId = HttpContext.User.Identity.Name; //ViewData["iID"] = iID; //ViewData["mId"] = mId; string interestId; if (Request.QueryString["iid"] != null) { interestId = Request.QueryString["iid"].ToString(); if (interestId == "") return RedirectToAction("Error", "Error", new { errorno = "0" }); } else { return RedirectToAction("Error", "Error", new { errorno = "0" }); } //只允许已登录用户访问自己 bool alreadyLogin = true; String userId = HttpContext.User.Identity.Name; //bool iffans = BiZ.InterestCenter.InterestFactory.IsFans(interestId, userId); //如果访问ID为空,则访问自己的主页 if (id == null) { if (userId == null || userId == "") return RedirectToAction("Error", "Error", new { errorno = "0" }); else id = userId; } //单击兴趣时记录用户对兴趣的喜好数据 BiZ.Recommendation.InterestTrainingData inttTrai = new BiZ.Recommendation.InterestTrainingData(id, interestId, BiZ.Recommendation.InterestTrainingDataType.Click); //单击兴趣时改变兴趣排名的分值 CBB.RankingHelper.IRankingAble irk = BiZ.InterestCenter.InterestFactory.GetInterest(interestId); CBB.RankingHelper.RankingProvider.AddScores(irk, 1); #region 构造页面数据对象 Models.MemberFullDisplayObj memberDisplayObj = Models.DisplayObjProvider.getMemberFullDisplayObj(id); BiZ.InterestCenter.Interest interest = BiZ.InterestCenter.InterestFactory.GetInterest(interestId); //IList<BiZ.InterestCenter.InterestFans> interestHtxualFansList = BiZ.InterestCenter.InterestFactory.GetInterestFans(interestId, 14, 1); #region 获取兴趣问问 string searchstr = ""; if (Request.QueryString["search"] != null) searchstr = Server.UrlDecode(Request.QueryString["search"].ToString()).Trim(); string page = Request.QueryString["pn"]; //页码 int pageNo = 1; if (!Int32.TryParse(page, out pageNo)) pageNo = 1; int pageSize = int.Parse(CBB.ConfigurationHelper.AppSettingHelper.GetConfig("PlazaPageSize")); IList<BiZ.WenWen.WenWen> wenwenlist = new List<BiZ.WenWen.WenWen>(); if (searchstr.Equals("")) wenwenlist = BiZ.WenWen.WenWenProvider.GetWenWen(interestId, pageSize, pageNo); else wenwenlist = BiZ.WenWen.WenWenProvider.GetWenWens(interestId, searchstr, pageSize, pageNo); #endregion //页面数据对象 Models.PageModels.MemberInterestModel interestModel = new Models.PageModels.MemberInterestModel(memberDisplayObj, interest, null, wenwenlist); interestModel.UserID = userId; interestModel.MemberID = id; interestModel.AlreadyLogon = alreadyLogin; interestModel.memberInterestObj = BiZ.InterestCenter.InterestFactory.GetMemberInterest(interestId, userId); //interestModel.ifmembertofans = iffans; //interestModel.interestFansCount = BiZ.InterestCenter.InterestFactory.GetInterestFansCount(interestId); //interestModel.interestHtxualFansCount = BiZ.InterestCenter.InterestFactory.GetInterestFansCount(interestId); double wenwencount = 0; if (searchstr.Equals("")) wenwencount = (double)BiZ.WenWen.WenWenProvider.GetWenWen(interestId, 0, 0).Count; else wenwencount = (double)BiZ.WenWen.WenWenProvider.GetWenWens(interestId, searchstr, 0, 0).Count; interestModel.wenwencount = (int)wenwencount; interestModel.Pagger = new Models.PaggerObj(); int pages = (int)Math.Ceiling(wenwencount / pageSize); interestModel.Pagger.PageCount = pages; interestModel.Pagger.PageSize = pageSize; interestModel.Pagger.PageNo = pageNo; if (searchstr.Equals("")) interestModel.Pagger.PageUrl = "/InterestCenter/InterestFans/?iid=" + interestId + "&pn="; else interestModel.Pagger.PageUrl = "/InterestCenter/InterestFans/?iid=" + interestId + "&search=" + Server.UrlEncode(searchstr) + "&pn="; #endregion return View(interestModel); }
private CBB.ExceptionHelper.OperationResult AddInterestFansFunc(String iID) { String mId = HttpContext.User.Identity.Name; if (mId != null) { //获取当前登录用户的页面对象 long interestcount = BiZ.InterestCenter.InterestFactory.GetMemberInterestCount(mId); //获取用户兴趣达到一定数量后,再次添加所需的米果数集合 Dictionary<int, int> interestaddfans = Common.Comm.getInterestAddFansToPoints(); //根据用的情趣数量获取用户添加兴趣时所需的米果 int value = 0; //判断加粉兴趣的数量是否超限 if (Convert.ToInt32(interestcount) < interestaddfans.Last().Value) { //加粉时记录用户对兴趣的喜好数据 BiZ.Recommendation.InterestTrainingData inttTrai = new BiZ.Recommendation.InterestTrainingData(mId, iID, BiZ.Recommendation.InterestTrainingDataType.AddToFansGroup); //加粉时记录用户对兴趣的操作 BiZ.MemberManager.MemberManager.ModifyInterestCountCount(mId, BiZ.MemberManager.StatusModifyType.Add); //加粉时改变兴趣排名的分值 CBB.RankingHelper.IRankingAble irk = BiZ.InterestCenter.InterestFactory.GetInterest(iID); CBB.RankingHelper.RankingProvider.AddScores(irk, 3); CBB.ExceptionHelper.OperationResult result = BiZ.Member.Activity.ActivityController.AddToInterestFansGroup(iID, mId); //判断当前添加的兴趣是否需要扣除米果 bool ifin = interestaddfans.ContainsKey(Convert.ToInt32(interestcount)); if (ifin) { value = interestaddfans[Convert.ToInt32(interestcount)]; } //获取当前登录用户的米果数量 var mypoints = BiZ.MemberManager.MemberManager.GetMember(mId).Status.Points; if (ifin && mypoints >= value) { if (result.ok) { //兴趣添加成功后扣除相应的米果 BiZ.MemberManager.MemberManager.ModifyPoints(mId, BiZ.MemberManager.StatusModifyType.Decrease, value); } } return result; } } return null; }