Beispiel #1
0
        public async Task <IActionResult> OnPostAsync()
        {
            var tracks = await _apiClient.GetTracksAsync();

            if (tracks.Any(t => t.Name == Track.Name && t.ConferenceID == Track.ConferenceID))
            {
                ModelState.AddModelError("Track.Name", $"The track name {Track.Name} exists already");
            }

            if (!ModelState.IsValid)
            {
                await GetConferences();

                return(Page());
            }

            Message = "Track created successfully!";

            await _apiClient.AddTrackAsync(Track);

            return(RedirectToPage());
        }