public ActionResult Pingluen(string a, FoodShareComment foodShareComment) { if (Session["user"] != null) { if (a != "") { string comment = a; foodShareComment.FsComment_content = comment; foodShareComment.Fs_id = (int)Session["Fs_id"]; foodShareComment.User_id = (int)Session["userid"]; foodShareComment.Addtime = System.DateTime.Now; db.FoodShareComment.Add(foodShareComment); db.SaveChanges(); return(Content(a)); } else { return(Content("<script> alert('评论不能为空!'); </script>")); } } else { return(Content("<script>;alert('请先登录!');</script>")); } }
public ActionResult Xiugai(UserInfo us) { try { HttpPostedFileBase postimageBase = Request.Files["User_img"]; if (postimageBase != null) { string filePath = postimageBase.FileName; string filename = filePath.Substring(filePath.LastIndexOf("\\") + 1); string serverpath = Server.MapPath(@"/images/User/") + filename; string relativepath = @"/images/User/" + filename; postimageBase.SaveAs(serverpath); us.User_img = relativepath; } int id = (int)Session["userid"]; UserInfo us1 = db.UserInfo.Where(n => n.User_id == id).FirstOrDefault(); us1.User_img = us.User_img; us1.User_name = us.User_name; us1.User_sex = us.User_sex; us1.User_sign = us.User_sign; int result = db.SaveChanges(); if (result > 0) { return(RedirectToAction("Index", "User")); } else { return(Content("<scrip> 修改有误</script>")); } } catch (Exception e) { return(Content(e.Message)); } }
public ActionResult Regist(UserInfo us) { if (ModelState.IsValid) { string vCode = Request.Form["txtverifcode1"]; if (vCode != Session["ValidateCode"].ToString()) { return(Content("<script>;alert('验证码错误!');history.go(-1)</script>")); } //var user = db.Userinfo.Where(u => u.Username == us.Username).FirstOrDefault(); //if (user != null) // return Content("<script>;alert('用户名已被占用!');history.go(-1)</script>"); } db.UserInfo.Add(us); int result = db.SaveChanges(); if (result > 0) { return(RedirectToAction("Login")); } else { return(RedirectToAction("Regist")); } }
public ActionResult Menu(FoodShare fs) { try { HttpPostedFileBase postimageBase = Request.Files["img"]; if (Session["user"] != null) { if (postimageBase != null) { string filePath = postimageBase.FileName; string filename = filePath.Substring(filePath.LastIndexOf("\\") + 1); string serverpath = Server.MapPath(@"/images/Food/") + filename; string relativepath = @"/images/Food/" + filename; postimageBase.SaveAs(serverpath); fs.Fs_img = relativepath; fs.User_id = (int)Session["userid"]; if (fs.Fs_detail != null && fs.Fs_title != null && fs.Fs_lable != null) { db.FoodShare.Add(fs); db.SaveChanges(); return(Content("<script> alert('发布菜谱成功!'); history.go(-1)</script>")); } else { return(Content("发布内容有为空!")); } } else { return(Content("<script>;alert('请先上传菜品图片!');history.go(-1)</script>")); } } else { return(Content("<script> alert('您还没有登录!'); history.go(-1);</script>")); } } catch (Exception ex) { return(Content(ex.Message)); } }
public void Save() { try { var count = _entities.SaveChanges(); _logger.LogDebug($"{count} state entries written to database"); } catch (Exception ex) { _logger.LogError("Error when saving to database", ex); throw; } }
public List <dynamic> addFoodTypeWithFoods([FromBody] FoodType foodType) { if (foodType != null) { FoodEntities db = new FoodEntities(); db.Configuration.ProxyCreationEnabled = false; db.FoodTypes.Add(foodType); db.SaveChanges(); return(getAllFoodTypesWithFood()); } else { return(null); } }
public ActionResult Edit(FoodShare us) { FoodShare user1 = db.FoodShare.Where(n => n.Fs_id == us.Fs_id).First(); user1.Fs_title = us.Fs_title; user1.Fs_lable = us.Fs_lable; user1.Fs_detail = us.Fs_detail; int result = db.SaveChanges(); if (result > 0) { return(RedirectToAction("Index", "User")); } else { return(Content("<script> alert('没有修改');history.go(-1); </script>")); } }
public ProductPrice Add(ProductPrice price) { FoodEntities.ProductPrices.Add(price); FoodEntities.SaveChanges(); return(price); }
public MarketProduct Add(MarketProduct marketProduct) { FoodEntities.MarketProducts.Add(marketProduct); FoodEntities.SaveChanges(); return(marketProduct); }
public TempProduct Add(TempProduct product) { FoodEntities.TempProducts.Add(product); FoodEntities.SaveChanges(); return(product); }
public Product Add(Product product) { FoodEntities.Products.Add(product); FoodEntities.SaveChanges(); return(product); }