public void SaveMenuAccessrights(List <MenuAccessrightModel> data)
        {
            var isMultiRoleId = data.Select(t => t.MenuId).Distinct().Count() > 1;

            if (isMultiRoleId)
            {
                throw new DataValidationException("Role id more than one value.");
            }
            var roleId = data.Select(t => t.MenuId).FirstOrDefault();

            if (!roleRepository.IsExist(roleId))
            {
                throw new DataValidationException(MessageResource.Error_ReferenceDataNotExist, "Role");
            }
            CollectionSave.Execute(
                source: data,
                destination: menuRepository.GetAllAccessRight().Where(t => t.RoleId == roleId).ToList(),
                matchFunc: (t1, t2) => t1.MenuId == t2.MenuId && t1.RoleId == t2.RoleId,
                addFunc: t1 => menuRepository.AddAccessRight(new MenuAccessRight()
            {
                RoleId = t1.RoleId, MenuId = t1.MenuId
            }),
                updateFunc: (t1, t2) => { },
                removeFunc: t2 => menuRepository.RemoveAccesRight(t2)
                );

            unitOfWork.SaveChanges();
        }
        public void SaveRoleOperationMapping(RoleOperationMappingModel data)
        {
            if (!roleRepository.IsExist(data.RoleId))
            {
                throw new DataValidationException(string.Format(MessageResource.Error_ReferenceDataNotExist, "Role"));
            }

            CollectionSave.Execute(
                source: data.OperationIds,
                destination: roleRepository.GetOperations(data.RoleId).ToList(),
                matchFunc: (t1, t2) => t1 == t2.OperationId,
                addFunc: t1 => roleRepository.AddOperation(new RoleOperation()
            {
                RoleId      = data.RoleId,
                OperationId = t1
            }),
                updateFunc: (t1, t2) => { },
                removeFunc: t2 => roleRepository.RemoveOperation(t2));

            unitOfWork.SaveChanges();
        }