Ejemplo n.º 1
0
        void ICompanyService.CreateCompany(CreateCompanyCommand command)
        {
            try
            {
                Company companyToCreate = command.ToCompany();
                companyRepository.CreateCompany(companyToCreate);
                companyRepository.Save();

                CreateCompanyEnrollmentCommand enrollmentCommand = new CreateCompanyEnrollmentCommand()
                {
                    CompanyId        = companyToCreate.Id,
                    IsCompanyCreator = true,
                    UserId           = command.UserId
                };
                companyEnrollmentRepository.CreateCompanyEnrollment(enrollmentCommand.ToCompanyEnrollment());
                companyEnrollmentRepository.Save();
            }
            catch (DbUpdateException ex)
            {
                throw new DbUpdateException("Service failed.\n" + ex.Message, ex.InnerException);
            }
        }