add missing fields

This commit is contained in:
Julian
2022-02-12 20:08:48 +01:00
parent 3154152851
commit 2a3af9b0a0
7 changed files with 50 additions and 2 deletions

View File

@@ -8,6 +8,7 @@ using weddingapi.Repositories;
using weddingapi.Dtos;
using weddingapi.Converters;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Cors;
namespace weddingapi.Controllers
{
@@ -22,6 +23,15 @@ namespace weddingapi.Controllers
this.repository = repository;
}
// GET /familyCount
[HttpGet("FamilyCount")]
public async Task<int> GetFamilyCountAsync()
{
int totalCount = 0;
(await repository.GetFamiliesAsync()).ToList().ForEach(family => totalCount += family.Members.Count());
return totalCount;
}
// GET /family
[HttpGet]
public async Task<IEnumerable<FamilyDto>> GetFamiliesAsync()
@@ -55,6 +65,8 @@ namespace weddingapi.Controllers
CreatedDate = DateTimeOffset.UtcNow,
Name = familyDto.Name,
Overnight = familyDto.Overnight,
Email = familyDto.EMail,
Telephonenumber = familyDto.Telephonenumber,
Members = familyDto.Members.Select(person => new Person() {
IsChild = person.IsChild,
Name = person.Name,
@@ -84,6 +96,8 @@ namespace weddingapi.Controllers
IsChild = person.IsChild,
}).ToList(),
Overnight = familyDto.Overnight,
Email = familyDto.Email,
Telephonenumber = familyDto.Telephonenumber,
Name = familyDto.Name,
};