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; public PauseService(IRepository pause) { _pause = pause ?? throw new ArgumentNullException(nameof(pause)); } public IEnumerable GetAllPauses() { return _pause.GetAll().ToList(); } public async Task 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; } } } }