61 lines
1.4 KiB
C#
61 lines
1.4 KiB
C#
using HanyadikHetVan.Data.Entities;
|
|
using HanyadikHetVan.Interface;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace HanyadikHetVan.Services
|
|
{
|
|
public class PauseService
|
|
{
|
|
private readonly IRepository<Pause> _pause;
|
|
|
|
public PauseService(IRepository<Pause> pause)
|
|
{
|
|
_pause = pause ?? throw new ArgumentNullException(nameof(pause));
|
|
}
|
|
|
|
public IEnumerable<Pause> GetAllPauses()
|
|
{
|
|
return _pause.GetAll().ToList();
|
|
}
|
|
|
|
public async Task<Pause> AddPause(Pause pause)
|
|
{
|
|
return await _pause.Create(pause);
|
|
}
|
|
|
|
public bool DeletePause(int pauseId)
|
|
{
|
|
try
|
|
{
|
|
var item = _pause.GetAll().Where(x => x.Id == pauseId).FirstOrDefault();
|
|
_pause.Delete(item);
|
|
return true;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public bool UpdatePause(Pause pause)
|
|
{
|
|
try
|
|
{
|
|
var DataList = _pause.GetAll().ToList();
|
|
foreach (var item in DataList)
|
|
{
|
|
_pause.Update(item);
|
|
}
|
|
return true;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|