// GET: ProductMng public ActionResult Index() { var resp = MysqlHelper.ExecuteObjects <List <ProductDto> >("select * from Product"); ViewData["ServerIP"] = $"服务器IP={IPHepler.GetLocalIP()}"; ViewData["DataBaseUrl"] = $"数据库链接={resp.Msg}"; DataInit.InitData(); return(View(resp.Data)); }
public ActionResult BuyProduct(BuyProductDto dto) { var data = RedisCacheHelper.Get <List <ProductDto> >("productlist"); ViewData["ServerIP"] = $"服务器IP={IPHepler.GetLocalIP()}"; var count = RedisCacheHelper.Decrement(dto.ProductID.ToString(), dto.BuyCount); BaseDtoResp <string> resp = new BaseDtoResp <string>(); if (count >= 0) { resp.IsSuccess = MysqlHelper.ExecuteSql($"update Product set count=count-{dto.BuyCount} where ID={dto.ProductID}") > 0; resp.Msg = "商品购买成功"; } else { resp.Msg = "商品已卖完"; } //RedisCacheHelper.Add<Student>(stu.NO, stu, DateTime.Now.AddMinutes(15)); return(Json(resp)); }
public ActionResult Index() { //var count = SQLHelper.ExecuteScalar("select COUNT(*) from Student"); //var data = SQLHelper.ExecuteDataTable("select * from Student"); //var countStudent = int.Parse(SQLHelper.ExecuteScalar("select COUNT(*) from Student where S#='10' ").ToString()); //if (countStudent > 0) //{ // var temp = SQLHelper.ExecuteNonQuery("delete from Student where S#='10' "); //} //var insert = SQLHelper.ExecuteNonQuery("insert into student (s#,Sname,Sage,Ssex) values('10','aaaa','1990-04-01 00:00:00.000','男')"); ViewData["message"] = "这是ViewData(string)" + IPHepler.GetLocalIP(); Student stu = new Student { Age = 320, Name = "潘守军3", NO = "NO003" }; //Student stu = new Student { Age = 10, Name = "潘守军", NO = "NO001" }//; ViewBag.ViewBagStu = stu; ViewData["ViewDataStu"] = stu; TempData["TempDataStu"] = stu; if (!RedisCacheHelper.Exists(stu.NO)) { RedisCacheHelper.Add <Student>(stu.NO, stu, DateTime.Now.AddMinutes(15)); } else { var student = RedisCacheHelper.Get <Student>("NO001"); } return(View()); }