public ActionResult AllotAdmit(int id) { UsersBLL usreBll = new UsersBLL(); string loginName = Request.Form["U_LoginName"]; int S_ID = Convert.ToInt32(Request.Form["S_ID"]); ShopsBLL shopBll = new ShopsBLL(); Shops s = shopBll.SelectWhere(m => m.S_ID == S_ID).FirstOrDefault(); Users u = new Users(); try { using (TransactionScope ts = new TransactionScope()) { u.U_LoginName = loginName; u.U_Password = "******"; u.S_ID = S_ID; u.U_Role = 2; s.S_IsHasSetAdmin = true; shopBll.SaveChanges(); usreBll.Add(u); usreBll.SaveChanges(); ts.Complete(); } return Json(new { result = "ok" }); } catch { return Json(new { result = "error" }); } }
public ActionResult Delete(int id) { try { ShopsBLL spBll = new ShopsBLL(); UsersBLL uBll = new UsersBLL(); Shops shop = spBll.Find(id); Users user = uBll.SelectWhere(m => m.S_ID == shop.S_ID && m.U_Role == 2).FirstOrDefault(); using (TransactionScope ts = new TransactionScope()) { // 软删除当前店铺的管理员 if (user != null) { user.U_Role = 4; uBll.SaveChanges(); } shop.S_Category = 4; spBll.SaveChanges(); ts.Complete(); } return Json(new { result = "ok" }); } catch { return Json(new { result = "error" }); } }
public ActionResult Create(Shops shop) { try { ShopsBLL db = new ShopsBLL(); shop.S_CreateTime = DateTime.Now; shop.S_IsHasSetAdmin = false; db.Add(shop); db.SaveChanges(); return Json(new { result = "ok" }); } catch { return Json(new { result = "error" }); } }
public ActionResult Edit(Shops shop) { try { ShopsBLL db = new ShopsBLL(); db.Edit(shop, "S_Name", "S_Category", "S_ContactName", "S_ContactTel", "S_Address", "S_Remark"); db.SaveChanges(); return Json(new { result = "ok" }); } catch { return Json(new { result = "error" }); } }