public ActionResult LuuAnhDaiDien() { var currentUser = HttpContext.User.Identity.GetUserLogin(); var files = Request.Files; if (files.Count > 0) { // upload new file var fileName = FileHelper.UploadFile("~/Uploads/UserImages/", files); if (!string.IsNullOrEmpty(fileName)) { // save new filename to db CanBoService _canbo = new CanBoService(); var canbo = _canbo.FindByKey(currentUser.CanBoId); var oldImage = canbo.AnhDaiDien; canbo.AnhDaiDien = fileName; _canbo.Update(canbo); Session.Remove("_Avatar"); Session["_Avatar"] = canbo.AnhDaiDien; // delete old image FileHelper.RemoveFile(Server.MapPath(oldImage)); return(Json(true, JsonRequestBehavior.AllowGet)); } } return(Json(false, JsonRequestBehavior.AllowGet)); }
public ActionResult ViewHieuChinhCanBo(int?id) { CanBoService _canbo = new CanBoService(); HoSoCanBo canbo = new HoSoCanBo(); if (id.HasValue && id.Value != 0) { canbo = _canbo.FindByKey(id.Value); } return(PartialView("_HieuChinhCanBo", canbo)); }
public ActionResult ThemMoi(int?id) { CanBoService _canbo = new CanBoService(); var canbo = new HoSoCanBo(); if (id.HasValue && id.Value > 0) { canbo = _canbo.FindByKey(id.Value); } return(View(canbo)); }
public JsonResult ThayDoiTrangThai(int?id) { if (id.HasValue) { CanBoService _canbo = new CanBoService(); var canbo = _canbo.FindByKey(id.Value); if (canbo != null) { canbo.ConHoatDong = canbo.ConHoatDong.HasValue ? !canbo.ConHoatDong : true; _canbo.Update(canbo); return(Json(new { status = true }, JsonRequestBehavior.AllowGet)); } } return(Json(new { status = false, message = "Cán bộ không khả dụng" })); }
public ActionResult CapNhatMatKhau(CapNhatTaiKhoanNguoiDung taikhoan) { CanBoService _canbo = new CanBoService(); var cb = _canbo.FindByKey(taikhoan.CanBoId); // check old password if (cb.MatKhau != EncryptHelper.EncryptMD5(taikhoan.MatKhau)) { return(Json(new { Success = false, Message = "Mật khẩu cũ không đúng" }, JsonRequestBehavior.DenyGet)); } // update new password cb.MatKhau = EncryptHelper.EncryptMD5(taikhoan.MatKhauMoi); _canbo.Update(cb); return(Json(new { Success = true, Message = "Đã thay đổi mật khẩu" }, JsonRequestBehavior.DenyGet)); }
public ActionResult CapNhatThongTin(CapNhatThongTinCanBo canbo) { CanBoService _canbo = new CanBoService(); var cb = _canbo.FindByKey(canbo.CanBoId); cb.HoVaTen = canbo.HoVaTen; cb.SoCMND = canbo.SoCMND; cb.SoTheCanCuoc = canbo.SoTheCanCuoc; cb.Email = canbo.Email; cb.DienThoai = canbo.DienThoai; _canbo.Update(cb); // update session Session.Remove("_FULLNAME"); Session["_FULLNAME"] = string.IsNullOrEmpty(cb.HoVaTen) ? "" : cb.HoVaTen; Session.Remove("_EMAIL"); Session["_EMAIL"] = string.IsNullOrEmpty(cb.Email) ? "" : cb.Email; Session.Remove("_TEL"); Session["_TEL"] = string.IsNullOrEmpty(cb.DienThoai) ? "" : cb.DienThoai; return(Json(new { Success = true, Message = "Đã thay đổi thông tin" }, JsonRequestBehavior.DenyGet)); }