View Code for Logic/CourseLogic.cs

Source code for the file Logic/CourseLogic.cs is shown below.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QuantumConcepts.CodeGenerator.Sample.DataAccess;
using QuantumConcepts.Common.Extensions;

namespace QuantumConcepts.CodeGenerator.Sample.Logic
{
    public partial class CourseLogic
    {
        static partial void PerformPreDeleteLogic(SampleDataContext context, Course obj)
        {
            if (!obj.Enrollments.IsNullOrEmpty())
                obj.Enrollments.ForEach(o => EnrollmentLogic.DeleteEnrollment(context, o.ID));
        }

        public static List<Course> FindCourseAPI(SampleDataContext context, string keyword)
        {
            return (from c in context.Courses
                    where
                        c.Name.Contains(keyword)
                        || c.Teacher.FirstName.Contains(keyword)
                        || c.Teacher.LastName.Contains(keyword)
                    select c).ToList();
        }
    }
}