public ActionResult CapNhat(int? id) { TaiKhoan tk = new TaiKhoan(); if (id != null) { tk = _taikhoanRepository.GetTaiKhoanByID(id); } TaiKhoanEditViewModel model = new TaiKhoanEditViewModel { MaTaiKhoan = tk.MaTaiKhoan, HoTen = tk.HoTen, TenTaiKhoan = tk.TenTaiKhoan, Email = tk.Email, DiaChi = tk.DiaChi, CMND = tk.CMND, CoQuan = tk.CoQuan, MaNhom = (int)tk.NhomNguoiDung, MaTinhTrang = (int)tk.TinhTrang, //MatKhau = MD5Helper.Equals( tinhtrangTaiKhoan = _tttkRespository.GetTinhTrangTaiKhoans().ToList(), nhomNguoiDung = _nhomnguoidungRespository.GetNhomNguoiDungs().ToList() }; return View(model); }
public ActionResult CapNhat(int id, TaiKhoanEditViewModel model) { try { TaiKhoan tk = new TaiKhoan(); tk = _taikhoanRepository.GetTaiKhoanByID(id); tk.TenTaiKhoan = model.TenTaiKhoan; tk.HoTen = model.HoTen; tk.CMND = model.CMND; tk.DiaChi = model.DiaChi; tk.Email = model.Email; tk.CoQuan = model.CoQuan; tk.TinhTrang = model.MaTinhTrang; tk.NhomNguoiDung = model.MaNhom; _taikhoanRepository.Save(); return RedirectToAction("thongbao", "qltaikhoan", new { iMsg = 1, id= id }); } catch { return RedirectToAction("thongbao", "qltaikhoan", new { iMsg = 2 , id = id}); } }