Example #1
0
        public async Task <CommandExecutionResult> HandleAsync(AddEmployeeEmailCommand command)
        {
            var emailEntity = command.Adapt <EmailEntity>();

            await _repository.InsertAsync(emailEntity);

            return(CommandExecutionResult.Success);
        }
Example #2
0
        public async Task <IActionResult> AddEmail(AddEmployeeEmailQuery query, AddEmployeeEmailCommand command)
        {
            if (ModelState.IsValid == false)
            {
                var queryExecutionResult = await _employeeService.HandleAsync(query);

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

                return(View(vm));
            }

            await _employeeService.HandleAsync(command);

            return(Redirect(EmailsUri(new SearchEmployeeEmailQuery(query.EmployeeId))));
        }
Example #3
0
 private IPageVm BuildNewEmailVm(EmployeeEntity employeeEntity, AddEmployeeEmailCommand command) =>
 BuildeEmailTab(employeeEntity).Link(RelTypes.Breadcrumb, "New Email", AddEmailUri(new AddEmployeeEmailQuery(employeeEntity.EmployeeId)))
 .Property(nameof(AddEmployeeEmailCommand.Email), "Email", command.Email)
 .Property(nameof(AddEmployeeEmailCommand.Description), "Description", command.Description)
 .Build()
 .ToFormVm();