以下分别是Dal ,bll,controler层
Dal 层:
public void AddClothingToCart(int CloId, string UserId)
{
var oldRec = db.Cart.FirstOrDefault(p => p.CloID == CloId && p.UId == UserId);
if (oldRec!=null)
{
oldRec.ClothingCount += 1;
db.SaveChanges();
}
else
{
Cart newRec = new Cart();
newRec.CloID = CloId;
newRec.UId = UserId;
newRec.ClothingCount = 1;
db.Cart.Add(newRec);
db.SaveChanges();
}
}
bll层
public void AddClothingToCart(int CloId, string UserId)
{
new CartDAL().AddClothingToCart(CloId, UserId);
}
controler层:
[UserAuthController(RoleId = "1")]
public ActionResult AddClothingToCart()
{
string userId = User.Identity.Name;
var sr = new System.IO.StreamReader(Request.InputStream);
var jss = new JavaScriptSerializer();
int CloId = jss.Deserialize<int>(sr.ReadToEnd());
new OrderService().AddClothingToCart(CloId, userId);
var rst = new { status = 1 };
return Json(rst, JsonRequestBehavior.AllowGet);
}
有什么错误吗,我只知道他到new OrderService().AddClothingToCart(CloId, userId);就跳过下面两行,也没有什么错误啊,烦死了
人到中年有点甜