Files
Microsoft.SelfService.Porta…/Repository/ServiceRepository.cs
2026-04-15 15:02:32 +02:00

49 lines
1.2 KiB
C#

using Microsoft.SelfService.Portal.Core.API.Context;
using Microsoft.SelfService.Portal.Core.API.Interfaces;
using Microsoft.SelfService.Portal.Core.API.Models;
namespace Microsoft.SelfService.Portal.Core.API.Repository
{
public class ServiceRepository : IServiceInterface
{
private readonly DataContext _context;
public ServiceRepository(DataContext context)
{
_context = context;
}
public ICollection<ServiceModel> GetServices()
{
return _context.Services
.ToList();
}
public ServiceModel GetServiceById(Guid Id)
{
return _context.Services
.Where(s=>s.Id == Id)
.FirstOrDefault();
}
public bool CheckServiceById(Guid Id)
{
return _context.Services
.Any(s =>s.Id == Id);
}
public ServiceModel GetServiceByName(string Name)
{
return _context.Services
.Where(s => s.Name == Name)
.FirstOrDefault();
}
public bool CheckServiceByName(string Name)
{
return _context.Services
.Any(s => s.Name == Name);
}
}
}