public bool Update(loaikhachhang entity) { var type = db.loaikhachhangs.Find(entity.lkh_ma); type.lkh_ten = entity.lkh_ten; type.lkh_dongia = entity.lkh_dongia; db.SaveChanges(); return(true); }
// GET: Admin/UserType public ActionResult Index() { UserTypeDao db = new UserTypeDao(); List <loaikhachhang> list = db.List(); loaikhachhang type = new loaikhachhang(); ViewData["list"] = list; ViewData["type"] = type; return(View()); }
public ActionResult Update(loaikhachhang model) { try { var type = new UserTypeDao().Update(model); if (TempData["ModelSuccess"] == null) { TempData.Add("ModelSuccess", "Cập nhật thành công."); } return(RedirectToAction("Index", "UserType")); } catch (Exception e) { Console.WriteLine(e.Message); } if (TempData["ModelErrors"] == null) { TempData.Add("ModelErrors", "Có lỗi xảy ra! Không thể cập nhật."); } return(RedirectToAction("Index", "UserType")); }
public ActionResult Store(loaikhachhang model) { try { UserTypeDao db = new UserTypeDao(); db.Insert(model); if (TempData["ModelSuccess"] == null) { TempData.Add("ModelSuccess", "Thêm thành công."); } return(RedirectToAction("Index", "UserType")); } catch (Exception e) { Console.WriteLine(e.Message); } if (TempData["ModelErrors"] == null) { TempData.Add("ModelErrors", "Có lỗi xảy ra! Không thể thêm."); } return(RedirectToAction("Index", "UserType")); }
public int Insert(loaikhachhang entity) { db.loaikhachhangs.Add(entity); db.SaveChanges(); return(entity.lkh_ma); }