Ejemplo n.º 1
0
        public async Task <JobOfferViewModel> Add(JobOfferViewModel jobOfferViewModel)
        {
            var jobOffer = _mapper.Map <JobOffer>(jobOfferViewModel);

            jobOffer.Id = Guid.NewGuid();

            if (!ExecuteValidation(new JobOfferValidation(), jobOffer))
            {
                return(null);
            }

            if (_jobOfferRepository.Get(j => j.ContractCode == jobOffer.ContractCode).Result.Any())
            {
                Notify("There is already a jobber offer with the contract code informed.");
                return(null);
            }

            if (!_companyrepository.Get(j => j.Id == jobOffer.CompanyId).Result.Any())
            {
                Notify("The company does not exists.");
                return(null);
            }

            await _jobOfferRepository.Add(jobOffer);

            return(_mapper.Map <JobOfferViewModel>(jobOffer));
        }
Ejemplo n.º 2
0
        public ActionResult Details(int id)
        {
            var jobOffer = _jobOfferRepository.Get(id);

            return(CheckForNullAndExecute(jobOffer, () => View(jobOffer)));
        }
Ejemplo n.º 3
0
        public ActionResult Get(int id)
        {
            var apiResult = TryExecute(() => _jobOfferRepository.Get(id), "JobOffer fetched sucessfully");

            return(Json(apiResult, JsonRequestBehavior.AllowGet));
        }