private bool IsKeyValid(TeachingAssignmentModel model)
        {
            if (!_exist.TeacherExists(model.TeacherID))
            {
                _resp.code = 404;
                _resp.messages.Add("Teacher not found");
                return(false);
            }

            if (!_exist.ClassExists(model.ClassID))
            {
                _resp.code = 404;
                _resp.messages.Add("Class not found");
                return(false);
            }

            if (!_exist.SubjectExists(model.SubjectID))
            {
                _resp.code = 404;
                _resp.messages.Add("Subject not found");
                return(false);
            }

            return(true);
        }
コード例 #2
0
        private bool IsEditKeysValid(ClassModel model)
        {
            // Check if Grade ID exists
            if (!exist.GradeExists(model.GradeID))
            {
                resp.code = 404;
                resp.messages.Add(new { GradeID = "Grade not found" });
                return(false);
            }

            // check if Head Teacher exists
            if (model.HeadTeacherID != null)
            {
                if (!exist.TeacherExists(model.HeadTeacherID))
                {
                    resp.code = 404;
                    resp.messages.Add(new { HeadTeacherID = "Head teacher not found" });
                    return(false);
                }
            }

            // all keys are valid
            return(true);
        }