예제 #1
0
        public async Task <AjaxCommandResult> Handle(CreatePersonCommand command)
        {
            string format = "dd/MM/yyyy";

            var newPerson = new Person
            {
                Firstname   = command.Firstname,
                Surname     = command.Surname,
                DateOfBirth = DateTime.ParseExact(command.DateOfBirth, format, CultureInfo.InvariantCulture)
            };

            newPerson.Communication = MapCommuncation(command, newPerson);

            _dbContext.People.Add(newPerson);


            await _dbContext.SaveChangesAsync();

            return(new AjaxCommandResult(true)
            {
                Id = newPerson.Id
            });
        }