diff --git a/HanyadikHetVan/Controllers/HanyadikHetVanController.cs b/HanyadikHetVan/Controllers/HanyadikHetVanController.cs index ab95a28..8a33fec 100644 --- a/HanyadikHetVan/Controllers/HanyadikHetVanController.cs +++ b/HanyadikHetVan/Controllers/HanyadikHetVanController.cs @@ -19,7 +19,7 @@ namespace HanyadikHetVan.Controllers _service = service; } - [HttpGet] + [HttpGet("json")] [Consumes("application/json")] public HanyadikHetVanDTO GetJson() { diff --git a/HanyadikHetVan/Controllers/PauseController.cs b/HanyadikHetVan/Controllers/PauseController.cs index 3585199..bf639dd 100644 --- a/HanyadikHetVan/Controllers/PauseController.cs +++ b/HanyadikHetVan/Controllers/PauseController.cs @@ -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 AddPause([FromBody] Pause weeklytimespan) + public async Task 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; diff --git a/HanyadikHetVan/Controllers/UserController.cs b/HanyadikHetVan/Controllers/UserController.cs new file mode 100644 index 0000000..7aff46e --- /dev/null +++ b/HanyadikHetVan/Controllers/UserController.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace HanyadikHetVan.Controllers +{ + public class UserController + { + } +} diff --git a/HanyadikHetVan/Controllers/WeeklyTimeSpanController.cs b/HanyadikHetVan/Controllers/WeeklyTimeSpanController.cs index faf83a4..31f3a7c 100644 --- a/HanyadikHetVan/Controllers/WeeklyTimeSpanController.cs +++ b/HanyadikHetVan/Controllers/WeeklyTimeSpanController.cs @@ -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; diff --git a/HanyadikHetVan/Services/WeeklyTimeSpanService.cs b/HanyadikHetVan/Services/WeeklyTimeSpanService.cs index 07e977d..941be2f 100644 --- a/HanyadikHetVan/Services/WeeklyTimeSpanService.cs +++ b/HanyadikHetVan/Services/WeeklyTimeSpanService.cs @@ -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 GetPausesOfWeeklyTimeSpan(int weeklytimespanId) + { + return _weeklytimespan.GetAll().Where(x => x.Id == weeklytimespanId).FirstOrDefault().Pauses; + } + + public IEnumerable GetWeeklyTimeSpanByStartdate(DateTime startTime) + { + return _weeklytimespan.GetAll().Where(x => x.Startdate.Date.Equals(startTime.Date)).ToList(); + } + public async Task AddWeeklyTimeSpan(WeeklyTimeSpan weeklytimespan) { return await _weeklytimespan.Create(weeklytimespan); diff --git a/HanyadikHetVan/Startup.cs b/HanyadikHetVan/Startup.cs index 1d05e8a..5ac892d 100644 --- a/HanyadikHetVan/Startup.cs +++ b/HanyadikHetVan/Startup.cs @@ -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 {