public JobOpportunity GetJobOpportunity(int idJob)
        {
            try
            {
                using (SqlConnection con = new SqlConnection(_connectionString))
                {
                    JobOpportunity job = new JobOpportunity();

                    con.Open();
                    SqlCommand command = new SqlCommand("SELECT * FROM JobOpportunities WHERE Id = @p1", con);

                    command.Parameters.AddWithValue("@p1", idJob);

                    SqlDataReader reader = command.ExecuteReader();

                    while (reader.Read())
                    {
                        job.Id          = Convert.ToInt32(reader["Id"].ToString());
                        job.Description = reader["Description"].ToString();
                        job.Title       = reader["Title"].ToString();
                        job.Salary      = Convert.ToDecimal(reader["Salary"].ToString());
                        job.CreatedOn   = Convert.ToDateTime(reader["CreatedOn"]);
                    }

                    return(job);
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
        public ActionResult Create(JobOpportunityViewModel model)
        {
            if (ModelState.IsValid)
            {
                JobOpportunity job = new JobOpportunity
                {
                    Title       = model.Title,
                    Description = model.Description,
                    Salary      = model.Salary
                };

                var command = new CreateJobOpportunity(new DataBaseServices());

                var correct = command.Execute(job);

                if (correct)
                {
                    TempData["Success"] = "Job opportunity was created successfully";
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ViewBag.Error = "An error has occurred";

                    return(View());
                }
            }
            else
            {
                return(View(model));
            }
        }
Ejemplo n.º 3
0
        protected override void Seed(Database context)
        {
            var oportunidad1 = new JobOpportunity
            {
                Category            = JobCategory.SoftwareDevelopment,
                Title               = "Pega Blo Senior",
                Location            = "Santo Domingo",
                CompanyEmail        = "*****@*****.**",
                CompanyUrl          = "http://www.developers.do",
                RequirementsToApply = "Debe saber programar Java",
                CompanyName         = "Developer DO",
                Created             = DateTime.Now.AddDays(-2),
                PublishedDate       = DateTime.Now
            };

            context.JobOpportunities.AddOrUpdate(d => d.Title,
                                                 oportunidad1);

            var oportunidad2 = new JobOpportunity
            {
                Category            = JobCategory.SoftwareDevelopment,
                Title               = "Pega Blo Junior",
                Location            = "Santo Domingo",
                CompanyEmail        = "*****@*****.**",
                CompanyUrl          = "http://www.developers.do",
                RequirementsToApply = "Debe saber programar C#",
                CompanyName         = "Developer DO",
                Created             = DateTime.Now.AddDays(-3),
                PublishedDate       = DateTime.Now
            };

            context.JobOpportunities.AddOrUpdate(d => d.Title,
                                                 oportunidad2);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Convert JobOpportunity into SyndicationItem
 /// </summary>
 /// <param name="jobOpportunity"></param>
 /// <returns></returns>
 private static SyndicationItem ToSyndicationItem(this JobOpportunity jobOpportunity)
 {
     return(new SyndicationItem()
     {
         Title = new TextSyndicationContent(jobOpportunity.Title),
         Summary = new TextSyndicationContent(jobOpportunity.Description),
         PublishDate = new DateTimeOffset(jobOpportunity.Created)
     });
 }
Ejemplo n.º 6
0
        public async Task PostNewJobOpportunity(JobOpportunity jobOpportunity)
        {
            if (string.IsNullOrWhiteSpace(jobOpportunity?.Title) || jobOpportunity.Id <= 0)
                return;

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

            var message = $"Se busca: {title} http://emplea.do/JobOpportunity/Detail/{UrlHelperExtensions.SeoUrl(jobOpportunity.Id, jobOpportunity.Title)}";

            await PostTweet(message).ConfigureAwait(false);
        }
Ejemplo n.º 7
0
        public async Task PostNewJobOpportunity(JobOpportunity jobOpportunity)
        {
            if (string.IsNullOrWhiteSpace(jobOpportunity?.Title) || jobOpportunity.Id <= 0)
                return;

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

            var message = $"Se busca: {title} http://emplea.do/JobOpportunity/Detail/{jobOpportunity.Id}";

            await PostTweet(message);
        }
        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();
        }
Ejemplo n.º 9
0
        public async Task PostNewJobOpportunity(JobOpportunity jobOpportunity)
        {
            if (string.IsNullOrWhiteSpace(jobOpportunity?.Title) || jobOpportunity.Id <= 0)
            {
                return;
            }

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

            var message = $"Se busca: {title} http://emplea.do/JobOpportunity/Detail/{UrlHelperExtensions.SeoUrl(jobOpportunity.Id, jobOpportunity.Title)}";

            await PostTweet(message);
        }
Ejemplo n.º 10
0
        public Models.JobOpportunity ToEntity()
        {
            var entity = new JobOpportunity {
                Title               = this.Title,
                Location            = this.Location,
                Category            = this.Category,
                RequirementsToApply = this.RequirementsToApply,
                CompanyName         = this.CompanyName,
                CompanyUrl          = this.CompanyUrl,
                CompanyLogoUrl      = this.CompanyLogoUrl,
                CompanyEmail        = this.CompanyEmail
            };

            return(entity);
        }
        public void Should_Tweet_JobOpportunity_With_140_Chars()
        {
            //Arrange
            var title = Get80CharsTitle();

            var jobOpportunity = new JobOpportunity
            {
                Title = title,
                Id = 999999999
            };

            //Act
            Action act = () => _sut.PostNewJobOpportunity(jobOpportunity).Wait();

            //Assert
            act.ShouldNotThrow();
        }
        public JobOpportunity ToEntity()
        {
            var entity = new JobOpportunity
            {
                Title          = Title,
                LocationId     = SelectedLocationId,
                Category       = Category,
                Description    = Description,
                CompanyName    = CompanyName,
                CompanyUrl     = CompanyUrl,
                CompanyLogoUrl = CompanyLogoUrl,
                CompanyEmail   = CompanyEmail,
                PublishedDate  = DateTime.Now
            };

            return(entity);
        }
Ejemplo n.º 13
0
        public void Should_Tweet_JobOpportunity_With_140_Chars()
        {
            //Arrange
            var title = Get80CharsTitle();

            var jobOpportunity = new JobOpportunity
            {
                Title = title,
                Id    = 999999999
            };

            //Act
            Action act = () => _sut.PostNewJobOpportunity(jobOpportunity).Wait();

            //Assert
            act.ShouldNotThrow();
        }
        public Models.JobOpportunity ToEntity()
        {
            var entity = new JobOpportunity {
                Title          = this.Title,
                Location       = this.Location,
                Category       = this.Category,
                Description    = this.Description,
                CompanyName    = this.CompanyName,
                CompanyUrl     = this.CompanyUrl,
                CompanyLogoUrl = this.CompanyLogoUrl,
                CompanyEmail   = this.CompanyEmail,
                Created        = DateTime.Now,
                PublishedDate  = DateTime.Now
            };

            return(entity);
        }
Ejemplo n.º 15
0
        public void Should_Tweet_JobOpportunity_With_140_Chars()
        {
            //Arrange
            var title = Get80CharsTitle();

            _jobOpportunityController.Url = new UrlHelper(new RequestContext(MvcMoqHelpers.FakeHttpContext(), new RouteData()));
            var jobOpportunity = new JobOpportunity
            {
                Title = title,
                Id    = 999999999
            };
            //Act
            Action act = () => _sut.PostNewJobOpportunity(jobOpportunity, _jobOpportunityController.Url).Wait();

            //Assert
            act.ShouldNotThrow();
        }
 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 List <JobOpportunity> JobOpportunities()
        {
            try
            {
                using (SqlConnection connection = new SqlConnection(_connectionString))
                {
                    connection.Open();

                    List <JobOpportunity> jobOpportunities = new List <JobOpportunity>();

                    SqlCommand command = new SqlCommand("SELECT * FROM JobOpportunities", connection);

                    SqlDataReader reader = command.ExecuteReader();

                    while (reader.Read())
                    {
                        JobOpportunity job = new JobOpportunity
                        {
                            Id          = Convert.ToInt32(reader["Id"].ToString()),
                            Description = reader["Description"].ToString(),
                            Title       = reader["Title"].ToString(),
                            Salary      = Convert.ToDecimal(reader["Salary"].ToString()),
                            CreatedOn   = Convert.ToDateTime(reader["CreatedOn"])
                        };

                        jobOpportunities.Add(job);
                    }

                    return(jobOpportunities);
                }
            }
            catch (Exception)
            {
                return(null);
            }
        }
        public bool CreateJobOpportunity(JobOpportunity jobOpportunity)
        {
            try
            {
                using (SqlConnection con = new SqlConnection(_connectionString))
                {
                    con.Open();
                    SqlCommand command = new SqlCommand("INSERT INTO JobOpportunities VALUES (@p1, @p2, @p3, @p4)", con);

                    command.Parameters.AddWithValue("@p1", jobOpportunity.Title);
                    command.Parameters.AddWithValue("@p2", jobOpportunity.Description);
                    command.Parameters.AddWithValue("@p3", jobOpportunity.Salary);
                    command.Parameters.AddWithValue("@p4", DateTime.Now);

                    int rows = command.ExecuteNonQuery();

                    return(rows > 0);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
 public void CreateNewJobOpportunity(JobOpportunity jobOpportunity, string userid)
 {
     jobOpportunity.UserProfile = _userProfileRepository.GetByUserId(userid);
     _jobOpportunityRepository.Add(jobOpportunity);
     _jobOpportunityRepository.SaveChanges();
 }
Ejemplo n.º 20
0
 public void CreateNewJobOpportunity(JobOpportunity jobOpportunity)
 {
     _jobOpportunityRepository.Add(jobOpportunity);
     _jobOpportunityRepository.SaveChanges();
 }
 public bool Execute(JobOpportunity jobOpportunity)
 {
     return(_database.CreateJobOpportunity(jobOpportunity));
 }
 public void SoftDeleteJobOpportunity(JobOpportunity jobOpportunity)
 {
     jobOpportunity.IsActive = false;
     _jobOpportunityRepository.SaveChanges();
 }
 public void ToggleHideState(JobOpportunity jobOpportunity)
 {
     jobOpportunity.IsHidden = !jobOpportunity.IsHidden;
     _jobOpportunityRepository.SaveChanges();
 }