Exemplo n.º 1
0
 public ActionResult DeleteDIY()
 {
     if (Session["userName"] != null)
     {
         var    userName = System.Web.HttpContext.Current.Request["username"];
         var    stream   = HttpContext.Request.InputStream;
         string dataJson = new StreamReader(stream).ReadToEnd(); //json 字符串在此
         int    id       = 0;
         int.TryParse(dataJson, out id);
         DIYResult result = db.DIYResult.Find(id);
         if (result != null)
         {
             db.DIYResult.Remove(result);
             db.SaveChanges();
             return(Content("Success"));
         }
         else
         {
             return(Content("Error"));
         }
     }
     else
     {
         return(RedirectToAction("Login", "Home"));
     }
 }
 public ActionResult DIYDetail(int id)
 {
     if (Session["admin"] != null)
     {
         DIYResult  result     = db.DIYResult.Find(id);
         StyleThird styleThird = db.StyleThird.Find(result.StyleDetailId);
         ViewBag.styleCode     = styleThird.StyleThirdCode;
         ViewBag.styleResource = styleThird.StyleResource;
         return(View(result));
     }
     else
     {
         return(RedirectToAction("Login", "Console"));
     }
 }