Exemplo n.º 1
0
        public async Task <CommandExecutionResult> HandleAsync(AddEmployeePhoneCommand command)
        {
            var phoneEntity = command.Adapt <PhoneEntity>();

            await _repository.InsertAsync(phoneEntity);

            return(CommandExecutionResult.Success);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> AddPhone(AddEmployeePhoneQuery query, AddEmployeePhoneCommand command)
        {
            if (ModelState.IsValid == false)
            {
                var queryExecutionResult = await _employeeService.HandleAsync(query);

                var vm = BuildNewPhoneVm(queryExecutionResult.Result, command);

                return(View(vm));
            }

            await _employeeService.HandleAsync(command);

            return(Redirect(PhonesUri(new SearchEmployeePhoneQuery(query.EmployeeId))));
        }
Exemplo n.º 3
0
 private IPageVm BuildNewPhoneVm(EmployeeEntity employeeEntity, AddEmployeePhoneCommand command) =>
 BuildePhoneTab(employeeEntity).Link(RelTypes.Breadcrumb, "New Email", AddEmailUri(new AddEmployeeEmailQuery(employeeEntity.EmployeeId)))
 .Property(nameof(AddEmployeePhoneCommand.Phone), "Phone", command.Phone)
 .Property(nameof(AddEmployeePhoneCommand.Description), "Description", command.Description)
 .Build()
 .ToFormVm();