initial commit
This commit is contained in:
48
Repository/ServiceRepository.cs
Normal file
48
Repository/ServiceRepository.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user