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});
     }
 }
Esempio n. 3
0
 partial void DeleteTaiKhoan(TaiKhoan instance);
 public ActionResult ChiTiet(int? id)
 {
     // Authenticated
     TaiKhoan model = new TaiKhoan();
     TaiKhoan tk = new TaiKhoan();
     tk = (id == null ? null : _taikhoanRepository.GetTaiKhoanByID(id));
     try
     {
         if (tk != null)
         {
             model = tk;
             return View(model);
         }
     }
     catch (Exception)
     {
         MessageHelper.CreateMessage(MessageType.Error, "", new List<string> { "error when display user" }, HttpContext.Response);
     }
     return RedirectToAction("Index","QLTaiKhoan");
 }
Esempio n. 5
0
 partial void UpdateTaiKhoan(TaiKhoan instance);
Esempio n. 6
0
 partial void InsertTaiKhoan(TaiKhoan instance);
Esempio n. 7
0
		private void detach_TaiKhoans(TaiKhoan entity)
		{
			this.SendPropertyChanging();
			entity.TinhTrangTaiKhoan = null;
		}
Esempio n. 8
0
		private void detach_TaiKhoans(TaiKhoan entity)
		{
			this.SendPropertyChanging();
			entity.NhomNguoiDung1 = null;
		}
        public ActionResult Dangky(RegisterViewModel model)
        {
            var myCaptcha = Request.Form["myCaptcha"];
            if (CaptchaHelper.VerifyAndExpireSolution(HttpContext, myCaptcha, model.Captcha))
            {
                // In a real app, actually register the user now
                if (ModelState.IsValid)
                {
                    if (_TaiKhoanRepository.IsExistUserName(model.TenTaiKhoan))
                    {
                        ModelState.AddModelError("", "Tài khoản đã tồn tại");
                        return View(model);
                    }

                    var tk = new TaiKhoan
                    {
                        TenTaiKhoan = model.TenTaiKhoan,
                        MatKhau = MD5Helper.GetHash(model.MatKhau),
                        Email = model.Email,
                        HoTen = model.HoTen,
                        DiaChi = model.DiaChi,
                        CoQuan = model.Coquan,
                        CMND = model.CMND,
                        TinhTrang = 2,
                        NhomNguoiDung = 1
                    };

                    var createStatus = _TaiKhoanRepository.CreateUser(tk);

                    if (createStatus == MembershipCreateStatus.Success) //success
                    {
                        // Sign in
                        return RedirectToAction("Index", "TrangChu");
                    }
                    else
                    {
                        ModelState.AddModelError("", AccountValidation.ErrorCodeToString(createStatus));
                    }
                }
            }
            else
            {
                // Redisplay the view with an error message
                ModelState.AddModelError("", "Captcha nhập sai - Xin vui lòng nhập lại");
            }

            return View(model);
        }