Exemplo n.º 1
0
        public HttpResponseMessage AddCoworkerCompany(NewCompanyDTO company)
        {
            Claims claims = new Claims().Values();
            Guid   personIntegrationCode = Guid.NewGuid();

            try
            {
                if (ModelState.IsValid)
                {
                    var command = new AddPersonCompanyPartnerCommand();

                    command.IntegrationCode     = Guid.NewGuid();
                    command.PersonIntegrationID = personIntegrationCode;
                    command.CompanyName         = company.CompanyName;
                    command.CompanyPhoneNumber  = company.CompanyPhoneNumber;
                    command.ManagerName         = company.ManagerName;
                    command.ManagerPhoneNumber  = company.ManagerSmartPhoneNumber;
                    command.UserSystemId        = claims.userSystemId;
                    command.ManagerEmail        = company.ManagerEmail;
                    command.CreatedBy           = claims.userSystemId;
                    command.EnrollmentIP        = HttpContext.Current.Request.UserHostAddress;
                    command.PersonOriginType    = GeneralEnumerators.EnumPersonOriginType.IntegracaoAPIExterna;
                    command.SkinId = 3;
                    command.PersonIntegrationFatherId = company.PersonIntegrationFatherId;
                    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));
            }
        }
Exemplo n.º 2
0
        public async Task <HttpResponseMessage> AddAssociateCompanyUser(NewCompanyDTO company)
        {
            try
            {
                Claims claims = new Claims().Values();
                Guid   personIntegrationCode = Guid.NewGuid();
                var    commandCoWorking      = new AddPersonCoworkingCommand();

                commandCoWorking.IntegrationCode    = Guid.NewGuid();
                commandCoWorking.CompanyName        = company.CompanyName;
                commandCoWorking.CompanyPhoneNumber = company.CompanyPhoneNumber;
                commandCoWorking.ManagerName        = company.ManagerName;
                commandCoWorking.ManagerPhoneNumber = company.ManagerSmartPhoneNumber;
                commandCoWorking.UserSystemId       = claims.userSystemId;
                commandCoWorking.ManagerEmail       = company.ManagerEmail;
                commandCoWorking.CreatedBy          = claims.userSystemId;
                commandCoWorking.EnrollmentIP       = "Colocar aqui o IP";

                this.bus.Send(commandCoWorking);

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch (System.Exception e)
            {
                LogManager.Error("Erro ao Add Coworking", e);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e));
            }
        }
Exemplo n.º 3
0
        public async Task <HttpResponseMessage> AddCoworking(NewCompanyDTO coworking)
        {
            Guid   personIntegrationCode = Guid.NewGuid();
            Claims claims = new Claims().Values();

            try
            {
                var command = new AddPersonCoworkingCommand();

                if (ModelState.IsValid)
                {
                    command.IntegrationCode     = personIntegrationCode;
                    command.PersonIntegrationID = Guid.NewGuid();
                    command.CompanyName         = coworking.CompanyName;
                    command.CompanyPhoneNumber  = coworking.CompanyPhoneNumber;
                    command.ManagerName         = coworking.ManagerName;
                    command.ManagerPhoneNumber  = coworking.ManagerSmartPhoneNumber;
                    command.UserSystemId        = claims.userSystemId;
                    command.ManagerEmail        = coworking.ManagerEmail;
                    command.CreatedBy           = claims.userSystemId;
                    command.EnrollmentIP        = "Colocar aqui o IP";
                    command.PersonOriginType    = GeneralEnumerators.EnumPersonOriginType.IntegracaoAPIExterna;
                    this.bus.Send(command);
                }

                this.bus.Send(command);

                return(Request.CreateResponse(HttpStatusCode.OK, personIntegrationCode));
            }
            catch (System.Exception e)
            {
                LogManager.Error("Erro ao Add Coworking", e);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e));
            }
        }
Exemplo n.º 4
0
        public HttpResponseMessage AddServiceProvider(NewCompanyDTO company)
        {
            Claims claims = new Claims().Values();
            Guid   personIntegrationCode = Guid.NewGuid();

            try
            {
                #region PersonCommand Pessoa Juridica
                var CommandCompanyServiceProvider = new AddPersonServiceProviderCommand();

                CommandCompanyServiceProvider.IntegrationCode     = personIntegrationCode;
                CommandCompanyServiceProvider.PersonIntegrationID = Guid.NewGuid();
                CommandCompanyServiceProvider.CompanyName         = company.CompanyName;
                CommandCompanyServiceProvider.CompanyPhoneNumber  = company.CompanyPhoneNumber;
                CommandCompanyServiceProvider.ManagerName         = company.ManagerName;
                CommandCompanyServiceProvider.ManagerPhoneNumber  = company.ManagerSmartPhoneNumber;
                CommandCompanyServiceProvider.UserSystemId        = claims.userSystemId;
                CommandCompanyServiceProvider.ManagerEmail        = company.ManagerEmail;
                CommandCompanyServiceProvider.CreatedBy           = claims.userSystemId;
                CommandCompanyServiceProvider.EnrollmentIP        = "Colocar aqui o IP";
                CommandCompanyServiceProvider.PersonOriginType    = GeneralEnumerators.EnumPersonOriginType.IntegracaoAPIExterna;
                this.bus.Send(CommandCompanyServiceProvider);

                #endregion
                return(Request.CreateResponse(HttpStatusCode.OK, personIntegrationCode));
            }
            catch (System.Exception e)
            {
                LogManager.Error("Erro ao Add UserAdd", e);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e));
            }
        }
Exemplo n.º 5
0
        public async Task <ActionResult> CreateNewCompany([FromBody] NewCompanyDTO newCompanyDTO)
        {
            var command = _mapper.Map <AddCompanyCommand>(newCompanyDTO);

            if (!(await SendCommand(command)))
            {
                return(BadRequest(GetComandErrors()));
            }

            return(Created(Url.Link(nameof(GetCompanybyID), new { companyID = command.CompanyID }), new { companyID = command.CompanyID }));
        }