public int RegisterUser(SocialPipelineUser user, Company company)
        {
            Contract.Requires(!string.IsNullOrEmpty(user.FirstName));
            Contract.Requires(!string.IsNullOrEmpty(user.Email));
            Contract.Requires(!string.IsNullOrEmpty(user.Password));
            Contract.Requires(!string.IsNullOrEmpty(company.Name));

            return default(int);
        }
        /// <exception cref="UnableToRegisterUserException">Thrown when there are issues registering a new user.</exception>
        public int RegisterUser(SocialPipelineUser user, Company company)
        {
            try
            {
                var userDto = Mapper.Map<SocialPipelineUser, SocialPipelineUserDto>(user);
                var companyDto = Mapper.Map<Company, CompanyDto>(company);

                userDto.Password = PasswordService.Md5Hash(userDto.Password);

                EnsureUserIsNotAlreadyRegistered(user);

                EnsureCompanyIsNotAlreadyRegistered(company);

                return registrationRepository.RegisterUser(userDto, companyDto);
            }
            catch (RegistrationException exception)
            {
                logger.LogException("RegisterUser: Unable to register new user", exception);
                throw new UnableToRegisterUserException("RegisterUser: Unable to register new user", exception);
            }
            catch (SocialPipelineDatabaseConnectionException exception)
            {
                logger.LogException("RegisterUser: Unable to register new user due to database connection issue", exception);
                throw new UnableToRegisterUserException("RegisterUser: Unable to register new user due to database connection issue", exception);
            }
            catch (UserAlreadyRegisteredException exception)
            {
                logger.LogException(string.Format("RegisterUser: User already exists and registered with this email {0}", user.Email));
                throw;
            }
            catch (CompanyAlreadyExistsException exception)
            {
                logger.LogException(string.Format("RegisterUser: Company already exists and registered with this name {0}", company.Name));
                throw;
            }
            catch (Exception exception)
            {
                logger.LogException("RegisterUser: Unhandled Exception", exception);
                throw new UnableToRegisterUserException("RegisterUser: Unhandled Exception", exception);
            }
        }
 private void EnsureCompanyIsNotAlreadyRegistered(Company company)
 {
     try
     {
         var registeredCompany = companyService.FindByName(company.Name);
         if (registeredCompany != null)
             throw new CompanyAlreadyExistsException("RegisterUser: The company already exists");
     }
     catch (FindCompanyException)
     {
         //If the company doesn't exist that's good.
     }
 }