92 lines
2.4 KiB
C#
92 lines
2.4 KiB
C#
using HanyadikHetVan.Data.Entities;
|
|
using HanyadikHetVan.Interface;
|
|
using HanyadikHetVan.Services;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace HanyadikHetVan.Controllers
|
|
{
|
|
[Route("api/pause")]
|
|
[ApiController]
|
|
public class PauseController
|
|
{
|
|
private readonly PauseService _pauseService;
|
|
|
|
private readonly IRepository<Pause> _pause;
|
|
|
|
public PauseController(IRepository<Pause> pause, PauseService pauseService)
|
|
{
|
|
_pauseService = pauseService;
|
|
_pause = pause;
|
|
}
|
|
[HttpPost]
|
|
public async Task<Object> AddPause([FromBody] Pause weeklytimespan)
|
|
{
|
|
try
|
|
{
|
|
await _pauseService.AddPause(weeklytimespan);
|
|
return true;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
|
|
return false;
|
|
}
|
|
}
|
|
[HttpDelete]
|
|
public bool DeletePause(int weeklyTimeSpanId)
|
|
{
|
|
try
|
|
{
|
|
_pauseService.DeletePause(weeklyTimeSpanId);
|
|
return true;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
[HttpPut]
|
|
public bool UpdatePause(Pause Object)
|
|
{
|
|
try
|
|
{
|
|
_pauseService.UpdatePause(Object);
|
|
return true;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
[HttpGet]
|
|
public Object GetAllPauses(DateTime UserEmail)
|
|
{
|
|
var data = _pauseService.GetPersonByUserName(UserEmail);
|
|
var json = JsonConvert.SerializeObject(data, Formatting.Indented,
|
|
new JsonSerializerSettings()
|
|
{
|
|
ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
|
|
}
|
|
);
|
|
return json;
|
|
}
|
|
[HttpGet]
|
|
public Object GetAllPauses()
|
|
{
|
|
var data = _pauseService.GetAllPauses();
|
|
var json = JsonConvert.SerializeObject(data, Formatting.Indented,
|
|
new JsonSerializerSettings()
|
|
{
|
|
ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
|
|
}
|
|
);
|
|
return json;
|
|
}
|
|
}
|
|
}
|