public HttpResponseMessage AddCoworkerEmployee(NewEmployeeDTO person) { Claims claims = new Claims().Values(); Guid personIntegrationCode = Guid.NewGuid(); try { if (ModelState.IsValid) { var command = new AddPersonEmployeeCommand(); var employeeId = Guid.NewGuid(); command.IntegrationCode = employeeId; command.Name = person.Name; command.PhoneNumber = person.SmartPhoneNumber; command.CreatedBy = claims.userSystemId; command.Email = person.Email; command.SecundaryEmail = person.Email; command.EnrollmentIP = HttpContext.Current.Request.UserHostAddress; command.PersonIntegrationFatherId = person.CompanyIntegrationCode; // todo: eliminar o campo CompanyIntegrationCode e usar apenas o IntegrationCode command.UserProfileId = (GeneralEnumerators.EnumUserProfile)person.UserProfileId; command.PersonOriginType = GeneralEnumerators.EnumPersonOriginType.IntegracaoAPIExterna; command.SkinId = 3; this.bus.Send(command); } return(Request.CreateResponse(HttpStatusCode.OK, personIntegrationCode)); } catch (System.Exception e) { LogManager.Error("Erro ao Add Empresa Coworker", e); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e)); } }
public void Handle(AddUserInvitedCommand command) { try { if (command.InviteCode != null) { var person = _personDao.GetPersonInviteCode(command.InviteCode); if (person != null) { if (person.InviteAvailable < 1) { //sem convites disponiveis var c = new AddSelfRegistrationCommand(); c.Name = command.Name; c.Email = command.Email; c.EnrollmentIP = command.EnrollmentIP; c.InviteCode = command.InviteCode; this.bus.Send(c); } else { //convite disponivel //cadastra a pessoa var c = new AddPersonEmployeeCommand(); c.IntegrationCode = Guid.NewGuid(); c.Name = command.Name; //c.PhoneNumber = employee.SmartPhoneNumber; c.CreatedBy = 1; c.Email = command.Email; c.SecundaryEmail = command.Email; c.EnrollmentIP = command.EnrollmentIP; c.PersonIntegrationFatherId = person.IntegrationCode; c.UserProfileId = GeneralEnumerators.EnumUserProfile.SemAcesso; c.PersonOriginType = GeneralEnumerators.EnumPersonOriginType.PainelAdministrativoGestor; this.bus.Send(c); _personDao.UpdateInviteAvailable(person.PersonId); } } else { //codigo nao encontrado var c = new AddSelfRegistrationCommand(); c.Name = command.Name; c.Email = command.Email; c.EnrollmentIP = command.EnrollmentIP; this.bus.Send(c); } } else { //codigo nao encontrado var c = new AddSelfRegistrationCommand(); c.Name = command.Name; c.Email = command.Email; c.EnrollmentIP = command.EnrollmentIP; this.bus.Send(c); } } catch (Exception ex) { throw ex; } }