public async Task <ActionResult <Pirate> > AddPirate([FromBody] NewPirate pirate)
        {
            var p = new Pirate
            {
                Name            = pirate.Name,
                RealName        = pirate.RealName,
                YearOfBirth     = pirate.YearOfBirth,
                YearOfDeath     = pirate.YearOfDeath,
                CountryOfOrigin = pirate.CountryOfOrigin
            };
            await context.Pirates.AddAsync(p);

            await context.SaveChangesAsync();

            return(CreatedAtRoute(nameof(GetPirateById), new { id = p.ID }, p));
        }
        public async Task OnPostDelete(Guid id)
        {
            var pirate = await context.Pirates.FirstOrDefaultAsync(p => p.ID == id);

            if (pirate != null)
            {
                context.Pirates.Remove(pirate);
                await context.SaveChangesAsync();
            }

            await OnPostFilter();
        }
        public async Task <IActionResult> OnPost()
        {
            if (ModelState.IsValid && Pirate != null)
            {
                if (RouteData.Values["id"] != null)
                {
                    context.Pirates.Update(Pirate);
                }
                else
                {
                    context.Pirates.Add(Pirate);
                }

                await context.SaveChangesAsync();

                return(RedirectToPage("Index"));
            }

            return(Page());
        }