static void Main(string[] args) { Interest interest = new Interest() { Description = "test", InterestId = 2, Type = "Chess" }; List <Interest> interests = new List <Interest>(); interests.Add(interest); Child child = new Child() { Id = 1, Age = 12, EyeColor = "blue", FirstName = "John", HairColor = "Grey", Height = 178, LastName = "Doe", Sex = "M", Weight = 67, Interests = interests }; ChildRepo childRepo = new ChildRepo(); childRepo.AddChild(child); Console.WriteLine(childRepo.GetAllChildren().ToString()); }
public async Task <ChildDTO> AddChild(Guid personId, ChildDTO child) { var personEntity = await PersonRepo.GetPerson(personId).ConfigureAwait(false); if (personEntity == null) { return(null); } child.Id = Guid.NewGuid(); child.PersonId = personId; await ChildRepo.AddChild(personId, child).ConfigureAwait(false); child.Age = child.Birthday.HasValue ? DateTime.Today.Year - child.Birthday.Value.Year : await NumberGenerator.GetRandomNumbers().ConfigureAwait(false); Logger.LogInformation($"Child with id {child.Id} successfully created."); return(child); }