Example #1
0
        public ActionResult <JobPositionDto> CreateJobPositionForCompany(Guid companyId, JobPositionForCreationDto dto)
        {
            if (!jobRepository.CompanyExists(companyId))
            {
                return(NotFound());
            }

            var entity = mapper.Map <JobPosition>(dto);

            jobRepository.AddJobPositionForCompany(companyId, entity);
            jobRepository.Save();

            var jobPositionDto = mapper.Map <JobPositionDto>(entity);

            return(CreatedAtRoute("GetJobPositionForCompany",
                                  new { companyId = jobPositionDto.CompanyId, jobPositionId = jobPositionDto.Id },
                                  jobPositionDto));
        }
Example #2
0
        public IActionResult CreateNewJobPosition(string CompanyName, [FromBody] JobPositionForCreationDto newJobPositionss)

        {
            if (newJobPositionss == null)

            {
                return(BadRequest());
            }

            // string companyName = CompanyName;

            if (!_hrResorcesInterface.CompanyExists(CompanyName))
            {
                return(BadRequest("Ne Postoji Kompanija  pod tim imenom"));
            }


            /*  string jobPositionName = newJobPositionss.JobName;
             *
             * if (_hrResorcesInterface.Exists(jobPositionName))
             * {
             * return BadRequest("Postoji Pozicija  pod tim imenom");
             *
             * }*/
            newJobPositionss.CompanyName = CompanyName;//zapamtiti kako se ubacuje !!!
            var finalJobPosition = Mapper.Map <Entities.JobPosition>(newJobPositionss);

            _hrResorcesInterface.AddNewJobPosition(finalJobPosition);

            if (!_hrResorcesInterface.Save())

            {
                return(StatusCode(500, "nije sačuvano"));
            }



            return(CreatedAtRoute(new
                                  { }, finalJobPosition));



            // var JobPositionss = JobPositionDataStore.Current.JobPositions;



            /* if (JobPositionss == null)
             *       {
             *           return NotFound();
             *       }
             *
             *       var maxJobPositionsId = JobPositionDataStore.Current.JobPositions.Max(c => c.JobId);
             *
             *       var finalJobPosition = new JobPositionDto()
             *       {
             *           JobId = ++ maxJobPositionsId,
             *           JobName = newJobPositionss.JobName,
             *          JobDescription = newJobPositionss.JobDescription,
             *           JobCity = newJobPositionss.JobCity,
             *          JobCountry = newJobPositionss.JobCountry,
             *           JobPartTime = newJobPositionss.JobPartTime,
             *          JobKeyWords = newJobPositionss.JobKeyWords,
             *
             *
             *       };
             *       JobPositionss.Add(finalJobPosition);*/


            /*   return CreatedAtRoute( new
             *         { }, finalJobPosition);*/
        }