asd
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Torma Kristóf 2021-05-17 22:53:27 +02:00
parent bd788697c7
commit 4b993aa4e8
Signed by: tormakris
GPG Key ID: DC83C4F2C41B1047
6 changed files with 58 additions and 34 deletions

View File

@ -19,7 +19,7 @@ namespace HanyadikHetVan.Controllers
_service = service; _service = service;
} }
[HttpGet] [HttpGet("json")]
[Consumes("application/json")] [Consumes("application/json")]
public HanyadikHetVanDTO GetJson() public HanyadikHetVanDTO GetJson()
{ {

View File

@ -4,8 +4,6 @@ using HanyadikHetVan.Services;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json; using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace HanyadikHetVan.Controllers namespace HanyadikHetVan.Controllers
@ -24,11 +22,11 @@ namespace HanyadikHetVan.Controllers
_pause = pause; _pause = pause;
} }
[HttpPost] [HttpPost]
public async Task<Object> AddPause([FromBody] Pause weeklytimespan) public async Task<Object> AddPause([FromBody] Pause pause)
{ {
try try
{ {
await _pauseService.AddPause(weeklytimespan); await _pauseService.AddPause(pause);
return true; return true;
} }
catch (Exception) catch (Exception)
@ -37,12 +35,12 @@ namespace HanyadikHetVan.Controllers
return false; return false;
} }
} }
[HttpDelete] [HttpDelete("{pauseId}")]
public bool DeletePause(int weeklyTimeSpanId) public bool DeletePause(int pauseId)
{ {
try try
{ {
_pauseService.DeletePause(weeklyTimeSpanId); _pauseService.DeletePause(pauseId);
return true; return true;
} }
catch (Exception) catch (Exception)
@ -51,11 +49,11 @@ namespace HanyadikHetVan.Controllers
} }
} }
[HttpPut] [HttpPut]
public bool UpdatePause(Pause Object) public bool UpdatePause([FromBody] Pause pause)
{ {
try try
{ {
_pauseService.UpdatePause(Object); _pauseService.UpdatePause(pause);
return true; return true;
} }
catch (Exception) catch (Exception)
@ -64,25 +62,13 @@ namespace HanyadikHetVan.Controllers
} }
} }
[HttpGet] [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() public Object GetAllPauses()
{ {
var data = _pauseService.GetAllPauses(); var data = _pauseService.GetAllPauses();
var json = JsonConvert.SerializeObject(data, Formatting.Indented, var json = JsonConvert.SerializeObject(data, Formatting.Indented,
new JsonSerializerSettings() new JsonSerializerSettings()
{ {
ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore ReferenceLoopHandling = ReferenceLoopHandling.Ignore
} }
); );
return json; return json;

View File

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace HanyadikHetVan.Controllers
{
public class UserController
{
}
}

View File

@ -4,8 +4,6 @@ using HanyadikHetVan.Services;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json; using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace HanyadikHetVan.Controllers namespace HanyadikHetVan.Controllers
@ -37,7 +35,7 @@ namespace HanyadikHetVan.Controllers
return false; return false;
} }
} }
[HttpDelete] [HttpDelete("{weeklyTimeSpanId}")]
public bool DeleteWeeklyTimeSpan(int weeklyTimeSpanId) public bool DeleteWeeklyTimeSpan(int weeklyTimeSpanId)
{ {
try try
@ -51,11 +49,11 @@ namespace HanyadikHetVan.Controllers
} }
} }
[HttpPut] [HttpPut]
public bool UpdateWeeklyTimeSpan(WeeklyTimeSpan Object) public bool UpdateWeeklyTimeSpan([FromBody] WeeklyTimeSpan weeklytimespan)
{ {
try try
{ {
_weeklytimespanService.UpdateWeeklyTimeSpan(Object); _weeklytimespanService.UpdateWeeklyTimeSpan(weeklytimespan);
return true; return true;
} }
catch (Exception) catch (Exception)
@ -63,14 +61,14 @@ namespace HanyadikHetVan.Controllers
return false; return false;
} }
} }
[HttpGet] [HttpGet("{startTime}")]
public Object GetAllWeeklyTimeSpanByStartdate(DateTime UserEmail) public Object GetAllWeeklyTimeSpanByStartdate(DateTime startTime)
{ {
var data = _weeklytimespanService.GetPersonByUserName(UserEmail); var data = _weeklytimespanService.GetWeeklyTimeSpanByStartdate(startTime);
var json = JsonConvert.SerializeObject(data, Formatting.Indented, var json = JsonConvert.SerializeObject(data, Formatting.Indented,
new JsonSerializerSettings() new JsonSerializerSettings()
{ {
ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore ReferenceLoopHandling = ReferenceLoopHandling.Ignore
} }
); );
return json; return json;
@ -82,7 +80,19 @@ namespace HanyadikHetVan.Controllers
var json = JsonConvert.SerializeObject(data, Formatting.Indented, var json = JsonConvert.SerializeObject(data, Formatting.Indented,
new JsonSerializerSettings() 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; return json;

View File

@ -1,5 +1,7 @@
using HanyadikHetVan.Data.Entities; using HanyadikHetVan.Data.Entities;
using HanyadikHetVan.Interface; using HanyadikHetVan.Interface;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -21,6 +23,21 @@ namespace HanyadikHetVan.Services
return _weeklytimespan.GetAll().ToList(); 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) public async Task<WeeklyTimeSpan> AddWeeklyTimeSpan(WeeklyTimeSpan weeklytimespan)
{ {
return await _weeklytimespan.Create(weeklytimespan); return await _weeklytimespan.Create(weeklytimespan);

View File

@ -84,7 +84,7 @@ namespace HanyadikHetVan
app.UseDeveloperExceptionPage(); app.UseDeveloperExceptionPage();
app.UseMigrationsEndPoint(); app.UseMigrationsEndPoint();
app.UseSwagger(); app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "HanyadikHetVan v1")); app.UseSwaggerUI(c => c.SwaggerEndpoint("v1/swagger.json", "HanyadikHetVan v1"));
} }
else else
{ {