public async Task <CommandExecutionResult> HandleAsync(AddEmployeePhoneCommand command) { var phoneEntity = command.Adapt <PhoneEntity>(); await _repository.InsertAsync(phoneEntity); return(CommandExecutionResult.Success); }
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)))); }
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();