public async Task <bool> Edit(JobOffer item)
        {
            var offer = await _jobOfferRepo.GetById(item.JobOfferId);

            offer.JobCategory = await _jobCategoryRepo.GetById(item.JobCategoryId);

            offer.JobType = await _jobTypeRepo.GetById(item.JobTypeId);

            offer.PostalCode  = item.PostalCode;
            offer.Title       = item.Title;
            offer.Description = item.Description;
            offer.Wage        = item.Wage;
            offer.LastEdit    = DateTime.Now;

            try
            {
                _jobOfferRepo.Update(offer);
                await _unitOfWork.Save();
            }
            catch (DbUpdateConcurrencyException)
            {
                return(false);
            }

            return(true);
        }
        public async Task <JobOfferViewModel> Update(JobOfferViewModel jobOfferViewModel)
        {
            var jobOffer = _mapper.Map <JobOffer>(jobOfferViewModel);

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

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

            if (!_jobOfferRepository.Get(j => j.Id == jobOffer.Id).Result.Any())
            {
                Notify("Job offer does not exists.");

                return(null);
            }

            await _jobOfferRepository.Update(jobOffer);

            return(_mapper.Map <JobOfferViewModel>(jobOffer));
        }
Esempio n. 3
0
        public ActionResult Update(JobOffer round)
        {
            ApiResult <JobOffer> apiResult;

            if (ModelState.IsValid)
            {
                if (round.Id > 0)
                {
                    apiResult = TryExecute(() =>
                    {
                        _jobOfferRepository.Update(round);
                        _unitOfWork.Commit();
                        return(round);
                    }, "Job Offer updated sucessfully");
                }
                else
                {
                    apiResult = TryExecute(() =>
                    {
                        _jobOfferRepository.Create(round);
                        _unitOfWork.Commit();
                        return(round);
                    }, "Job Offer created sucessfully");
                }
            }
            else
            {
                apiResult = ApiResultFromModelErrors <JobOffer>();
            }

            return(Json(apiResult, JsonRequestBehavior.AllowGet));
        }
Esempio n. 4
0
        public JobOfferDTO UpdateJobOffer(JobOfferForManipulationDTO jobOffer, Guid id)
        {
            var jobOfferFromDb = _jobOfferRepository.GetJobOfferWithFullData(id);

            if (jobOfferFromDb == null)
            {
                var jobOfferToAdd = _mapper.Map <JobOffer>(jobOffer);
                jobOfferToAdd.Id           = id;
                jobOfferToAdd.DateOfAdding = DateTime.Now;

                _jobOfferRepository.Add(jobOfferToAdd);
                if (!_jobOfferRepository.Save())
                {
                    throw new Exception("Error during Job offer upserting!");
                }

                var jobOfferUpserted = _mapper.Map <JobOfferDTO>(jobOfferToAdd);
                return(jobOfferUpserted);
            }
            else
            {
                var jobOfferForUpdate = _mapper.Map(jobOffer, jobOfferFromDb);
                _jobOfferRepository.Update(jobOfferForUpdate);

                if (!_jobOfferRepository.Save())
                {
                    throw new Exception("Error during Job offer updating...");
                }

                var jobOfferUpdated = _mapper.Map <JobOfferDTO>(jobOfferForUpdate);
                return(jobOfferUpdated);
            }
        }
Esempio n. 5
0
        public ActionResult Edit(JobOffer jobOffer)
        {
            if (ModelState.IsValid)
            {
                _jobOfferRepository.Update(jobOffer);
                _unitOfWork.Commit();

                return(RedirectToAction("Index"));
            }

            ViewBag.CandidateId   = new SelectList(_candidateRepository.GetAll("Person"), "Id", "Source", jobOffer.CandidateId);
            ViewBag.DesignationId = new SelectList(_designationRepository.GetAll(), "Id", "Title", jobOffer.DesignationId);

            return(View(jobOffer));
        }