/// <summary> /// 牛人展示 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult PersonalShow(int id, int p = 0) { try { User user = new User(); user = db.Users.Find(id); if (user != null) { user.PV = user.PV + 1; user.TodayPV = user.TodayPV + 1; db.SaveChanges(); ViewBag.user = new vUser(user); var u = ""; if (user.RealName == null) { u = user.UserName; } else { u = user.RealName; } if (CurrentUser != null) { BrowseRecord browserecord = new BrowseRecord(); string url = Request.Url.ToString(); browserecord = db.BrowseRecords.Where(br => br.URL == url && br.UserID == CurrentUser.ID).FirstOrDefault(); if (browserecord == null) { BrowseRecord addbrowserecord = new BrowseRecord(); addbrowserecord.UserID = CurrentUser.ID; addbrowserecord.URL = url; addbrowserecord.Title = "牛人展示——" + u; addbrowserecord.Time = DateTime.Now; db.BrowseRecords.Add(addbrowserecord); db.SaveChanges(); } else { db.BrowseRecords.Remove(browserecord); BrowseRecord updatebrowserecord = new BrowseRecord(); updatebrowserecord.UserID = CurrentUser.ID; updatebrowserecord.URL = url; updatebrowserecord.Title = "牛人展示——" + u; updatebrowserecord.Time = DateTime.Now; db.BrowseRecords.Add(updatebrowserecord); db.SaveChanges(); } var collect = db.Collects.Where(c => c.CollectTypeAsInt == 0 && c.TID == id && c.UserID == CurrentUser.ID).FirstOrDefault(); if (collect == null) { ViewBag.IsCollected = false; } else { ViewBag.IsCollected = true; } } else { ViewBag.IsCollected = false; } IEnumerable<MessageBoard> query = db.MessageBoards.Where(m => m.ToUserID == user.ID).OrderByDescending(m => m.Time).AsEnumerable(); ViewBag.PageInfo = PagerHelper.Do(ref query, 5, p); List<vMessageBoard> MessageBoards = new List<vMessageBoard>(); foreach (var item in query) { MessageBoards.Add(new vMessageBoard(item)); } return View(MessageBoards); } else { return Redirect("/Shared/info?msg=该用户不存在,请不要不合理操作"); } } catch (Exception ex) { log.Error(new LogContent("注册信息完善页面出错", HttpHelper.GetIPAddress()), ex); return Redirect("/User/PersonalShow/" + id); } }
/// <summary> /// 产品展示 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult Show(int id) { var _product = db.Products.Find(id); if(_product!=null) { vProduct product = new vProduct(_product); if (CurrentUser != null) { try { BrowseRecord browserecord = new BrowseRecord(); string url = Request.Url.ToString(); browserecord = db.BrowseRecords.Where(br => br.URL == url && br.UserID == CurrentUser.ID).FirstOrDefault(); if (browserecord == null) { BrowseRecord addbrowserecord = new BrowseRecord(); addbrowserecord.UserID = CurrentUser.ID; addbrowserecord.URL = url; addbrowserecord.Title = "商品展示——" + product.ProductName; addbrowserecord.Time = DateTime.Now; db.BrowseRecords.Add(addbrowserecord); db.SaveChanges(); } else { db.BrowseRecords.Remove(browserecord); BrowseRecord updatebrowserecord = new BrowseRecord(); updatebrowserecord.UserID = CurrentUser.ID; updatebrowserecord.URL = url; updatebrowserecord.Title = "商品展示——" + product.ProductName; updatebrowserecord.Time = DateTime.Now; db.BrowseRecords.Add(updatebrowserecord); db.SaveChanges(); } } catch(Exception ex) { log.Error(new LogContent("产品展示出错", HttpHelper.GetIPAddress()), ex); return Redirect("/Shared/Info?msg=数据异常,请稍后重试"); } } return View(product); } else { return Redirect("/Shared/Info?msg=数据异常,请稍后重试"); } }
public ActionResult UserGroupShow(int? id) { UserGroup group = db.UserGroups.Find(id); if (group == null) { return Redirect("/Shared/Info?msg=该牛棚不存在,请不要不合理操作"); } else { try { group.PV = group.PV + 1; group.TodayPV = group.TodayPV + 1; db.SaveChanges(); vUserGroup user = new vUserGroup(group); ViewBag.User = user; var u = ""; if (user.GroupName == null) { u = user.LoginName; } else { u = user.GroupName; } if (CurrentUser != null) { BrowseRecord browserecord = new BrowseRecord(); string url = Request.Url.ToString(); browserecord = db.BrowseRecords.Where(br => br.URL == url && br.UserID == CurrentUser.ID).FirstOrDefault(); if (browserecord == null) { BrowseRecord addbrowserecord = new BrowseRecord(); addbrowserecord.UserID = CurrentUser.ID; addbrowserecord.URL = url; addbrowserecord.Title = "牛棚展示——" + u; addbrowserecord.Time = DateTime.Now; db.BrowseRecords.Add(addbrowserecord); db.SaveChanges(); } else { db.BrowseRecords.Remove(browserecord); BrowseRecord updatebrowserecord = new BrowseRecord(); updatebrowserecord.UserID = CurrentUser.ID; updatebrowserecord.URL = url; updatebrowserecord.Title = "牛棚展示——" + u; updatebrowserecord.Time = DateTime.Now; db.BrowseRecords.Add(updatebrowserecord); db.SaveChanges(); } var collect = db.Collects.Where(c => c.CollectTypeAsInt == 1 && c.TID == id && c.UserID == CurrentUser.ID).FirstOrDefault(); if (collect == null) { ViewBag.IsCollected = false; } else { ViewBag.IsCollected = true; } } else { ViewBag.IsCollected = false; } return View(); } catch(Exception ex) { log.Error(new LogContent(" 牛人头像修改出错", HttpHelper.GetIPAddress()), ex); return Redirect("/UserGroup/UserGroupShow/" + id); } } }
public ActionResult BusinessShow(int id) { Business business = db.Businesses.Find(id); if (business != null) { try { business.PV = business.PV + 1; business.TodayPV = business.TodayPV + 1; db.SaveChanges(); vBusiness vbusiness = new vBusiness(business); ViewBag.Business = vbusiness; var u = ""; if (vbusiness.BusinessName == null) { u = vbusiness.LoginName; } else { u = vbusiness.BusinessName; } if (CurrentUser != null) { BrowseRecord browserecord = new BrowseRecord(); string url = Request.Url.ToString(); browserecord = db.BrowseRecords.Where(br => br.URL == url && br.UserID == CurrentUser.ID).FirstOrDefault(); if (browserecord == null) { BrowseRecord addbrowserecord = new BrowseRecord(); addbrowserecord.UserID = CurrentUser.ID; addbrowserecord.URL = url; addbrowserecord.Title = "商户展示——" + u; addbrowserecord.Time = DateTime.Now; db.BrowseRecords.Add(addbrowserecord); db.SaveChanges(); } else { db.BrowseRecords.Remove(browserecord); BrowseRecord updatebrowserecord = new BrowseRecord(); updatebrowserecord.UserID = CurrentUser.ID; updatebrowserecord.URL = url; updatebrowserecord.Title = "商户展示——" + u; updatebrowserecord.Time = DateTime.Now; db.BrowseRecords.Add(updatebrowserecord); db.SaveChanges(); } } return View(); } catch (Exception ex) { log.Error(new LogContent("商户展示页面出错", HttpHelper.GetIPAddress()), ex); return Redirect("/Shared/Info?msg=数据异常,请稍后重试"); } } else { return Redirect("/Business/BusinessShow/"+id); } }