Exemple #1
0
        public async Task <IActionResult> AddChild(AddChildVM child)
        {
            if (!ModelState.IsValid)
            {
                return(InvalidChildToAdd(child));
            }

            var addedChild = await _manager.AddChildForUser(child.FirstName, child.LastName, UserId);

            var childVM = ChildToVM(addedChild);

            return(Ok(childVM));
        }
Exemple #2
0
 private async Task AddChildrenInList(IEnumerable <string> names, string lastName, string adultId)
 {
     foreach (var name in names)
     {
         if (!await _manager.ChildExists(name, lastName, adultId))
         {
             _children.Add(await _manager.AddChildForUser(name, lastName, adultId));
         }
         else
         {
             _children.Add(await _manager.GetChild(name, lastName, adultId));
         }
     }
 }