61 lines
1.7 KiB
C#
61 lines
1.7 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 WeeklyTimeSpanService
|
|
{
|
|
private readonly IRepository<WeeklyTimeSpan> _weeklytimespan;
|
|
|
|
public WeeklyTimeSpanService(IRepository<WeeklyTimeSpan> weeklytimespan)
|
|
{
|
|
_weeklytimespan = weeklytimespan ?? throw new ArgumentNullException(nameof(weeklytimespan));
|
|
}
|
|
|
|
public IEnumerable<WeeklyTimeSpan> GetAllWeeklyTimeSpans()
|
|
{
|
|
return _weeklytimespan.GetAll().ToList();
|
|
}
|
|
|
|
public async Task<WeeklyTimeSpan> 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;
|
|
}
|
|
}
|
|
}
|
|
}
|