public ActionResult <object> CreateBySubjectList(TeacherClassSubjectSaveMethodSubjectListFORM formSubjectList)
        {
            try
            {
                Init();
                StringBuilder sbError   = new StringBuilder();
                int           isUpdated = _teacherClassSubjectService.SaveByTeacherClassSubject(null, formSubjectList, ref sbError);

                if (isUpdated > 0)
                {
                    return((string)"Teacher Class Subject Saved ");
                }
                Response.StatusCode = 400;
                return(sbError.ToString());
            }
            catch (Exception er)
            {
                return(Error(er));
            }
        }
        public int SaveByTeacherClassSubject(TeacherClassSubjectSaveMethodClassListFORM formClassList, TeacherClassSubjectSaveMethodSubjectListFORM formSubjectList, ref StringBuilder sbError)
        {
            bool dbFlag       = false;
            int  rowsAffected = 0;

            if (formSubjectList != null)
            {
                var classes = _uofRepository.ClassRepository.GetListClassesBySchoolID(_user.SchoolID, ref dbFlag);

                if (classes == null)
                {
                    return(0);
                }
                var classID = classes.Where(c => c.ClassID.Equals(formSubjectList.ClassID)).FirstOrDefault();
                if (classID == null)
                {
                    return(0);
                }


                foreach (var sub in (formSubjectList.SubjectList ?? new List <Guid>()))
                {
                    try
                    {
                        var isSaved = _uofRepository.TeacherClassSubjectRepository
                                      .SaveTeacherClassSubjectsBySubject(formSubjectList.TeacherID, formSubjectList.ClassID, sub, _user.TermID, _user.Username, ref dbFlag);
                        if (isSaved)
                        {
                            rowsAffected++;
                        }
                    }
                    catch (Exception er)
                    {
                        sbError.Append("Error saving one record , this can be due to a duplicate of a deleted record for audit purpose");
                    }
                }
            }
            else
            {
                /*
                 *
                 *
                 * Method 2
                 *
                 *
                 */

                var classes = _uofRepository.ClassRepository.GetListClassesBySchoolID(_user.SchoolID, ref dbFlag);

                if (classes == null || classes.Count() < 1)
                {
                    return(0);
                }


                foreach (var cl in (formClassList.ClassList ?? new List <Guid>()))
                {
                    var classID = classes.Where(c => c.ClassID.Equals(cl)).FirstOrDefault();
                    if (classID == null)
                    {
                        formClassList.ClassList.Remove(cl);
                    }
                    else if (classID.SchoolID != _user.SchoolID)
                    {
                        formClassList.ClassList.Remove(cl);
                    }
                    else
                    {
                        try
                        {
                            var isSaved = _uofRepository.TeacherClassSubjectRepository
                                          .SaveTeacherClassSubjectsBySubject(formClassList.TeacherID, cl, formClassList.SubjectID, _user.TermID, _user.Username, ref dbFlag);
                            if (isSaved)
                            {
                                rowsAffected++;
                            }
                        }
                        catch (Exception er)
                        {
                            sbError.Append("Error saving one record , this can be due to a duplicate of a deleted record for audit purpose");
                        }
                    }
                }
            }
            return(rowsAffected);
        }