示例#1
0
        public ActionResult Edit(long MaGiangVien)
        {
            _db.DbContext.Configuration.ProxyCreationEnabled = false;
            GiangVien          model  = _db.GetOne <GiangVien>(o => o.MaGiangVien == MaGiangVien);
            CrudModelGiangVien _model = new CrudModelGiangVien();

            WebMVC.COMMON.Helpers.CopyObject <CrudModelGiangVien>(model, ref _model);
            initialCategoryEditAction(_model);
            return(View(_model));
        }
示例#2
0
 public ActionResult Edit(CrudModelGiangVien model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             GiangVien _model = _db.GetOne <GiangVien>(o => o.MaGiangVien == model.MaGiangVien);
             COMMON.Helpers.CopyObject <GiangVien>(model, ref _model);
             _db.Update <GiangVien>(_model);
         }
         catch (Exception ex)
         {
             ModelState.AddModelError("", "Cập nhật quản trị viên thất bại.");
         }
     }
     return(RedirectToAction("Index"));
 }
示例#3
0
 public ActionResult Create(CrudModelGiangVien model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             GiangVien _model = new GiangVien();
             COMMON.Helpers.CopyObject <GiangVien>(model, ref _model);
             _db.Insert <GiangVien>(_model);
             _db.SaveChange();
             return(RedirectToAction("Index", "GiangVien"));
         }
         catch (Exception)
         {
             ModelState.AddModelError("", "Thêm quản trị viên thất bại.");
         }
     }
     return(View("Index"));
 }
示例#4
0
 public void initialCategoryEditAction(CrudModelGiangVien view)
 {
     //ViewBag.lstQuyenQuanTri = new SelectList(_db.Filter<DMQuyenQuanTri>(x => x.MaQuyenQuanTri == view.MaQuyenQuanTri), "MaQuyenQuanTri", "TenQuyenQuanTri");
     ViewBag.lstGioiTinh = new SelectList(_db.GetAll <DMGioiTinh>(), "MaGioiTinh", "TenGioiTinh", view.MaGioiTinh);
 }