public void kichHoatTaiKhoan(string id, string userId, int trangThai) { try { if (string.IsNullOrEmpty(id)) { Clients.Caller.UpdateResult(false); } NguoiDung nd = xlNguoiDung.Doc(id); if (nd == null) { Clients.Caller.UpdateResult(false); } nd.KichHoat = trangThai; nd.IdNguoiCapNhat = userId; Clients.Caller.UpdateResult(xlNguoiDung.CapNhat(nd)); } catch (Exception) { Clients.Caller.UpdateResult(false); } }
public ActionResult ChinhSua(FormCollection collection) { if (SessionManager.CheckSession(ConstantValues.SessionKeyCurrentUser)) { NotifyModel thongBao = new NotifyModel(); string id = collection["nguoiDungId"].ToString(); if (string.IsNullOrEmpty(id)) { return(RedirectToAction("Index", "NguoiDung")); } NguoiDung nguoiDung = xlNguoiDung.Doc(id); try { if (!string.IsNullOrEmpty(collection["save"].ToString())) { int kichHoat = 0; if (collection["kich_hoat"] != null && !string.IsNullOrEmpty(collection["kich_hoat"].ToString()) && collection["kich_hoat"].ToString() == "on") { kichHoat = 1; } nguoiDung.Ten = collection["ten"].ToString(); nguoiDung.Email = collection["email"].ToString(); nguoiDung.DienThoai = collection["dienThoai"].ToString(); nguoiDung.IdVaiTro = collection["vaiTro"].ToString(); nguoiDung.IdDonVi = collection["donVi"].ToString(); var nhomNguoiDungIds = collection["nhomNguoiDung"].Split(','); List <string> nndIdList = nhomNguoiDungIds.ToList(); nguoiDung.DanhSachNhom = nndIdList; List <string> dsChucNang = nguoiDung.DanhSachChucNang; foreach (var nndId in nndIdList) { NhomNguoiDung nhomNguoiDung = xlNhomNguoiDung.Doc(nndId); foreach (var cn in nhomNguoiDung.DanhSachChucNang) { if (!dsChucNang.Contains(cn)) { dsChucNang.Add(cn); } } } nguoiDung.DanhSachChucNang = dsChucNang; nguoiDung.KichHoat = kichHoat; nguoiDung.IdNguoiCapNhat = currentUser.Id.ToString(); if (xlNguoiDung.CapNhat(nguoiDung)) { thongBao.TypeNotify = "alert-success"; thongBao.Message = "Chỉnh sửa thông tin thành công"; } else { thongBao.TypeNotify = "alert-danger"; thongBao.Message = "Chỉnh sửa thông tin thất bại!"; } } } catch (Exception) { thongBao.TypeNotify = "alert-danger"; thongBao.Message = "Chỉnh sửa thông tin thất bại!"; } ViewBag.ThongBao = thongBao; var model = new NguoiDungModel(); model.DanhSachVaiTro = DocDanhSachVaiTro(); model.DanhSachDonVi = DocDanhSachDonVi(); model.DanhSachNhomNguoiDung = DocDanhSachNhomNguoiDung(); model.NguoiDungHienTai = nguoiDung; return(View("ChinhSua", model)); } if (Request.Url != null) { SessionManager.RegisterSession(ConstantValues.SessionKeyUrl, Request.Url.AbsolutePath); } return(RedirectToAction("Index", "Login")); }