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 WeeklyTimeSpanService { private readonly IRepository _weeklytimespan; public WeeklyTimeSpanService(IRepository weeklytimespan) { _weeklytimespan = weeklytimespan ?? throw new ArgumentNullException(nameof(weeklytimespan)); } public IEnumerable GetAllWeeklyTimeSpans() { return _weeklytimespan.GetAll().ToList(); } public async Task AddWeeklyTimeSpan(WeeklyTimeSpan weeklytimespan) { return await _weeklytimespan.Create(weeklytimespan); } public bool DeleteWeeklyTimeSpan(int weeklytimespanId) { try { var item = _weeklytimespan.GetAll().Where(x => x.Id == weeklytimespanId).FirstOrDefault(); _weeklytimespan.Delete(item); return true; } catch (Exception) { return false; } } public bool UpdateWeeklyTimeSpan(WeeklyTimeSpan weeklytimespan) { try { var DataList = _weeklytimespan.GetAll().ToList(); foreach (var item in DataList) { _weeklytimespan.Update(item); } return true; } catch (Exception) { return true; } } } }