public HttpResponseMessage UserInvited(UserInvitedDTO userInvited) { if (ModelState.IsValid) { try { var command = new AddUserInvitedCommand(); command.Name = userInvited.Name; command.InviteCode = userInvited.InviteCode; command.Email = userInvited.Email; command.EnrollmentIP = userInvited.EnrollmentIP; this.bus.Send(command); } catch (Exception e) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e)); } } return(Request.CreateResponse(HttpStatusCode.OK)); }
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; } }