-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnewfile
More file actions
30 lines (26 loc) · 876 Bytes
/
newfile
File metadata and controls
30 lines (26 loc) · 876 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System.Collections.Generic;
using System.Linq;
namespace CourseApplication.Services
{
public class CourseSearchService
{
private readonly ApplicationDbContext _context;
public CourseSearchService(ApplicationDbContext context)
{
_context = context;
}
/// <summary>
/// Searches for courses by keyword.
/// </summary>
/// <param name="keyword">The search keyword (in title or description).</param>
/// <returns>List of matching courses.</returns>
public List<Course> SearchCourses(string keyword)
{
if (string.IsNullOrEmpty(keyword))
return new List<Course>();
return _context.Courses
.Where(c => c.Title.Contains(keyword) || c.Description.Contains(keyword))
.ToList();
}
}
}