initial commit
This commit is contained in:
59
Repository/RunbookRepository.cs
Normal file
59
Repository/RunbookRepository.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
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 RunbookRepository : IRunbookInterface
|
||||
{
|
||||
private readonly DataContext _context;
|
||||
|
||||
public RunbookRepository(DataContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public ICollection<RunbookModel> GetRunbooks()
|
||||
{
|
||||
return _context.Runbooks
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public RunbookModel GetRunbookById(Guid Id)
|
||||
{
|
||||
return _context.Runbooks
|
||||
.Where(r => r.Id == Id)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
public bool AddRunbookById(RunbookModel runbook)
|
||||
{
|
||||
_context.Add(runbook);
|
||||
|
||||
return SaveChanges();
|
||||
}
|
||||
public bool EditRunbookById(RunbookModel runbook)
|
||||
{
|
||||
_context.Update(runbook);
|
||||
return SaveChanges();
|
||||
}
|
||||
|
||||
public bool CheckRunbookById(Guid Id)
|
||||
{
|
||||
return _context.Runbooks
|
||||
.Any(r => r.Id == Id);
|
||||
}
|
||||
|
||||
public bool CheckRunbookByName(string Name)
|
||||
{
|
||||
return _context.Runbooks
|
||||
.Any(r => r.Name == Name);
|
||||
}
|
||||
|
||||
public bool SaveChanges()
|
||||
{
|
||||
var saved = _context.SaveChanges();
|
||||
return saved > 0 ? true : false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user