private async Task <bool> AddEntity(TrainingPlanViewModel model,
                                            ICollection <TrainingPlanMember> TrainingPlanMembers,
                                            IQueryable <Member> regions)
        {
            bool isSaveSuccess = true;
            List <TrainingPlanMember> TrainingPlanMemberList = new List <TrainingPlanMember>();

            foreach (var record in model.MemberIds)
            {
                var currentRolePermission = regions.Any(a => a.Id == record);
                if (currentRolePermission)
                {
                    TrainingPlanMember TrainingPlanMember = new TrainingPlanMember();
                    TrainingPlanMemberList.Add(TrainingPlanMember.ToEntity(record, model.Id, model.SessionUserId));
                }
            }

            if (TrainingPlanMemberList.Count > 0)
            {
                await _context.TrainingPlanMember.AddRangeAsync(TrainingPlanMemberList);

                await _context.SaveChangesAsync();

                isSaveSuccess = true;
            }

            return(isSaveSuccess);
        }
        private async Task <bool> AddTrainingPlanMemberWherePreviousExists(TrainingPlanViewModel model,
                                                                           ICollection <TrainingPlanMember> TrainingPlanMembers,
                                                                           IQueryable <Member> regions)
        {
            bool isSaveSuccess = true;
            List <TrainingPlanMember> assignedTrainingPlanMembers = new List <TrainingPlanMember>();

            foreach (var recordId in model.MemberIds)
            {
                var currentRolePermission = regions.Where(a => a.Id == recordId).FirstOrDefault();
                if (currentRolePermission != null)
                {
                    if (!TrainingPlanMembers.Any(a => a.MemberId == recordId))
                    {
                        // var currentUserRoleID = currentMenuRoles.First(a => a.Member.RoleID == currentRolePermission.RoleID).RegionID;
                        var TrainingPlanMemberRepo = new TrainingPlanMember();
                        assignedTrainingPlanMembers.Add(TrainingPlanMemberRepo.ToEntity(recordId, model.Id, model.SessionUserId));
                    }
                }
            }

            if (assignedTrainingPlanMembers.Count > 0)
            {
                await _context.TrainingPlanMember.AddRangeAsync(assignedTrainingPlanMembers);

                await _context.SaveChangesAsync();

                isSaveSuccess = true;
            }

            return(isSaveSuccess);
        }