// update public bool Update(NhomTK entity) { try { var tt = db.NhomTKs.Find(entity.MaNhomTK); tt.MaNhomTK = entity.MaNhomTK; tt.TenNhomTK = entity.TenNhomTK; db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public JsonResult Delete(int id) { bool result = false; TaiKhoan ct = db.TaiKhoans.Where(x => x.MaNhomTK == id).FirstOrDefault(); if (ct == null) { NhomTK s = db.NhomTKs.Where(x => x.MaNhomTK == id).SingleOrDefault(); if (s != null) { new UserGroupDao().Delete(id); db.SaveChanges(); result = true; } } return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult Edit(NhomTK tt) { if (ModelState.IsValid) { var dao = new UserGroupDao(); var result = dao.Update(tt); if (result) { SetAlert("Sửa thông tin nhóm tài khoản thành công", "success"); return(RedirectToAction("Index", "UserGroup")); } else { ModelState.AddModelError("", "Cập nhật nhóm tài khoản không thành công"); } } return(View("Index")); }
public ActionResult Create(NhomTK tt) { if (ModelState.IsValid) { var dao = new UserGroupDao(); long id = dao.Insert(tt); if (id > 0) { SetAlert("Thêm nhóm user thành công", "success"); return(RedirectToAction("Index", "UserGroup")); } else { ModelState.AddModelError("", "Thêm nhóm tài khoản không thành công"); } } return(View("Index")); }
// Insert public long Insert(NhomTK entity) { db.NhomTKs.Add(entity); db.SaveChanges(); return(entity.MaNhomTK); }