public async Task <IActionResult> OnPostAsync()
        {
            if (ModelState.IsValid)
            {
                var userId = userManager.GetUserId(User);
                var result = await babiesService.UpdateBaby(EditBaby, userId);

                if (result != null)
                {
                    return(RedirectToPage("/Babies/Babies"));
                }
            }

            return(Page());
        }
Beispiel #2
0
        public async Task <IActionResult> PutBaby([FromRoute] string userId, [FromBody] PutBaby baby)
        {
            var putBaby = new Baby()
            {
                Id         = baby.Id,
                Name       = baby.Name,
                GenderType = (GenderType)Enum.Parse(typeof(GenderType), baby.GenderType),
                BloodType  = baby.BloodType,
                Allergies  = baby.Allergies,
                Notes      = baby.Notes
            };

            var result = await babiesService.UpdateBaby(putBaby, userId);

            if (result == null)
            {
                return(NotFound());
            }

            return(NoContent());
        }