Exemplo n.º 1
0
        public void Apply(AddVaccineCommand command)
        {
            EnsureNotExistVaccine(command.Name);

            Vaccines.Add(new Vaccine
            {
                Id        = Guid.NewGuid().ToString(),
                Name      = command.Name,
                AppliedAt = command.AppliedAt,
                CreatedAt = DateTime.Now.Date
            });
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Post(string id, [FromBody] AddVaccineCommand command)
        {
            Person person = await peopleRepository.GetAsync(id);

            if (person == null)
            {
                return(new NotFoundResult());
            }

            person.Apply(command);

            await peopleRepository.UpdateAsync(person);

            return(new OkObjectResult(person));
        }