public ActionResult <Company> Hire([FromRoute] int companyId, [FromRoute] int contactId) { var command = new HireEmployeeCommand { CompanyId = companyId, ContactId = contactId }; var company = _companyService.Hire(command); return(Ok(company)); }
public async Task <IHttpActionResult> HireEmployee(Guid id, HireEmployeeCommand command) { command.Validate(); command.Id = id; await _bus.DispatchAsync(command); return(Ok()); }
/// <inheritdoc /> public async Task HandleAsync(HireEmployeeCommand command) { var company = await _companyRepository.GetAsync(command.Id); if (company == null) { throw new CommandHandlerNotFoundException("Company Not Found"); } company.HireEmployee(new Employee(new FullName(command.FirstName, command.LastName), new NationalCode(command.NationalCode))); await _unitOfWork.CommitAsync(); }
public Company Hire(HireEmployeeCommand command) { var company = GetCompany(command.CompanyId); company.CompanyEmployees.Add(new CompanyEmployees { ContactId = command.ContactId }); _contactsContext.SaveChanges(); return(company); }
public async Task <ActionResult> Create([FromBody] HireEmployeeCommand command) { try { var result = await mediator.Send(command); return(Created($"/employees/{result.Id}", result)); } catch (BusinessException ex) { return(ex.GetError()); } }