public void UpdateJobOpportunity(int id, JobOpportunity updatedJob)
        {
            var existingJob = _jobOpportunityRepository.GetJobOpportunityById(id);

            existingJob.Title = updatedJob.Title;
            existingJob.Approved = updatedJob.Approved;
            existingJob.Category = updatedJob.Category;
            existingJob.CompanyEmail = updatedJob.CompanyEmail;
            existingJob.CompanyLogoUrl = updatedJob.CompanyLogoUrl;
            existingJob.CompanyName = updatedJob.CompanyName;
            existingJob.CompanyUrl = updatedJob.CompanyUrl;
            existingJob.Description = updatedJob.Description;
            existingJob.HowToApply = updatedJob.HowToApply;
            existingJob.IsActive = updatedJob.IsActive;
            existingJob.IsRemote = updatedJob.IsRemote;

            if (updatedJob.JobOpportunityLocation != null)
            {
                existingJob.JobOpportunityLocation = existingJob.JobOpportunityLocation == null
                    ? new JobOpportunityLocation()
                    : existingJob.JobOpportunityLocation;

                existingJob.JobOpportunityLocation.Latitude = updatedJob.JobOpportunityLocation.Latitude;
                existingJob.JobOpportunityLocation.Longitude = updatedJob.JobOpportunityLocation.Longitude;
                existingJob.JobOpportunityLocation.Name = updatedJob.JobOpportunityLocation.Name;
                existingJob.JobOpportunityLocation.PlaceId = updatedJob.JobOpportunityLocation.PlaceId;
            }

            existingJob.JobType = updatedJob.JobType;
            if (updatedJob.JoelTest != null)
            {
                existingJob.JoelTest = existingJob.JoelTest == null
                    ? new JoelTest()
                    : existingJob.JoelTest;

                existingJob.JoelTest.HasBestTools = updatedJob.JoelTest.HasBestTools;
                existingJob.JoelTest.HasBugDatabase = updatedJob.JoelTest.HasBugDatabase;
                existingJob.JoelTest.HasBusFixedBeforeProceding = updatedJob.JoelTest.HasBusFixedBeforeProceding;
                existingJob.JoelTest.HasDailyBuilds = updatedJob.JoelTest.HasDailyBuilds;
                existingJob.JoelTest.HasHallwayTests = updatedJob.JoelTest.HasHallwayTests;
                existingJob.JoelTest.HasOneStepBuilds = updatedJob.JoelTest.HasOneStepBuilds;
                existingJob.JoelTest.HasQuiteEnvironment = updatedJob.JoelTest.HasQuiteEnvironment;
                existingJob.JoelTest.HasSourceControl = updatedJob.JoelTest.HasSourceControl;
                existingJob.JoelTest.HasSpec = updatedJob.JoelTest.HasSpec;
                existingJob.JoelTest.HasTesters = updatedJob.JoelTest.HasTesters;
                existingJob.JoelTest.HasUpToDateSchedule = updatedJob.JoelTest.HasUpToDateSchedule;
                existingJob.JoelTest.HasWrittenTest = updatedJob.JoelTest.HasWrittenTest;
            }

            _jobOpportunityRepository.SaveChanges();

        }
        public void Should_Tweet_JobOpportunity_With_80_Title_Chars()
        {
            //Arrange
            _jobOpportunityController.Url = new UrlHelper(new RequestContext(MvcMoqHelpers.FakeHttpContext(), new RouteData()));
            var title = Get80CharsTitle();

            var jobOpportunity = new JobOpportunity
            {
                Title = title,
                Id = 1
            };
            //Act
            Action act = () => _sut.PostNewJobOpportunity(jobOpportunity, _jobOpportunityController.Url).Wait();

            //Assert
            act.ShouldNotThrow();
        }
        public async Task PostNewJobOpportunity(JobOpportunity jobOpportunity, UrlHelper urlHelper)
        {
            if (string.IsNullOrWhiteSpace(jobOpportunity?.Title) || jobOpportunity.Id <= 0)
                return;

            var length = 80;
            var hashtag = string.Empty;

            if (jobOpportunity.IsRemote)
            {
                length = 64;
                hashtag = " #weworkremotely";
            }

            var title = jobOpportunity.Title.Length > length
                ? jobOpportunity.Title.Substring(0, length)
                : jobOpportunity.Title;

            var action = UrlHelperExtensions.SeoUrl(jobOpportunity.Id, jobOpportunity.Title);
            var url = urlHelper.AbsoluteUrl(action, "jobs");
            var message = $"Se busca: {title}{hashtag} {url}";

            await PostTweet(message).ConfigureAwait(false);
        }
 private static void VerifyGeneratedJobOpportunityEntity(
     NewJobOpportunityViewModel model,
     JobOpportunity entity)
 {
     entity.Title.Should().Be(model.Title);
     entity.Category.Should().Be(model.Category);
     entity.Description.Should().Be(model.Description);
     entity.CompanyName.Should().Be(model.CompanyName);
     entity.CompanyUrl.Should().Be(model.CompanyUrl);
     entity.CompanyLogoUrl.Should().Be(model.CompanyLogoUrl);
     entity.CompanyEmail.Should().Be(model.CompanyEmail);
     entity.PublishedDate.Should().BeCloseTo(DateTime.Now);
     entity.IsRemote.Should().Be(model.IsRemote);
     entity.JobType.Should().Be(model.JobType);
     entity.JobOpportunityLocation.Should().Match<JobOpportunityLocation>(x =>
         x.Latitude == model.LocationLatitude
         && x.Longitude == model.LocationLongitude
         && x.Name == model.LocationName
         && x.PlaceId == model.LocationPlaceId
         );
 }
 public void CreateNewJobOpportunity(JobOpportunity jobOpportunity)
 {
     _jobOpportunityRepository.Add(jobOpportunity);
     _jobOpportunityRepository.SaveChanges();
 }
 public void ToggleHideState(JobOpportunity jobOpportunity)
 {
     jobOpportunity.IsHidden = !jobOpportunity.IsHidden;
     _jobOpportunityRepository.SaveChanges();
 }
 public void SoftDeleteJobOpportunity(JobOpportunity jobOpportunity)
 {
     jobOpportunity.IsActive = false;
     _jobOpportunityRepository.SaveChanges();
 }
 public void CreateNewJobOpportunity(JobOpportunity jobOpportunity, string userid)
 {
     jobOpportunity.UserProfile = _userProfileRepository.GetByUserId(userid);
     _jobOpportunityRepository.Add(jobOpportunity);
     _jobOpportunityRepository.SaveChanges();
 }