public JsonResult SaveRecipients(FormCollection collection)
        {
            AssignUserInfo();
            RecipientBusiness = Get <QL_NGUOINHAN_VANBANBusiness>();

            JsonResultBO result = new JsonResultBO(true);
            long         id     = collection["ID"].ToLongOrZero();

            QL_NGUOINHAN_VANBAN recipients = RecipientBusiness.Find(id) ?? new QL_NGUOINHAN_VANBAN();

            recipients.TEN_NHOM = collection["TEN_NHOM"];
            bool existed = RecipientBusiness.CheckExistedName(recipients.TEN_NHOM, recipients.ID);

            if (existed)
            {
                result.Status  = false;
                result.Message = "Nhóm đã tồn tại trên hệ thống";
            }

            recipients.NGUOINHAN_IDS  = collection["NGUOINHAN_IDS"];
            recipients.DM_PHONGBAN_ID = currentUser.DM_PHONGBAN_ID.GetValueOrDefault();
            recipients.IS_DEFAULT     = collection["IS_DEFAULT"].ToIntOrZero() > 0;
            RecipientBusiness.Save(recipients);

            result.Message = "Cập nhật nhóm người nhận thành công";
            return(Json(result));
        }
        /// <summary>
        /// @author: duynn
        /// </summary>
        /// <returns></returns>
        public PartialViewResult EditRecipients(int id = 0)
        {
            AssignUserInfo();
            RecipientBusiness      = Get <QL_NGUOINHAN_VANBANBusiness>();
            UserBusiness           = Get <DM_NGUOIDUNGBusiness>();
            CCTC_THANHPHANBusiness = Get <CCTC_THANHPHANBusiness>();

            QLNguoiNhanVanBanEditViewModel viewModel = new QLNguoiNhanVanBanEditViewModel();
            QL_NGUOINHAN_VANBAN            entity    = RecipientBusiness.Find(id) ?? new QL_NGUOINHAN_VANBAN();
            List <long> choosenUserIds = new List <long>();

            /**
             * dah sách ngươi dùng
             */
            if (!string.IsNullOrEmpty(entity.NGUOINHAN_IDS))
            {
                choosenUserIds = entity.NGUOINHAN_IDS.ToListLong(',');
            }

            /**
             * lấy danh sách người dùng phòng ban
             */
            List <NguoiDungPhongBanBO> groupDepts = UserBusiness.GetUsersOfDepartments();

            //if (currentUser.ListVaiTro.Any(x=>x.MA_VAITRO == "QLHT"))
            //{
            //    groupDeptUsers = UserBusiness.GetUsersOfDepartments();
            //}
            //else
            //{
            //    groupDeptUsers = UserBusiness.GetUsersOfDepartments(currentUser.DM_PHONGBAN_ID.GetValueOrDefault());
            //}

            foreach (var dept in groupDepts)
            {
                SelectListGroup group = new SelectListGroup()
                {
                    Name = dept.PhongBan.NAME
                };
                viewModel.GroupUsers.AddRange(this.GetGroupUsers(group, choosenUserIds, dept.LstNguoiDung));
            }
            viewModel.Department    = CCTC_THANHPHANBusiness.Find(currentUser.DM_PHONGBAN_ID) ?? new CCTC_THANHPHAN();
            viewModel.IsSystemAdmin = currentUser.ListVaiTro.Any(x => x.MA_VAITRO == "QLHT");
            viewModel.Entity        = entity;
            return(PartialView("_EditRecipient", viewModel));
        }
        /// <summary>
        /// @author: duynn
        /// </summary>
        /// <returns></returns>
        public JsonResult Delete(long id)
        {
            JsonResultBO result = new JsonResultBO(true);

            RecipientBusiness = Get <QL_NGUOINHAN_VANBANBusiness>();
            QL_NGUOINHAN_VANBAN entity = RecipientBusiness.Find(id);

            if (entity != null)
            {
                RecipientBusiness.repository.Delete(id);
                result.Message = "Xóa nhóm người nhận thành công";
            }
            else
            {
                result.Status  = false;
                result.Message = "Thông tin nhóm người nhận không tồn tại";
            }
            return(Json(result));
        }