예제 #1
0
        public async Task <IActionResult> Add(AddAccountantViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Invalid data model."));
            }

            AddAccountantCommand command = new AddAccountantCommand
            {
                Email     = model.Email,
                FirstName = model.FirstName,
                LastName  = model.LastName,
                Password  = model.Password
            };

            try
            {
                await this.commandBus.SendAsync(command);
            }
            catch
            {
                return(BadRequest("Failed to add accountant."));
            }

            return(Ok(OperationResult.Added(command.Id)));
        }