public ActionResult Edit(NewsModel news) { try { int userId = -1; if (Session["UserId"] != null) { userId = int.Parse(Session["UserID"].ToString()); } BLLNews bll = new BLLNews(); NewsInfo newsObjest = new NewsInfo() { NewId = news.NewId, Title = news.Title, Content = SecurityUtility.RemoveIllegalCharacters(news.Message), CreateDate = DateTime.Now, IsDelete = false, IsTop = false, IsPublic = true, ViewTimes = 0, UserId = userId, ImageUrl = "" }; //编辑信息 之后提交更新 bll.Update(newsObjest); return(RedirectToAction("Index", "News")); } catch (Exception) { return(View()); } }
public ActionResult AddRelation(ht_comm_relation relation) { AuthenticationUser loginInfo = BLLUser.GetLoginUserInfo(); if (loginInfo == null) { apiResp.msg = "请先登录"; apiResp.code = (int)HT.Model.Enum.APIErrCode.UserIsNotLogin; return(Json(apiResp)); } if (BLLRelation.IsExistRelation(relation.main_id, loginInfo.id.ToString(), "praise")) { apiResp.msg = "重复关注"; apiResp.code = (int)HT.Model.Enum.APIErrCode.UserIsNotLogin; return(Json(apiResp)); } ht_comm_relation model = new ht_comm_relation(); model.add_time = DateTime.Now; model.relation_type = "praise"; model.main_id = relation.main_id; model.relation_id = loginInfo.id.ToString(); if (BLLNews.AddPraise(int.Parse(relation.main_id), model) > 0) { apiResp.status = true; apiResp.msg = "点赞成功"; } else { apiResp.msg = "点赞出错"; apiResp.code = (int)HT.Model.Enum.APIErrCode.OperateFail; } return(Json(apiResp)); }
/// <summary> /// 微信支付 /// </summary> /// <param name="id">订单号</param> /// <returns></returns> public ActionResult Pay(string id) { var order = BLLNews.GetNewsDetailsByOrderNo(id); ViewBag.OrderNo = id; if (Request.IsAjaxRequest()) { if (order == null || order.pay_status == 1) { return(JsonResult(Model.Enum.APIErrCode.OperateFail, "订单无效或已经支付")); } string Ip = Request.UserHostAddress; string openId = BLLUser.GetLoginUserInfo().openid; string notiUrl = Request.Url.Scheme + "://" + Request.Url.Authority + "/WX/PayNotify";//通知地址 bool isRequestSuccess = false; var payRequest = BLLWeixin.WXPay(order.order_no, order.total.Value, openId, Ip, notiUrl, out isRequestSuccess); if (isRequestSuccess) { return(JsonResult(Model.Enum.APIErrCode.Success, "OK", payRequest)); } else { return(JsonResult(Model.Enum.APIErrCode.OperateFail)); } } else { return(View()); } }
public ActionResult CreateNews(FormCollection fc) { int userId = -1; if (Session["UserID"] != null) { userId = int.Parse(Convert.ToString(Session["UserID"])); } NewsModel news = new NewsModel(); BLLNews bll = new BLLNews(); NewsInfo newsObject = new NewsInfo() { Title = fc["Title"].ToString(), Content = fc["Message"].ToString(), CreateDate = DateTime.Now, IsDelete = false, IsPublic = Convert.ToBoolean(fc["IsPublic"]), IsTop = false, ViewTimes = 0, IsCommented = false, UserId = userId }; //保存到数据库 bll.Insert(newsObject); //返回到列表 return(RedirectToAction("Index")); }
public ActionResult Details(int id) { BLLNews bll = new BLLNews(); NewsInfo newsinfo = bll.GetData(id); NewsModel newsModel = new NewsModel(newsinfo); return(View(newsModel)); }
// GET api/martinapi/5 public NewsInfo Get(int id) { // return "value"; BLLNews bll = new BLLNews(); //获取所有新闻 NewsInfo newInfo = bll.GetData(id); return(newInfo); }
/// <summary> /// 余额支付提交 /// </summary> /// <returns></returns> public ActionResult PostMoneyPay(string order_no) { string msg = ""; if (BLLNews.PayNews(order_no, "余额", "", out msg) == 0) { return(JsonResult(APIErrCode.OperateFail, msg)); } return(JsonResult(APIErrCode.Success, "支付完成")); }
public ActionResult Delete(int id) { //删除新闻 BLLNews bll = new BLLNews(); bll.Delete(id); //返回新闻列表 return(RedirectToAction("Index", "News")); }
// GET api/martinapi public IEnumerable <NewsInfo> Get() { // return new string[] { "value1", "value2" }; BLLNews bll = new BLLNews(); //获取所有新闻 List <NewsInfo> listNews = bll.GetData(); return(listNews); }
public JsonResult AJAXTest(int id) { BLLNews bll = new BLLNews(); //获取所有新闻 NewsInfo newsinfo = bll.GetData(id); NewsModel model = new NewsModel(newsinfo); JsonResult json = this.Json(model, JsonRequestBehavior.AllowGet); //this.Json(newsinfo); return(json); }
public ActionResult Edit(ht_news model) { if (BLLNews.Edit(model)) { return(JsonResult(APIErrCode.Success, "编辑成功")); } else { return(JsonResult(APIErrCode.OperateFail, "编辑失败")); } }
public ActionResult PostDel(int id) { if (BLLNews.DelNews(id) > 0) { return(JsonResult(APIErrCode.Success, "删除成功")); } else { return(JsonResult(APIErrCode.OperateFail, "删除失败")); } }
public ActionResult Detail(int id) { var detail = BLLNews.Get(id); var authenticationUser = BLLAuthentication.GetAuthenticationUser(); if (authenticationUser.id != detail.add_userid) { return(JsonResult(APIErrCode.OperateFail, "无权操作")); } return(JsonResult(APIErrCode.Success, "OK", detail)); }
public ActionResult SubscribeNewsList(int subscribe_id, int page = 1, int rows = 5) { Model.Model.PageResult <ht_news> pageModel = BLLNews.GetSubscribeNewsListPageResult(page, rows, subscribe_id); if (Request.IsAjaxRequest()) { apiResp.status = true; apiResp.result = pageModel; return(Json(apiResp)); } return(View(pageModel)); }
/// <summary> /// 获取信息详情 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult BaseNewsDetails(int id) { HT.Model.ht_news model = BLLNews.GetNewsDetails(id); if (Request.IsAjaxRequest()) { apiResp.status = true; apiResp.result = model; return(Json(apiResp)); } return(View(model)); }
public ActionResult Edit(int id) { //根据id获取要编辑的新闻 BLLNews bll = new BLLNews(); NewsInfo newsInfo = bll.GetData(id); //根据实体对象,来构造模型 NewsModel newsModel = new NewsModel(newsInfo); return(View(newsModel)); }
/// <summary> /// 信息列表 /// </summary> /// <param name="searchKey"></param> /// <param name="page"></param> /// <param name="rows"></param> /// <returns></returns> public ActionResult BaseNewsList(ht_news searchKey, int page = 1, int rows = 5, bool recommend = false) { Model.Model.PageResult <ht_news> pageModel = BLLNews.GetNewsListPageResult(page, rows, searchKey, recommend); if (Request.IsAjaxRequest()) { apiResp.status = true; apiResp.result = pageModel; return(Json(apiResp)); } return(View(pageModel)); }
/// <summary> /// 猜你喜欢 /// </summary> /// <param name="searchKey"></param> /// <param name="page"></param> /// <param name="rows"></param> /// <returns></returns> public ActionResult BaseLikeNewsList(int page = 1, int rows = 5, int id = 0, int min = 1) { List <ht_news> list = BLLNews.GetLikeNewsList(page, rows, id, min); if (Request.IsAjaxRequest()) { apiResp.status = true; apiResp.result = list; return(Json(apiResp)); } return(View(list)); }
/// <summary> /// 获取信息详情 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult BaseNewsDetails(int id) { HT.Model.ht_news model = BLLNews.GetNewsDetails(id); if (model != null) { model.is_praise = BLLRelation.IsExistRelation(model.id.ToString(), BLLUser.GetUserId().ToString(), "praise"); } if (Request.IsAjaxRequest()) { apiResp.status = true; apiResp.result = model; return(Json(apiResp)); } return(View(model)); }
public ActionResult PostGoodsSubmit(ht_news model) { string msg = ""; string orderNo = ""; model.add_userid = BLLUser.GetLoginUserInfo().id; if (BLLNews.Add(model, out msg, out orderNo)) { return(JsonResult(APIErrCode.Success, "OK", new { order_no = orderNo })); } else { return(JsonResult(APIErrCode.OperateFail, msg)); } }
public ActionResult DeleteRelation(ht_comm_relation relation) { relation.relation_type = "praise"; relation.relation_id = BLLUser.GetUserId().ToString(); if (BLLNews.DeletePraise(int.Parse(relation.main_id), relation) > 0) { apiResp.msg = "取消点赞成功"; apiResp.status = true; } else { apiResp.msg = "取消点赞出错"; apiResp.code = (int)HT.Model.Enum.APIErrCode.OperateFail; } return(Json(apiResp)); }
/// <summary> /// 微信支付通知 /// </summary> /// <returns></returns> public ActionResult PayNotify() { string successXml = "<xml><return_code><![CDATA[SUCCESS]]></return_code></xml>"; string failXml = "<xml><return_code><![CDATA[FAIL]]></return_code></xml>"; try { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(Request.InputStream); //全部参数 SortedDictionary <string, string> parametersAll = new SortedDictionary <string, string>(); foreach (XmlElement item in xmlDoc.DocumentElement.ChildNodes) { string key = item.Name; string value = item.InnerText; if ((!string.IsNullOrEmpty(key)) && (!string.IsNullOrEmpty(value))) { parametersAll.Add(key, value); } } xmlDoc.Save(string.Format("E:\\WXPay\\{0}_Notify.xml", parametersAll["out_trade_no"]));//写入日志 if (MicroMessenger.CommonUtil.VerifySign(parametersAll, BLLConfig.Get("wx_mchsecret"))) { string orderNo = parametersAll["out_trade_no"].ToString(); if (orderNo.StartsWith("T")) { if (BLLNewsOrder.WXPaySuccess(orderNo, parametersAll["transaction_id"])) { return(Content(successXml)); } } else if (BLLNews.WXPaySuccess(orderNo, parametersAll["transaction_id"])) { return(Content(successXml)); } } } catch (Exception ex) { using (System.IO.StreamWriter sw = new System.IO.StreamWriter(@"E:\WXPay\Error.txt", true, Encoding.GetEncoding("UTF-8"))) { sw.WriteLine(ex.ToString()); } } return(Content(failXml)); }
public ActionResult UpdteSetTop(int id, int set_top, decimal money, string pay) { string orderno = string.Empty; if (BLLNews.UpdateSetTop(id, set_top, money, pay, out orderno)) { apiResp.msg = "置顶成功"; apiResp.result = orderno; apiResp.status = true; } else { apiResp.msg = "置顶失败"; apiResp.status = true; } return(Json(apiResp)); }
/// <summary> /// 猜你喜欢 /// </summary> /// <param name="searchKey"></param> /// <param name="page"></param> /// <param name="rows"></param> /// <returns></returns> public ActionResult BaseLikeNewsList(int page = 1, int rows = 5, int id = 0, int min = 1) { List <ht_news> list = BLLNews.GetLikeNewsList(page, rows, id, min); //foreach (var item in list) //{ // item.is_praise = BLLRelation.IsExistRelation(item.id.ToString(), BLLUser.GetUserId().ToString(), "praise"); //} if (Request.IsAjaxRequest()) { apiResp.status = true; apiResp.result = list; return(Json(apiResp)); } return(View(list)); }
public ActionResult PostSubmit(ht_news model) { string msg = ""; string orderNo = ""; var authenticationUser = BLLAuthentication.GetAuthenticationUser(); model.add_userid = authenticationUser.id; model.add_nickname = authenticationUser.nickname; model.add_avatar = authenticationUser.avatar; if (BLLNews.Add(model, out msg, out orderNo)) { return(JsonResult(APIErrCode.Success, "OK", new { order_no = orderNo })); } else { return(JsonResult(APIErrCode.OperateFail, msg)); } }
/// <summary> /// 信息列表 /// </summary> /// <param name="searchKey"></param> /// <param name="page"></param> /// <param name="rows"></param> /// <returns></returns> public ActionResult BaseNewsList(ht_news searchKey, int page = 1, int rows = 5) { var curUserid = BLLAuthentication.GetAuthenticationUser().id; if (searchKey.isme.HasValue && searchKey.isme.Value) { searchKey.add_userid = curUserid; //我的发布 } Model.Model.PageResult <ht_news> pageModel = BLLNews.GetNewsListPageResult(page, rows, searchKey, curUserid); if (Request.IsAjaxRequest()) { apiResp.status = true; apiResp.result = pageModel; return(Json(apiResp)); } return(View(pageModel)); }
public ActionResult Pay(string id) { var details = BLLNews.GetNewsDetailsByOrderNo(id); if (details.pay_status == 1) //已支付 { return(PayResult(id)); } int user_id = BLLAuthentication.GetAuthenticationUser().id; var user = BLLUser.GetUserById(user_id); ViewBag.RespUser = new Model.Model.RespUser { id = user.id, nickname = user.nickname, avatar = user.avatar, money = user.money.Value }; return(View(details)); }
// // GET: /News/ public ActionResult Index() { BLLNews bll = new BLLNews(); //获取所有新闻 List <NewsInfo> listNews = bll.GetData(); NewsListModel modelList = new NewsListModel(listNews); //判断用户是否登录 if (Session["UserId"] != null) { ViewBag.IsLogOn = true; } else { ViewBag.IsLogOn = false; } //模型传递给视图 return(View(modelList.NewsList)); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { PagedDataSource objPds = new PagedDataSource(); objPds.DataSource = BLLNews.getAllNews().DefaultView; objPds.AllowPaging = true; objPds.PageSize = 2; int CurPage; if (Request.QueryString["Page"] != null) { CurPage = Convert.ToInt32(Request.QueryString["Page"]); } else { CurPage = 1; } objPds.CurrentPageIndex = CurPage - 1; //lblCurrentPage.Text = "Page: " + CurPage.ToString(); if (!objPds.IsFirstPage) { lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage - 1); } if (!objPds.IsLastPage) { lnkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage + 1); } Repeater1.DataSource = objPds; Repeater1.DataBind(); } }
/// <summary> /// 获取列表 /// </summary> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <param name="type"></param> /// <param name="keyword"></param> /// <returns></returns> public static HT.Model.Model.PageResult <ht_review> GetReviewsList(int pageIndex, int pageSize, string news_id, string type, string status, string keyword, string review_id) { HT.Model.Model.PageResult <ht_review> pageModel = new HT.Model.Model.PageResult <ht_review>(); using (Entities db = new Entities()) { db.Configuration.ProxyCreationEnabled = false; var unDelList = db.ht_review.Where(r => true); if (!string.IsNullOrWhiteSpace(news_id)) { int newsid = int.Parse(news_id); unDelList = unDelList.Where(r => r.news_id == newsid); } if (!string.IsNullOrWhiteSpace(type) && type != "all") { unDelList = unDelList.Where(r => r.review_type == type); } if (!string.IsNullOrWhiteSpace(keyword)) { unDelList = unDelList.Where(r => r.nickname == keyword || r.review_content.StartsWith(keyword)); } if (!string.IsNullOrWhiteSpace(status)) { int statusInt = int.Parse(status); unDelList = unDelList.Where(r => r.status == statusInt); } if (!string.IsNullOrWhiteSpace(review_id)) { int review_id_num = Convert.ToInt32(review_id); unDelList = unDelList.Where(r => r.review_id == review_id_num); } int total = unDelList.Count(); pageModel.totalpage = (int)Math.Ceiling((decimal)total / (decimal)pageSize);//总页数 pageModel.total = total; pageModel.list = unDelList.OrderBy(p => p.status).Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList(); if (type == "all") { foreach (var item in pageModel.list) { if (item.review_type == "reply") { var pr = db.ht_review.Find(item.review_id); if (pr != null) { item.parent_content = pr.review_content; } } else if (item.review_type == "comment") { var pn = db.ht_news.Find(item.news_id); if (pn == null) { continue; } if (pn.cateid == 1 || pn.cateid == 2) { item.parent_content = BLLNews.GetCity(pn.start_city, pn.start_district, pn.start_province) + "→" + BLLNews.GetCity(pn.stop_city, pn.stop_district, pn.stop_province); } else { item.parent_content = pn.add_nickname + " " + pn.cate; } } } } return(pageModel); } }