This commit is contained in:
parent
bd788697c7
commit
4b993aa4e8
@ -19,7 +19,7 @@ namespace HanyadikHetVan.Controllers
|
||||
_service = service;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[HttpGet("json")]
|
||||
[Consumes("application/json")]
|
||||
public HanyadikHetVanDTO GetJson()
|
||||
{
|
||||
|
@ -4,8 +4,6 @@ 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
|
||||
@ -24,11 +22,11 @@ namespace HanyadikHetVan.Controllers
|
||||
_pause = pause;
|
||||
}
|
||||
[HttpPost]
|
||||
public async Task<Object> AddPause([FromBody] Pause weeklytimespan)
|
||||
public async Task<Object> AddPause([FromBody] Pause pause)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _pauseService.AddPause(weeklytimespan);
|
||||
await _pauseService.AddPause(pause);
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
@ -37,12 +35,12 @@ namespace HanyadikHetVan.Controllers
|
||||
return false;
|
||||
}
|
||||
}
|
||||
[HttpDelete]
|
||||
public bool DeletePause(int weeklyTimeSpanId)
|
||||
[HttpDelete("{pauseId}")]
|
||||
public bool DeletePause(int pauseId)
|
||||
{
|
||||
try
|
||||
{
|
||||
_pauseService.DeletePause(weeklyTimeSpanId);
|
||||
_pauseService.DeletePause(pauseId);
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
@ -51,11 +49,11 @@ namespace HanyadikHetVan.Controllers
|
||||
}
|
||||
}
|
||||
[HttpPut]
|
||||
public bool UpdatePause(Pause Object)
|
||||
public bool UpdatePause([FromBody] Pause pause)
|
||||
{
|
||||
try
|
||||
{
|
||||
_pauseService.UpdatePause(Object);
|
||||
_pauseService.UpdatePause(pause);
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
@ -64,25 +62,13 @@ namespace HanyadikHetVan.Controllers
|
||||
}
|
||||
}
|
||||
[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
|
||||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
|
||||
}
|
||||
);
|
||||
return json;
|
||||
|
11
HanyadikHetVan/Controllers/UserController.cs
Normal file
11
HanyadikHetVan/Controllers/UserController.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HanyadikHetVan.Controllers
|
||||
{
|
||||
public class UserController
|
||||
{
|
||||
}
|
||||
}
|
@ -4,8 +4,6 @@ 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
|
||||
@ -37,7 +35,7 @@ namespace HanyadikHetVan.Controllers
|
||||
return false;
|
||||
}
|
||||
}
|
||||
[HttpDelete]
|
||||
[HttpDelete("{weeklyTimeSpanId}")]
|
||||
public bool DeleteWeeklyTimeSpan(int weeklyTimeSpanId)
|
||||
{
|
||||
try
|
||||
@ -51,11 +49,11 @@ namespace HanyadikHetVan.Controllers
|
||||
}
|
||||
}
|
||||
[HttpPut]
|
||||
public bool UpdateWeeklyTimeSpan(WeeklyTimeSpan Object)
|
||||
public bool UpdateWeeklyTimeSpan([FromBody] WeeklyTimeSpan weeklytimespan)
|
||||
{
|
||||
try
|
||||
{
|
||||
_weeklytimespanService.UpdateWeeklyTimeSpan(Object);
|
||||
_weeklytimespanService.UpdateWeeklyTimeSpan(weeklytimespan);
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
@ -63,14 +61,14 @@ namespace HanyadikHetVan.Controllers
|
||||
return false;
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public Object GetAllWeeklyTimeSpanByStartdate(DateTime UserEmail)
|
||||
[HttpGet("{startTime}")]
|
||||
public Object GetAllWeeklyTimeSpanByStartdate(DateTime startTime)
|
||||
{
|
||||
var data = _weeklytimespanService.GetPersonByUserName(UserEmail);
|
||||
var data = _weeklytimespanService.GetWeeklyTimeSpanByStartdate(startTime);
|
||||
var json = JsonConvert.SerializeObject(data, Formatting.Indented,
|
||||
new JsonSerializerSettings()
|
||||
{
|
||||
ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
|
||||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
|
||||
}
|
||||
);
|
||||
return json;
|
||||
@ -82,7 +80,19 @@ namespace HanyadikHetVan.Controllers
|
||||
var json = JsonConvert.SerializeObject(data, Formatting.Indented,
|
||||
new JsonSerializerSettings()
|
||||
{
|
||||
ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
|
||||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
|
||||
}
|
||||
);
|
||||
return json;
|
||||
}
|
||||
[HttpGet("{weeklytimespanId}")]
|
||||
public Object GetAllPausesOfTimeSpan(int weeklytimespanId)
|
||||
{
|
||||
var data = _weeklytimespanService.GetPausesOfWeeklyTimeSpan(weeklytimespanId);
|
||||
var json = JsonConvert.SerializeObject(data, Formatting.Indented,
|
||||
new JsonSerializerSettings()
|
||||
{
|
||||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
|
||||
}
|
||||
);
|
||||
return json;
|
||||
|
@ -1,5 +1,7 @@
|
||||
using HanyadikHetVan.Data.Entities;
|
||||
using HanyadikHetVan.Interface;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -21,6 +23,21 @@ namespace HanyadikHetVan.Services
|
||||
return _weeklytimespan.GetAll().ToList();
|
||||
}
|
||||
|
||||
public WeeklyTimeSpan GetWeeklyTimeSpan(int weeklytimespanId)
|
||||
{
|
||||
return _weeklytimespan.GetAll().Where(x => x.Id == weeklytimespanId).FirstOrDefault();
|
||||
}
|
||||
|
||||
public ICollection<Pause> GetPausesOfWeeklyTimeSpan(int weeklytimespanId)
|
||||
{
|
||||
return _weeklytimespan.GetAll().Where(x => x.Id == weeklytimespanId).FirstOrDefault().Pauses;
|
||||
}
|
||||
|
||||
public IEnumerable<WeeklyTimeSpan> GetWeeklyTimeSpanByStartdate(DateTime startTime)
|
||||
{
|
||||
return _weeklytimespan.GetAll().Where(x => x.Startdate.Date.Equals(startTime.Date)).ToList();
|
||||
}
|
||||
|
||||
public async Task<WeeklyTimeSpan> AddWeeklyTimeSpan(WeeklyTimeSpan weeklytimespan)
|
||||
{
|
||||
return await _weeklytimespan.Create(weeklytimespan);
|
||||
|
@ -84,7 +84,7 @@ namespace HanyadikHetVan
|
||||
app.UseDeveloperExceptionPage();
|
||||
app.UseMigrationsEndPoint();
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "HanyadikHetVan v1"));
|
||||
app.UseSwaggerUI(c => c.SwaggerEndpoint("v1/swagger.json", "HanyadikHetVan v1"));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user