diff --git a/MeetUpFunctions/Constants.cs b/MeetUpFunctions/Constants.cs index 297d1a6..a48942f 100644 --- a/MeetUpFunctions/Constants.cs +++ b/MeetUpFunctions/Constants.cs @@ -22,7 +22,7 @@ public static class Constants public const string DEFAULT_DISCLAIMER = "Disclaimer"; public const string DEFAULT_GUEST_DISCLAIMER = "Guest Disclaimer"; - public const string VERSION = "2024-01-02"; + public const string VERSION = "2024-01-24"; public const int ADMINOVERBOOKFACTOR = 1; // no overbooking any more, because not needed public const int LOG_TTL = 30 * 24 * 3600; // 30 days TTL for Log items diff --git a/MeetUpFunctions/RemoveParticipantFromCalendarItem.cs b/MeetUpFunctions/RemoveParticipantFromCalendarItem.cs index b437441..3253370 100644 --- a/MeetUpFunctions/RemoveParticipantFromCalendarItem.cs +++ b/MeetUpFunctions/RemoveParticipantFromCalendarItem.cs @@ -36,6 +36,108 @@ CosmosDBRepository cosmosRepository } [FunctionName("RemoveParticipantFromCalendarItem")] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + public async Task Run( [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req) { diff --git a/MeetUpPlanner/Client/AppState.cs b/MeetUpPlanner/Client/AppState.cs index 1b59941..47d1cb9 100644 --- a/MeetUpPlanner/Client/AppState.cs +++ b/MeetUpPlanner/Client/AppState.cs @@ -55,8 +55,6 @@ public string DisplayName return sb.ToString(); } } - [MaxLength(120, ErrorMessage = "Die Tel-Nr/Mail-Adresse ist zu lang"), MinLength(8, ErrorMessage = "Die Tel-Nr/Mail-Adresse ist zu kurz.")] - [Required(ErrorMessage = "Tel-Nr/Mail-Adresse fehlen.")] public string PhoneMail { get; set; } public Boolean NoAddressNeeded { get; set; } = false; public bool SaveSettings { get; set; } = true; diff --git a/MeetUpPlanner/Client/BackendApiRepository.cs b/MeetUpPlanner/Client/BackendApiRepository.cs index 4c40c64..b15ac54 100644 --- a/MeetUpPlanner/Client/BackendApiRepository.cs +++ b/MeetUpPlanner/Client/BackendApiRepository.cs @@ -11,6 +11,9 @@ using Azure.Storage.Blobs; using Azure.Core; using System.Text; +using Newtonsoft.Json; +using Radzen; +using static System.Net.WebRequestMethods; namespace MeetUpPlanner.Client { @@ -250,6 +253,26 @@ public async Task RemoveFederation(CalendarItem calendarItem) return; } + public async Task RemoveParticipant(Participant participant) + { + this.PrepareHttpClient(); + HttpResponseMessage response = await _http.PostAsJsonAsync($"Calendar/removeparticipant", participant); + string responseBody = await response.Content.ReadAsStringAsync(); + + BackendResult result = JsonConvert.DeserializeObject(responseBody); + return result; + } + public async Task AddParticipant(Participant participant) + { + this.PrepareHttpClient(); + HttpResponseMessage response = await _http.PostAsJsonAsync($"Calendar/addparticipant", participant); + string responseBody = await response.Content.ReadAsStringAsync(); + + BackendResult result = JsonConvert.DeserializeObject(responseBody); + return result; + } + + } } diff --git a/MeetUpPlanner/Client/Pages/About.razor b/MeetUpPlanner/Client/Pages/About.razor index c41b44a..dde24b1 100644 --- a/MeetUpPlanner/Client/Pages/About.razor +++ b/MeetUpPlanner/Client/Pages/About.razor @@ -51,7 +51,7 @@ @code { - private const string clientVersion = "2024-01-02"; + private const string clientVersion = "2024-01-24"; private string serverVersion = "tbd"; private string functionsVersion = "tbd"; diff --git a/MeetUpPlanner/Client/Pages/Calendar.razor b/MeetUpPlanner/Client/Pages/Calendar.razor index 33b7f35..bbb0669 100644 --- a/MeetUpPlanner/Client/Pages/Calendar.razor +++ b/MeetUpPlanner/Client/Pages/Calendar.razor @@ -433,11 +433,7 @@ participant.CalendarItemId = itemId; checkInDisabled = true; StateHasChanged(); - PrepareHttpClient(); - HttpResponseMessage response = await Http.PostAsJsonAsync($"Calendar/addparticipant", participant); - string responseBody = await response.Content.ReadAsStringAsync(); - - BackendResult result = JsonConvert.DeserializeObject(responseBody); + BackendResult result = await Api.AddParticipant(participant); if (result.Success) { if (IsConnected) await SendMessage(); @@ -518,11 +514,7 @@ // Find corresponding participant item Participant participant = calendarItem.FindParticipant(AppStateStore.FirstName, AppStateStore.LastName); - PrepareHttpClient(); - HttpResponseMessage response = await Http.PostAsJsonAsync($"Calendar/removeparticipant", participant); - string responseBody = await response.Content.ReadAsStringAsync(); - - BackendResult result = JsonConvert.DeserializeObject(responseBody); + BackendResult result = await Api.RemoveParticipant(participant); if (result.Success) { if (IsConnected) await SendMessage(); diff --git a/MeetUpPlanner/Server/Controllers/CalendarController.cs b/MeetUpPlanner/Server/Controllers/CalendarController.cs index 4e70f83..23c8546 100644 --- a/MeetUpPlanner/Server/Controllers/CalendarController.cs +++ b/MeetUpPlanner/Server/Controllers/CalendarController.cs @@ -7,6 +7,7 @@ using MeetUpPlanner.Shared; using System; + namespace MeetUpPlanner.Server.Controllers { [Route("[controller]")] @@ -53,6 +54,7 @@ public async Task GetCalendarItems([FromHeader(Name = "x-meetup-t [ProducesResponseType(StatusCodes.Status200OK)] public async Task GetExtendedCalendarItems([FromHeader(Name = "x-meetup-tenant")] string tenant, [FromHeader(Name = "x-meetup-keyword")] string keyword, [FromQuery] string privatekeywords) { + logger.LogInformation("GetExtendedCalendarItems()"); if (String.IsNullOrEmpty(keyword)) { keyword = _meetUpFunctions.InviteGuestKey; @@ -117,6 +119,7 @@ public async Task GetExtendedCalendarItemForGuest([FromHeader(Nam [ProducesResponseType(StatusCodes.Status200OK)] public async Task AddParticipant([FromHeader(Name = "x-meetup-tenant")] string tenant, [FromHeader(Name = "x-meetup-keyword")] string keyword, [FromBody] Participant participant) { + logger.LogInformation("AddParticipant"); if (String.IsNullOrEmpty(keyword)) { keyword = _meetUpFunctions.InviteGuestKey; @@ -146,6 +149,7 @@ public async Task AddGuest([FromHeader(Name = "x-meetup-tenant")] [ProducesResponseType(StatusCodes.Status200OK)] public async Task RemoveParticipant([FromHeader(Name = "x-meetup-tenant")] string tenant, [FromHeader(Name = "x-meetup-keyword")] string keyword, [FromBody] Participant participant) { + logger.LogInformation("RemoveParticipant"); if (String.IsNullOrEmpty(keyword)) { keyword = _meetUpFunctions.InviteGuestKey; diff --git a/MeetUpPlanner/Server/Controllers/UtilController.cs b/MeetUpPlanner/Server/Controllers/UtilController.cs index 93454ca..1247f7e 100644 --- a/MeetUpPlanner/Server/Controllers/UtilController.cs +++ b/MeetUpPlanner/Server/Controllers/UtilController.cs @@ -20,7 +20,7 @@ public class UtilController : ControllerBase { private readonly MeetUpFunctions _meetUpFunctions; private readonly ILogger logger; - const string serverVersion = "2024-01-20"; + const string serverVersion = "2024-01-24"; string functionsVersion = "tbd"; public UtilController(ILogger logger, MeetUpFunctions meetUpFunctions) diff --git a/MeetUpPlanner/Server/Controllers/WinterpokalController.cs b/MeetUpPlanner/Server/Controllers/WinterpokalController.cs index 9407a08..d3bb3d9 100644 --- a/MeetUpPlanner/Server/Controllers/WinterpokalController.cs +++ b/MeetUpPlanner/Server/Controllers/WinterpokalController.cs @@ -6,6 +6,8 @@ using System.Threading.Tasks; using Flurl.Http; using Flurl; +using Flurl.Http.Newtonsoft; +using Newtonsoft.Json; using Microsoft.Extensions.Logging; using MeetUpPlanner.Server.Repositories; using MeetUpPlanner.Shared; @@ -29,15 +31,18 @@ public WinterpokalController(ILogger logger, WinterpokalC public async Task GetTeam([FromRoute] string teamId) { _logger.LogInformation($"GetTeam({teamId})"); - + // To get the dynamic from the serializer Newtonsoft.Json has to be used, + // see https://www.nuget.org/packages/Flurl.Http.Newtonsoft/#readme-body-tab dynamic response = await $"{_winterpokalConfig.ApiEndpoint}/api/v1/teams/get/{teamId}.json" .WithHeader("api-token", _winterpokalConfig.ApiKey) - .GetJsonAsync(); + .WithSettings(s => { s.JsonSerializer = new NewtonsoftJsonSerializer(); }) + .GetJsonAsync(); WinterpokalTeam team = new WinterpokalTeam() { Id = Convert.ToInt64(teamId) }; - if (response.status != "OK") + + if ( response.status != "OK" ) { team.Name = "Team unbekannt"; } diff --git a/MeetUpPlanner/Server/MeetUpPlanner.Server.csproj b/MeetUpPlanner/Server/MeetUpPlanner.Server.csproj index 1e664c5..49ac7ab 100644 --- a/MeetUpPlanner/Server/MeetUpPlanner.Server.csproj +++ b/MeetUpPlanner/Server/MeetUpPlanner.Server.csproj @@ -8,6 +8,7 @@ + diff --git a/MeetUpPlanner/Shared/Participant.cs b/MeetUpPlanner/Shared/Participant.cs index 66dc09b..a0b4b6c 100644 --- a/MeetUpPlanner/Shared/Participant.cs +++ b/MeetUpPlanner/Shared/Participant.cs @@ -14,11 +14,11 @@ public class Participant : CosmosDBEntity /// [JsonProperty(PropertyName = "calendarItemId")] public string CalendarItemId { get; set; } - [JsonProperty(PropertyName = "participantFirstName"), MaxLength(100), Required(ErrorMessage = "Vornamen bitte eingeben.")] + [JsonProperty(PropertyName = "participantFirstName"), MaxLength(100)] public string ParticipantFirstName { get; set; } - [JsonProperty(PropertyName = "participantLastName"), MaxLength(100), Required(ErrorMessage = "Nachnamen bitte eingeben.")] + [JsonProperty(PropertyName = "participantLastName"), MaxLength(100)] public string ParticipantLastName { get; set; } - [JsonProperty(PropertyName = "participantAddressName", NullValueHandling = NullValueHandling.Ignore), MaxLength(100), Required(ErrorMessage = "Bitte eine Adress-Info eingeben.")] + [JsonProperty(PropertyName = "participantAdressInfo"), MaxLength(100)] public string ParticipantAdressInfo { get; set; } [JsonProperty(PropertyName = "checkInDate")] public DateTime CheckInDate { get; set; }